Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1289

Re: GridBagLayout and cha

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Chris Smith" <chris.smith@THRWHITE.remove-dii-this>
Subject Re: GridBagLayout and cha
Message-ID <MPG.2070a65072e2ecc5989846@news.altopia.net> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1174860473.305833.284620@n76g2000hsh.googlegroups.com>
References <1174860473.305833.284620@n76g2000hsh.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 29
Date Wed, 27 Apr 2011 15:32:27 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918347 96.60.20.240 (Wed, 27 Apr 2011 10:32:27 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:32:27 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1289

Show key headers only | View raw


  To: comp.lang.java.gui
Daniel Pitts <googlegroupie@coloraura.com> wrote:
> 
> Say I have the following code:
> 
> JPanel myPanel = new JPanel(new GridBagLayout());
> GridBagConstraints constaints = getConstraints();
> myPanel.add(new JLabel("Hello world"), constaints);
> 
> And then later (as a result of an Event), I do something like
> constraints.gridx = 3;
> myPanel.revalidate();
> 
> Will this have the expected effect, or do I need to remove the old
> label, and re-add it with the new constraints?

The latter.  The GridBagLayout class makes a copy of the layout 
constraints when the device is added.  In fact, it's fairly common to 
create just one GridBagConstraints object, and use it to add a large 
number of components by just changing the few properties that differ 
each time.

-- 
Chris Smith

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

GridBagLayout and changin "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Chris Smith" <chris.smith@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: GridBagLayout and cha "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "SadRed" <sadred@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: GridBagLayout and cha "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "SadRed" <sadred@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: GridBagLayout and cha "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: GridBagLayout and cha "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: GridBagLayout and cha "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web