🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7642

Re: Resizing problems

#7642
From: Sam
Date: Wed, 10 Jan 2001 23:28
71 lines
3334 bytes
Thanks, Rich, that's what I was afraid of.  I guess I'll start
translating into a different layout or create a custom one.

In response to Torsten, here is an example of what WON'T work for
attempting to change a component's XYLayout...

In class MyFrame:

...

void this_componentResized(ComponentEvent e) { // resize event

// get frame's width and height, which were set at invocation time
	int x = this.getWidth(); 
	int y = this.getHeight();

// This is component's scaled width
	i = (int)java.lang.Math.rint(0.75*x);
// This is component's scaled height
	j = (int)java.lang.Math.rint(0.25*y);
// This is component's scaled x placement
	k = (int)java.lang.Math.rint(0.15*x);
// This is component's scaled y placement
	l = (int)java.lang.Math.rint(0.35*x);

// Try to re-set the bounds for the component
	jScrollPane1.setBounds(k, l, i, j);
//DOESN'T WORK

// Try to re-set preferred size
	jScrollPane1.setPreferredSize(i, j);
//DOESN'T WORK, neither did anything else I tried!!
...
}



Rich Wilkman wrote:
> 
> Sam:
> 
> XYLayout will never get you there -- that's the problem with co-ordinate
> based layouts.  Things go where you stick them at the size you stick them
> there.  I haven't seen a PercentOfContainer layout so you'll probably have
> to invent one (or use GridBagLayout which is very, very powerful).
> 
> -Rich
> 
> Sam wrote:
> 
> > Hi all-
> >
> > I'm trying to allow a user to resize a GUI.  I'm trying to get it
> > working on a test application first, which has a table within a scroll
> > pane, on a panel in a frame.  When the frame is resized, I'd like the
> > scroll pane to adjust its size based on a percentage of the size of the
> > frame.
> >
> > I'm trying to use the XYLayout, but it seems that no matter what I do
> > (e.g. set bounds, delete and re-add the component, set preferred sizes,
> > etc) the sizes of the components always go back to their initial size.
> > Sometimes you can see the scroll pane flash to the correct size for a
> > moment, but then it resizes to the original XYConstraints.
> >
> > I was hoping not to use a different layout manager, if possible.
> >
> > Can anyone tell me what I'm doing wrong?
> > Thanks
> > Sam
> >
> > BTW, I'm using JBuilder3.
Technical Details
Message-ID: <3A5CF018.151183DA@home.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newsgate.cistron.nl!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!news.imp.ch!news-zh.switch.ch!newsfeed-zh.ip-plus.net!news.ip-plus.net!bornews.borland.com!dnews!24.113.3.107
References: <3A5CBA35.FBDC69B0@home.com> <3A5CCA16.7EC9FF9A@formlessvoid.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,ecab773c49c5caa6
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2001-01-10 15:37:27 PST
Message-ID: <3A5CF018.151183DA@home.com>
Date: Wed, 10 Jan 2001 15:28:24 -0800
From: Sam <ssac@home.com>
Organization: @Home Network
X-Mailer: Mozilla 4.61 [en]C-AtHome0407  (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Resizing problems
References: <3A5CBA35.FBDC69B0@home.com> <3A5CCA16.7EC9FF9A@formlessvoid.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.113.3.107
X-Trace: 10 Jan 2001 15:28:17 -0800, 24.113.3.107
Lines: 71
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newsgate.cistron.nl!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!news.imp.ch!news-zh.switch.ch!newsfeed-zh.ip-plus.net!news.ip-plus.net!bornews.borland.com!dnews!24.113.3.107