Aout Success !!!

Peter C. Mehlitz kaffe@rufus.w3.org
Sat, 25 Jul 1998 14:56:30 +0200


>	...Its necessary to comment preferredSize out, and it fails to run
>	this simple class. Perhaps some people remember it from sawt.
>
>import java.awt.*;
>
>public class AwtHello
>{
>	public static void main (String args[]) {
>		Frame f = new Frame("Hello");
>		TextField t = new TextField ("Salut c'est Kraehe.");
>		f.add(t);
>		f.pack();
>
>	/*	f.resize(f.preferredSize()); */
>
>		f.show ();
>	}
>}

Hello again, deprecateds :-) The X errors are from your window manager,
complaining about a toplevel which is too small (for its decorations). Here is a
fix:

$ diff Frame.java ~/kaffe-1.0.b1/libraries/javalib/java/awt/Frame.java 
86,97d85
< public Dimension getPreferredSize () {
<       Dimension d = super.getPreferredSize();
< 
<       d.width  += 2*Defaults.FrameBorderWidth;
<       d.height += Defaults.TitleBarHeight + Defaults.BottomBarHeight;
< 
<       if ( bMenu != null )
<               d.height += Defaults.MenuBarHeight;
< 
<       return d;
< }
< 

Of course, you also have to add the deprecated "preferredSize()" to Component.
I also increased the default width of TextFields:

$ diff TextField.java
~/kaffe-1.0.b1/libraries/javalib/java/awt/widgets/TextField.java  166c166
<       int cx = 80;
---
>       int cx = 50;
170c170
<               cx = Math.max( cx, 15* fm.charWidth( 'm'));
---
> //            cx = Math.max( cx, fm.stringWidth( label));
173d172
< 

Otherwise, the resize(..) / setBounds(..) should be superfluous (which is even
the pack() - with kaffe).

--
 Peter Mehlitz                         Tel:     +1 510 704 1660 
 Transvirtual Technologies, Inc.,      Fax:     +1 510 704 1893 
 http://www.transvirtual.com           Email:   peter@transvirtual.com