home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Choice;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.TextField;
-
- class DitherControls extends Panel {
- TextField start;
- TextField end;
- Button button;
- Choice choice;
- DitherTest applet;
- static LayoutManager dcLayout = new FlowLayout(1, 10, 5);
-
- public void addRenderButton() {
- ((Container)this).add(this.button = new Button("New Image"));
- }
-
- public int getParams(int[] vals) {
- vals[0] = Integer.parseInt(this.start.getText());
- vals[1] = Integer.parseInt(this.end.getText());
- return this.choice.getSelectedIndex();
- }
-
- public boolean action(Event ev, Object arg) {
- if (ev.target instanceof Button) {
- this.applet.restart();
- return true;
- } else {
- return false;
- }
- }
-
- public DitherControls(DitherTest app, int s, int e, int type, boolean vertical) {
- this.applet = app;
- ((Container)this).setLayout(dcLayout);
- ((Container)this).add(new Label(vertical ? "Vertical" : "Horizontal"));
- ((Container)this).add(this.choice = new Choice());
- this.choice.addItem("Noop");
- this.choice.addItem("Red");
- this.choice.addItem("Green");
- this.choice.addItem("Blue");
- this.choice.addItem("Alpha");
- this.choice.addItem("Saturation");
- this.choice.select(type);
- ((Container)this).add(this.start = new TextField(Integer.toString(s), 4));
- ((Container)this).add(this.end = new TextField(Integer.toString(e), 4));
- }
- }
-