[4679] in java-interest

home help back first fref pref prev next nref lref last post

How to prevent component resizing?

daemon@ATHENA.MIT.EDU (Chris Toomey)
Wed Jan 10 19:43:45 1996

Date: Wed, 10 Jan 96 15:39:29 PST
From: toomey@aolproductions.com (Chris Toomey)
To: java-interest@java.sun.com
Cc: toomey@aolproductions.com


I'd like to include a fixed-size Canvas on a pop-up window that has
some other components as well.

I've created a subclass of Canvas that I've attempted to make fixed-size by
having the constructor do a resize(W, H) and specializing the preferredSize()
and minimumSize() methods to return (W, H), where WxH is my desired fixed
size.

When I pack the canvas into either a BorderLayout or a GridLayout, however,
the reshape() method is called on my canvas and resizes it to a different
size.  So it appears that preferredSize() and minimumSize() are not being
called or are being ignored, which is troubling.

How can this resizing/reshaping be prevented, so that my canvas stays the WxH
size I want it, within its parent frame?

Note that this may be a bug in the Windows95 implementation, as it does not
get resized when run via appletviewer or Netscape 2.0b4 under Solaris on a
Sun, but does when run under Netscape 2.0b4 under Win95 (was not able to test 
via appletviewer under Win95).

And if it is a bug, any ideas how to work around it, e.g., a different layout
manager?

Thanks,
Chris

P.S. Some advice if you're doing AWT stuff: make sure to test your applets
on several different platforms!  Unfortunately, I've learned the behavior
can be different!
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post