home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.5 KB | 66 lines |
- import java.applet.*;
- import java.awt.*;
- import WorkPanel;
-
- class SetSizeFrame extends Frame
- {
- WorkPanel target;
- Applet applet;
- TextField tfWidth, tfHeight, tfComment;
-
- public SetSizeFrame(WorkPanel target, Applet applet)
- {
- super("Set Chart Size");
-
- this.target = target;
- this.applet = applet;
- setLayout(new FlowLayout());
-
- add(new Label("Chart Width : "));
- add((tfWidth =new TextField(4)));
- add(new Label("Chart Height : "));
- add((tfHeight =new TextField(4)));
- add(new Label("Comment : "));
- add((tfComment =new TextField(20)));
- add(new Button("OK"));
- add(new Button("Cancel"));
- }
-
- public boolean keyDown(Event e, int key)
- {
-
- if ( (e.target == tfWidth || e.target == tfHeight) &&
- !(( (Character.isDigit((char)key) && (char)key != '.') ||
- key == e.LEFT || key == e.RIGHT || key == e.HOME || key == e.END ||
- (char) key == '\b'|| key == 127 ))) //**** 127 is Delete key
- return true;
-
- return super.keyDown(e, key);
- }
- public boolean action(Event e, Object what)
- {
- if (e.target instanceof Button)
- {
- if (e.arg == "OK")
- {
- int wid = 0, hig = 0;
-
- try
- wid = Integer.parseInt(tfWidth.getText());
- catch (NumberFormatException nfe1)
- return true;
-
- try
- hig = Integer.parseInt(tfHeight.getText());
- catch (NumberFormatException nfe2)
- return true;
-
- target.setSize(wid, hig, tfComment.getText());
- }
- dispose();
- applet.enable();
- }
- return super.action(e, what);
- }
- }
-