Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Mar 1998 11:55:13 -0700
From:      Nate Williams <nate@mt.sri.com>
To:        "Simon J. Gerraty" <sjg@quick.com.au>
Cc:        freebsd-java@FreeBSD.ORG
Subject:   Re: JVM bug or user error?
Message-ID:  <199803071855.LAA03817@mt.sri.com>
In-Reply-To: <199803071252.XAA01494@zen.quick.com.au>
References:  <199803071252.XAA01494@zen.quick.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
> I have been testing some awt behaviour in my native NetBSD jdk (uses
> lesstif), The reason I'm posting here is that the current FreeBSD JDK
> using Motif shows the same behaviour (bug?).  Note that real apps so
> far have worked fine with the FreeBSD JDK on NetBSD.

Glad to hear it.

> Since all my tests were run on a NetBSD-1.3 box I would appreciate
> it if someone could compile the app and run it on a FreeBSD system.

Done.

> Below is a simple test app which should throw up a username/passwd
> dialogue.   It is hacked from modeFrame11.java from the Java AWT Reference
> book from O'Reilly & Assc. The changes made are simply to allow its
> behviour to be changed at runtime.
> 
> Basically if you compile modeFrameL.java and run 
> 
> java modeFrameL
> 
> this explicitly calls resize(250,125) and you get:
> 
> getPreferredSize(): x=0, y=0
> 
> printed out, and a correctly sized popup window.
>
> If you run "java modeFrameL a", it skips resize() and calls pack(),
> you now get:
> 
> getPreferredSize(): x=217, y=102
> 
> and a 2x2 sized popup!
> 
> If you run "java modeFrameL a b", it does the resize() followed by
> pack() and you get:
> 
> getPreferredSize(): x=217, y=102
> 
> and a reasonably sized popup.

Is the popup window the one with the OK button in it, or the window that
happens after you hit OK?

In any case, I get the following behavior (which all seems to work),
using the JDK I built that should be the same one that I stuck on
FreeBSD's JDK WWW page for download.

caddis:~/InCON/SRI/base/SIData % java modeFrameL 
getPreferredSize(): x=0, y=0
^C

caddis:~/InCON/SRI/base/SIData % java modeFrameL a
getPreferredSize(): x=227, y=132
^C

caddis:~/InCON/SRI/base/SIData % java modeFrameL a b
getPreferredSize(): x=227, y=132
^C

However, all of the frames have the exact same size (both the original
username/password one and the subsequent frame that stays up
afterwards.)


> What is going on?  It appears that getPreferredSize() returns 0x0
> until pack() has been called.

Yep, this is 'expected' behavior unless you explicitly give the
component a size.

> Which is interesting as one of the
> things that pack() does is setSize(getPreferredSize()).

In a couple of our components that have varied size in out application,
we must over-ride getPreferredSize() to contain the largest size the
component will be, since if we don't then resizer endds up with
potentially bogus sizing information which never gets redone. (I suppose
we could call pack() everytime something changed, but that alot and
we've got enough problems with repaint performance already.)

> Anyway, like I said, the surprise was that in this case the FreeBSD
> JDK showed exactly? the same behaviour whereas for real apps dialogs
> etc are sized ok.

I don't see the bug.  I haven't looked more closely into it than to just
run the program and check the results (I haven't analyzed it as well as
you have above), but I'm merely sharing my results and experiences with
this program and Java/AWT in general.




Nate

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803071855.LAA03817>