summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/FieldEditorDialog.java
blob: 04e496c9326d5d2e965d7765328c95d4ad579c86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package NET.worlds.scape;

import NET.worlds.console.Console;
import NET.worlds.console.OkCancelDialog;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.TextField;

public abstract class FieldEditorDialog extends OkCancelDialog {
   private TextField strField = new TextField(40);
   protected EditTile parent;
   private static Font font = new Font(Console.message("GammaTextFont"), 0, 12);

   protected FieldEditorDialog(EditTile parent, String title) {
      super(Console.getFrame(), parent, title);
      this.parent = parent;
   }

   @Override
   protected void build() {
      GridBagConstraints c = new GridBagConstraints();
      c.fill = 2;
      c.weightx = 1.0;
      c.weighty = 1.0;
      c.gridwidth = 0;
      this.strField.setFont(font);
      this.add(this.gbag, this.strField, c);
      super.build();
   }

   protected abstract String getValue();

   protected abstract boolean setValue(String var1);

   @Override
   protected boolean setValue() {
      return this.setValue(this.strField.getText().trim());
   }

   @Override
   public void show() {
      super.show();
      this.strField.setText(this.getValue());
      this.strField.requestFocus();
      this.strField.selectAll();
   }
}