/[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.11.2.1 by gnu_andrew, Fri Jan 14 10:24:17 2005 UTC revision 1.11.2.2 by gnu_andrew, Sun Jan 16 15:15:13 2005 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    
39  package javax.swing;  package javax.swing;
40    
41  import java.awt.Dimension;  import java.awt.Dimension;
# Line 50  import javax.swing.text.Document; Line 51  import javax.swing.text.Document;
51  import javax.swing.text.JTextComponent;  import javax.swing.text.JTextComponent;
52  import javax.swing.text.PlainDocument;  import javax.swing.text.PlainDocument;
53    
   
54  public class JTextField extends JTextComponent  public class JTextField extends JTextComponent
55    implements SwingConstants    implements SwingConstants
56  {  {
# Line 272  public class JTextField extends JTextCom Line 272  public class JTextField extends JTextCom
272    
273    public Dimension getPreferredSize()    public Dimension getPreferredSize()
274    {    {
275      Dimension size;      Dimension size = super.getPreferredSize();
276      FontMetrics fm = getFontMetrics(getFont());  
     int fontHeight = fm.getMaxAscent() + fm.getMaxDescent();  
     int columnWidth = fm.charWidth('m');  
       
277      if (columns != 0)      if (columns != 0)
278        {        size.width = columns * getColumnWidth();
         size = new Dimension(columns * columnWidth + 4, fontHeight + 4);  
       }  
     else  
       {  
         size = new Dimension(10, 10);  
       }  
279    
280      return size;      return size;
281    }    }

Legend:
Removed from v.1.11.2.1  
changed lines
  Added in v.1.11.2.2

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