Re: GridBagLayout and changing constraints objects.
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Sun, 25 Mar 2007 16:32:01 -0600
Daniel Pitts <googlegroupie@xxxxxxxxxxxxx> 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
.
- Prev by Date: Re: MacOS X: annoying rectangle during drag and drop
- Next by Date: Re: GridBagLayout and changing constraints objects.
- Previous by thread: ResultSet and getArray() - Error on AWT
- Next by thread: Re: GridBagLayout and changing constraints objects.
- Index(es):
Relevant Pages
|