AWT: TextField.getPreferredSize ()
Uverdier philippe
kaffe@rufus.w3.org
Thu, 13 Aug 1998 15:08:16 +0200
The 'getPreferredSize()' method of the 'TextField' class
always return 'text width = 50' whatever the string length !
A simple solution is to replace:
public Dimension getPreferredSize() {
int cx = 50;
int cy = 20;
if ( font != null ){
FontMetrics fm = getFontMetrics( font);
// cx = Math.max( cx, fm.stringWidth( label));
cy = Math.max( cy, 3*fm.getHeight()/2 );
}
return new Dimension( cx, cy);
}
.... by:
public Dimension getPreferredSize() {
return getMinimumSize (cols);
}
Regards