Back to index

wims  3.65+svn20090927
TextFieldAction.java
Go to the documentation of this file.
00001 package rene.gui;
00002 
00003 import java.awt.TextField;
00004 import java.awt.event.FocusEvent;
00005 import java.awt.event.FocusListener;
00006 
00012 public class TextFieldAction extends TextField
00013        implements FocusListener
00014 {      protected ActionTranslator T;
00015        String S;
00016        public TextFieldAction (DoActionListener t, String name, String s)
00017        {      super(s);
00018               S=s;
00019               if (Global.NormalFont!=null) setFont(Global.NormalFont);
00020               if (Global.Background!=null) setBackground(Global.Background);
00021               T=new ActionTranslator(t,name);
00022               addActionListener(T);
00023               addFocusListener(this);
00024        }
00025        public TextFieldAction (DoActionListener t, String name)
00026        {      if (Global.NormalFont!=null) setFont(Global.NormalFont);
00027               if (Global.Background!=null) setBackground(Global.Background);
00028               T=new ActionTranslator(t,name);
00029               addActionListener(T);
00030               addFocusListener(this);
00031        }
00032        public TextFieldAction (DoActionListener t, String name, int n)
00033        {      super(n);
00034               if (Global.NormalFont!=null) setFont(Global.NormalFont);
00035               if (Global.Background!=null) setBackground(Global.Background);
00036               T=new ActionTranslator(t,name);
00037               addActionListener(T);
00038               addFocusListener(this);
00039        }
00040        public TextFieldAction (DoActionListener t, String name, String s, int n)
00041        {      super(s,n);
00042               S=s;
00043               if (Global.NormalFont!=null) setFont(Global.NormalFont);
00044               if (Global.Background!=null) setBackground(Global.Background);
00045               T=new ActionTranslator(t,name);
00046               addActionListener(T);
00047               addFocusListener(this);
00048        }
00049        public void triggerAction ()
00050        {      T.trigger();
00051        }
00052        public void focusGained (FocusEvent e)
00053        {      setSelectionStart(0);
00054        }
00055        public void focusLost (FocusEvent e)
00056        {      setSelectionStart(0);
00057               setSelectionEnd(0);
00058        }
00059        public void setText (String s)
00060        {      super.setText(s);
00061               S=s;
00062        }
00063        public String getOldText ()
00064        {      return S;
00065        }
00066        public boolean isChanged ()
00067        {      return !S.equals(getText());
00068        }
00069 }