package NET.worlds.console; import java.awt.Button; import java.awt.Event; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Label; import java.awt.TextArea; import java.util.StringTokenizer; import java.util.Vector; class PersonalInfoDialog extends PolledDialog { private static final long serialVersionUID = 1200424099007473332L; private Vector info; private Button okButton = new Button(Console.message("OK")); private static Font font = new Font(Console.message("MenuFont"), 0, 12); private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12); public PersonalInfoDialog(String name, Vector info) { super(Console.getFrame(), null, Console.message("Personal-Info") + name, false); this.info = info; this.ready(); } @Override protected void build() { GridBagLayout gbag = new GridBagLayout(); this.setLayout(gbag); GridBagConstraints c = new GridBagConstraints(); try { int count = this.info.size(); int i = 0; while (i < count) { StringTokenizer tok = new StringTokenizer(this.info.elementAt(i++), ":"); String heading = tok.nextToken(); c.gridwidth = -1; c.gridheight = 1; c.fill = 1; Label lHead = new Label(heading, 1); lHead.setFont(font); this.add(gbag, lHead, c); int totalLines = Integer.parseInt(tok.nextToken()); int displayLines = Math.max(Math.min(3, totalLines), 1); int maxLine = 0; for (int j = 0; j < totalLines; j++) { maxLine = Math.max(maxLine, this.info.elementAt(i + j).length()); } int scrollFlags = 3; if (maxLine > 40) { if (totalLines > ++displayLines) { scrollFlags = 0; } else { scrollFlags = 2; } } else if (totalLines > displayLines) { scrollFlags = 1; } TextArea t = new TextArea("", displayLines, 40, scrollFlags); t.setFont(font); for (int j = 0; j < totalLines; j++) { if (j > 0) { t.append("\n"); } t.append(this.info.elementAt(i++)); } c.fill = 0; c.gridwidth = 0; c.gridheight = displayLines; t.setEditable(false); this.add(gbag, t, c); } } catch (Exception var14) { this.removeAll(); c.fill = 0; c.gridwidth = 0; c.gridheight = 1; Label lFormat = new Label(Console.message("Format-error")); lFormat.setFont(font); this.add(gbag, lFormat, c); } c.fill = 0; c.gridwidth = 0; c.gridheight = 1; this.okButton.setFont(bfont); this.add(gbag, this.okButton, c); } @Override public boolean action(Event event, Object what) { return event.target == this.okButton ? this.done(false) : false; } @Override public boolean keyDown(Event event, int key) { return key != 27 && key != 10 ? super.keyDown(event, key) : this.done(false); } @Override public void show() { super.show(); this.okButton.requestFocus(); } }