package NET.worlds.console; import NET.worlds.core.IniFile; import NET.worlds.core.Std; import NET.worlds.network.NetUpdate; import java.awt.BorderLayout; import java.awt.Button; import java.awt.Color; import java.awt.Component; import java.awt.Event; import java.awt.Font; import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Label; import java.awt.Panel; import java.awt.TextArea; import java.util.Enumeration; import java.util.Vector; public class AboutDialog extends PolledDialog { private static final long serialVersionUID = -2810306367601133331L; public static final String JavaVersion = "1890a40"; Button okButton = new Button(Console.message("OK")); private static Font font = new Font(Console.message("ConsoleFont"), 0, 12); private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12); String apptitle; AboutDialog(String apptitle, Frame frame) { super(frame, null, Console.message("About") + Std.getProductName(), true); this.apptitle = apptitle; this.ready(); } private Component setConstraints(GridBagLayout gbag, Component comp, GridBagConstraints c) { gbag.setConstraints(comp, c); return comp; } @Override protected void build() { this.setBackground(Color.white); this.setLayout(new BorderLayout()); this.add("North", new Filler(10, 10)); this.add("South", new Filler(10, 10)); this.add("East", new Filler(10, 10)); this.add("West", new Filler(10, 10)); GridBagLayout gbag = new GridBagLayout(); Panel p = new Panel(gbag); p.setFont(font); GridBagConstraints c = new GridBagConstraints(); c.fill = 0; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = 0; c.gridheight = 1; String logo = IniFile.override().getIniString("AboutLogo", Console.message("wlogo.gif")); p.add(this.setConstraints(gbag, new ImageCanvas(logo), c)); c.weightx = 0.0; c.weighty = 0.0; p.add(this.setConstraints(gbag, new Label(this.apptitle), c)); if (Gamma.getShaper() != null) { p.add(this.setConstraints(gbag, new Label(Console.message("about-box-build-date") + " " + Std.getBuildInfo() + ":" + "1890a40"), c)); } else { p.add(this.setConstraints(gbag, new Label(Console.message("about-box-rev") + " " + Std.getVersion() + " : " + "1890a40"), c)); } Vector worlds = NetUpdate.aboutWorlds(); TextArea worldList = new TextArea(10, 40); worldList.setEditable(false); p.add(this.setConstraints(gbag, worldList, c)); Enumeration e = worlds.elements(); while (e.hasMoreElements()) { worldList.append(e.nextElement() + "\n"); } p.add(this.setConstraints(gbag, new Label(Console.message("about-box-1")), c)); p.add(this.setConstraints(gbag, new Label(Console.message("about-box-2")), c)); this.okButton.setFont(bfont); p.add(this.setConstraints(gbag, this.okButton, c)); this.add("Center", p); } @Override public boolean action(Event event, Object what) { return event.target == this.okButton ? this.done(true) : false; } @Override public boolean keyDown(Event event, int key) { return key != 27 && key != 10 ? super.keyDown(event, key) : this.done(true); } @Override public void show() { super.show(); this.okButton.requestFocus(); } }