/[classpath]/classpath/javax/swing/JTextField.java
ViewVC logotype

Diff of /classpath/javax/swing/JTextField.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by mark, Sat Jun 26 16:07:01 2004 UTC revision 1.10 by mark, Thu Jul 22 19:45:39 2004 UTC
# Line 37  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package javax.swing;  package javax.swing;
39    
40    import java.awt.Dimension;
41    import java.awt.Font;
42    import java.awt.FontMetrics;
43  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
44  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
45  import javax.accessibility.AccessibleStateSet;  import javax.accessibility.AccessibleStateSet;
# Line 78  public class JTextField extends JTextCom Line 81  public class JTextField extends JTextCom
81        
82    private int columns;    private int columns;
83    
84      private int align;
85    
86    /**    /**
87     * Creates a new instance of <code>JTextField</code>.     * Creates a new instance of <code>JTextField</code>.
88     */     */
# Line 132  public class JTextField extends JTextCom Line 137  public class JTextField extends JTextCom
137     */     */
138    public JTextField(Document doc, String text, int columns)    public JTextField(Document doc, String text, int columns)
139    {    {
140      if (doc == null)      setDocument(doc == null ? createDefaultModel() : doc);
       doc = createDefaultModel();  
   
     setDocument(doc);  
141      setText(text);      setText(text);
142      setColumns(columns);      setColumns(columns);
143    }    }
# Line 152  public class JTextField extends JTextCom Line 154  public class JTextField extends JTextCom
154    }    }
155    
156    /**    /**
157       * Returns the class ID for the UI.
158       *
159       * @return "TextFieldUI";
160       */
161      public String getUIClassID()
162      {
163        return "TextFieldUI";
164      }
165    
166      /**
167     * Adds a new listener object to this text field.     * Adds a new listener object to this text field.
168     *     *
169     * @param listener the listener to add     * @param listener the listener to add
# Line 175  public class JTextField extends JTextCom Line 187  public class JTextField extends JTextCom
187     * Returns all registered <code>ActionListener</code> objects.     * Returns all registered <code>ActionListener</code> objects.
188     *     *
189     * @return an array of listeners     * @return an array of listeners
190       *
191       * @since 1.4
192     */     */
193    public ActionListener[] getActionListeners()    public ActionListener[] getActionListeners()
194    {    {
# Line 210  public class JTextField extends JTextCom Line 224  public class JTextField extends JTextCom
224        throw new IllegalArgumentException();        throw new IllegalArgumentException();
225    
226      this.columns = columns;      this.columns = columns;
227      // FIXME: Invalidate layout.      invalidate();
228        repaint();
229    }    }
230    
231    public void selectAll()    public int getHorizontalAlignment()
232    {    {
233        return align;
234      }
235    
236      public void setHorizontalAlignment(int newAlign)
237      {
238        int oldAlign = align;
239        align = newAlign;
240        invalidate();
241        repaint();
242        firePropertyChange("horizontalAlignment", oldAlign, newAlign);
243      }
244    
245      public void setFont(Font newFont)
246      {
247        super.setFont(newFont);
248        revalidate();
249      }
250    
251      public Dimension getPreferredSize()
252      {
253        Dimension size;
254        FontMetrics fm = getFontMetrics(getFont());
255        int fontHeight = fm.getMaxAscent() + fm.getMaxDescent();
256        int columnWidth = fm.charWidth('m');
257        
258        if (columns != 0)
259          {
260            size = new Dimension(columns * columnWidth + 4, fontHeight + 4);
261          }
262        else
263          {
264            size = new Dimension(10, 10);
265          }
266    
267        return size;
268    }    }
269  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26