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


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

Re: GridBagLayout and cha

From "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this>
Subject Re: GridBagLayout and cha
Message-ID <t6udnSHBpLX4S5rbnZ2dnUVZ_uiknZ2d@comcast.com> (permalink)
Newsgroups comp.lang.java.gui
References <1174860473.305833.284620@n76g2000hsh.googlegroups.com>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui

"Daniel Pitts" <googlegroupie@coloraura.com> wrote in message 
news:1174860473.305833.284620@n76g2000hsh.googlegroups.com...
>
> 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 will have no effect. Normally you change the (single) constraints
object between adding components. There is no need to create
multiple constraints objects. To change after creation, I assume you
can use GridBagLayout.setConstraints(). You could use
GridBagLayout.getConstraints(), make the change, then use
setConstraints() to avoid storing the constraints object.

---
 * 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