Back to index

wims  3.65+svn20090927
GetParameter.java
Go to the documentation of this file.
00001 package rene.dialogs;
00002 
00003 import java.awt.BorderLayout;
00004 import java.awt.FlowLayout;
00005 import java.awt.Frame;
00006 import java.awt.GridLayout;
00007 import java.awt.Panel;
00008 
00009 import rene.gui.ButtonAction;
00010 import rene.gui.CloseDialog;
00011 import rene.gui.Global;
00012 import rene.gui.HistoryTextField;
00013 import rene.gui.MyLabel;
00014 import rene.gui.MyPanel;
00015 import rene.gui.Panel3D;
00016 
00021 public class GetParameter extends CloseDialog
00022 {      HistoryTextField Input;
00023        static public int InputLength;
00024        String Result="";
00025        boolean Aborted=true;
00026        public GetParameter (Frame f, String title, String prompt, String action)
00027        {      this(f,title,prompt,action,false);
00028        }
00029        public GetParameter (Frame f, String title, String prompt, String action,
00030               String subject)
00031        {      super(f,title,true);
00032               Subject=subject;
00033               Input=new HistoryTextField(this,"Action",InputLength);
00034               Input.addKeyListener(this);
00035               init(f,title,prompt,action,true);
00036        }
00037        public GetParameter (Frame f, String title, String prompt, String action,
00038               boolean help)
00039        {      super(f,title,true);
00040               Input=new HistoryTextField(this,"Action",InputLength);
00041               Input.addKeyListener(this);
00042               init(f,title,prompt,action,help);
00043        }
00044        void init (Frame f, String title, String prompt, String action, boolean help)
00045        {      setLayout(new BorderLayout());
00046               Panel center=new MyPanel();
00047               center.setLayout(new GridLayout(0,1));
00048               center.add(new MyLabel(prompt));
00049               center.add(Input);
00050               add("Center",new Panel3D(center));
00051               Panel south=new MyPanel();
00052               south.setLayout(new FlowLayout(FlowLayout.RIGHT));
00053               south.add(new ButtonAction(this,action,"Action"));
00054               south.add(new ButtonAction(this,Global.name("abort"),"Abort"));
00055               if (help)
00056                      south.add(new ButtonAction(this,Global.name("help","Help"),"Help"));
00057               add("South",new Panel3D(south));
00058               pack();
00059        }
00060        public void doAction (String o)
00061        {      if (o.equals("Abort"))
00062               {      doclose();
00063               }
00064               else if (o.equals("Action"))
00065               {      Result=Input.getText();
00066                      doclose();
00067                      Aborted=false;
00068               }
00069               else super.doAction(o);
00070        }
00071        public void set (String s)
00072        {      Input.setText(s);
00073        }
00074        public String getResult () { return Result; }
00075        public boolean aborted () { return Aborted; }
00076 
00077 }