[4718] in java-interest
Re: java-interest-digest V1 #43
daemon@ATHENA.MIT.EDU (Sami Shaio)
Thu Jan 11 15:45:44 1996
Date: Thu, 11 Jan 1996 10:54:26 -0800
From: Sami.Shaio@Eng.Sun.COM (Sami Shaio)
To: java-interest@java.Eng.Sun.COM, andruid@SLINKY.CS.NYU.EDU
|From andruid@SLINKY.CS.NYU.EDU Thu Jan 11 10:48:18 1996
|
|>>>
|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?
|
It all depends on which layout manager you're using. For example, if you're
using BorderLayout and your canvas happens to be the "North" component,
the layout manager will take into account the height of your canvas but
modify the width to span the maximum width. Other layout managers exist
such as GridBagLayout which let you specify the width,height but specify
the position in a relative way. GridBag also has options for setting
the width,height automatically. FlowLayout will lay out components in
a left-to-right manner without modifying their dimensions at all.
You can also set the layout manager to null (Container.setLayout method)
and place your canvas wherever you want with whatever dimension you want.
--sami
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com