home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / AppB / DitherTest / DitherControls.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-07-26  |  2.2 KB  |  54 lines

  1. import java.awt.Button;
  2. import java.awt.Choice;
  3. import java.awt.Container;
  4. import java.awt.Event;
  5. import java.awt.FlowLayout;
  6. import java.awt.Label;
  7. import java.awt.LayoutManager;
  8. import java.awt.Panel;
  9. import java.awt.TextField;
  10.  
  11. class DitherControls extends Panel {
  12.    TextField start;
  13.    TextField end;
  14.    Button button;
  15.    Choice choice;
  16.    DitherTest applet;
  17.    static LayoutManager dcLayout = new FlowLayout(1, 10, 5);
  18.  
  19.    public void addRenderButton() {
  20.       ((Container)this).add(this.button = new Button("New Image"));
  21.    }
  22.  
  23.    public int getParams(int[] vals) {
  24.       vals[0] = Integer.parseInt(this.start.getText());
  25.       vals[1] = Integer.parseInt(this.end.getText());
  26.       return this.choice.getSelectedIndex();
  27.    }
  28.  
  29.    public boolean action(Event ev, Object arg) {
  30.       if (ev.target instanceof Button) {
  31.          this.applet.restart();
  32.          return true;
  33.       } else {
  34.          return false;
  35.       }
  36.    }
  37.  
  38.    public DitherControls(DitherTest app, int s, int e, int type, boolean vertical) {
  39.       this.applet = app;
  40.       ((Container)this).setLayout(dcLayout);
  41.       ((Container)this).add(new Label(vertical ? "Vertical" : "Horizontal"));
  42.       ((Container)this).add(this.choice = new Choice());
  43.       this.choice.addItem("Noop");
  44.       this.choice.addItem("Red");
  45.       this.choice.addItem("Green");
  46.       this.choice.addItem("Blue");
  47.       this.choice.addItem("Alpha");
  48.       this.choice.addItem("Saturation");
  49.       this.choice.select(type);
  50.       ((Container)this).add(this.start = new TextField(Integer.toString(s), 4));
  51.       ((Container)this).add(this.end = new TextField(Integer.toString(e), 4));
  52.    }
  53. }
  54.