Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1292
| From | "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: GridBagLayout and cha |
| Message-ID | <1174867259.278111.167330@n59g2000hsh.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <4606fe4e$0$8739$ed2619ec@ptn-nntp-reader02.plus.net> |
| Date | 2011-04-27 15:32 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
On Mar 25, 3:57 pm, Tom Hawtin <use...@tackline.plus.com> wrote:
> Daniel Pitts 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?
>
> It wont have any affect. The constraints object is cloned. Indeed it is
> normal to use one constraints object to add many components.
>
> To change the constraints for a component, just call
> LayoutManager[2].addLayoutComponent.
>
> Tom Hawtin
Thanks to everyone who replied.
I should have RTFM. Actually, its RTFA, isn't it?
GridBagLayout.setConstraints is what I need to use. :-)
Cheers,
Daniel.
---
* 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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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