Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] Updated RelayoutExampleView

Gordon Hirsch wrote:
> I've added a bit more to this example view. There are now two swing 
> controls side by side. The grow and shrink buttons add to the preferred 
> size both vertically and horizontally.

A statement that you added in this change is redundant: panel.validate().
I prefer to go without this statement, because:

  - Swing programs are usually written with a minimum amount of validate
    calls. I.e. usually: none. (The Swing system cares about it. When you
    call JLabel.setText, it calls revalidate(), which will do it.)
    Albireo should be tested to work with Swing samples without extra
    validate().

  - When the Swing system does not care about it, the programmer should
    normally not use validate() alone. Either he should call
       revalidate();
    explicitly, or - when the result of the validation must be present
    immediately -
       invalidate();
       validate();

Bruno


Index: src/org/eclipse/albireo/examples/plugin/views/SwingGrowShrinkControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.examples.plugin/src/org/eclipse/albireo/examples/plugin/views/SwingGrowShrinkControl.java,v
retrieving revision 1.6
diff -c -3 -r1.6 SwingGrowShrinkControl.java
*** src/org/eclipse/albireo/examples/plugin/views/SwingGrowShrinkControl.java	22 Feb 2008 20:13:56 -0000	1.6
--- src/org/eclipse/albireo/examples/plugin/views/SwingGrowShrinkControl.java	27 Feb 2008 17:05:07 -0000
***************
*** 110,116 ****
              JLabel label = (JLabel)labels.remove(0);
              panel.remove(label);
          }
-         panel.validate();
          for (Iterator iterator = labels.iterator(); iterator.hasNext();) {
              JLabel label = (JLabel)iterator.next();
              label.setText(text);
--- 110,115 ----


Back to the top