Re: GridBagLayout and changing constraints objects.



On Mar 26, 2:46 am, Ian Wilson <scoblo...@xxxxxxxxxxxxx> wrote:
Daniel Pitts wrote:
Say I have the following code:

OK, I shall ...



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?

Others have given the answer you were seeking. However I can't help
noticing that the code you quoted can never have the expected effect
since constaints != constraints :-)

Did I surround that code with an sscce tag? I don't think so. :-)

.



Relevant Pages

  • Re: GridBagLayout and changing constraints objects.
    ... myPanel.add, constaints); ... You will have to remove it and re-add it. ... ever played a game on Yahoo games? ... isn't going to do much because you aren't defining what your constraints ...
    (comp.lang.java.gui)
  • Re: GridBagLayout and changing constraints objects.
    ... GridBagConstraints constaints = getConstraints; ... myPanel.add, constaints); ... Will this have the expected effect, or do I need to remove the old ... However I can't help noticing that the code you quoted can never have the expected effect since constaints!= constraints :-) ...
    (comp.lang.java.gui)
  • Re: GridBagLayout and changing constraints objects.
    ... GridBagConstraints constaints = getConstraints; ... label, and re-add it with the new constraints? ...
    (comp.lang.java.gui)