I wrote a mauve test to back up my earlier patch and found that the same pattern can be applied to all visual property changes: simply call installComponents() and uninstallComponents() when any one of the visual properties changes.

These last two patches fix a serious regression and are backed by a Mauve test. Please merge into the release branch.

2006-08-01  Roman Kennke  <[EMAIL PROTECTED]>

        PR 28562
        * javax/swing/plaf/basic/BasicOptionPaneUI.java
        (PropertyChangeHandler.propertyChange): Cleanly reinstall
        components when visual property chanegs.


/Roman
Index: javax/swing/plaf/basic/BasicOptionPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java,v
retrieving revision 1.34
diff -u -1 -2 -r1.34 BasicOptionPaneUI.java
--- javax/swing/plaf/basic/BasicOptionPaneUI.java	1 Aug 2006 15:41:57 -0000	1.34
+++ javax/swing/plaf/basic/BasicOptionPaneUI.java	1 Aug 2006 20:51:16 -0000
@@ -399,42 +399,33 @@
    *           public for compatibility.
    */
   public class PropertyChangeHandler implements PropertyChangeListener
   {
     /**
      * This method is called when one of the properties of the JOptionPane
      * changes.
      *
      * @param e The PropertyChangeEvent.
      */
     public void propertyChange(PropertyChangeEvent e)
     {
-      if (e.getPropertyName().equals(JOptionPane.ICON_PROPERTY)
-          || e.getPropertyName().equals(JOptionPane.MESSAGE_TYPE_PROPERTY))
-	addIcon(messageAreaContainer);
-      else if (e.getPropertyName().equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY))
-	resetSelectedValue();
-      else if (e.getPropertyName().equals(JOptionPane.INITIAL_VALUE_PROPERTY)
-               || e.getPropertyName().equals(JOptionPane.OPTIONS_PROPERTY)
-               || e.getPropertyName().equals(JOptionPane.OPTION_TYPE_PROPERTY))
-        {
-	  Container newButtons = createButtonArea();
-	  optionPane.remove(buttonContainer);
-	  optionPane.add(newButtons);
-	  buttonContainer = newButtons;
-        }
-
-      else if (e.getPropertyName().equals(JOptionPane.MESSAGE_PROPERTY)
-               || e.getPropertyName().equals(JOptionPane.WANTS_INPUT_PROPERTY)
-               || e.getPropertyName().equals(JOptionPane.SELECTION_VALUES_PROPERTY))
+      String property = e.getPropertyName();
+      if (property.equals(JOptionPane.ICON_PROPERTY)
+          || property.equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY)
+          || property.equals(JOptionPane.INITIAL_VALUE_PROPERTY)
+          || property.equals(JOptionPane.MESSAGE_PROPERTY)
+          || property.equals(JOptionPane.MESSAGE_TYPE_PROPERTY)
+          || property.equals(JOptionPane.OPTION_TYPE_PROPERTY)
+          || property.equals(JOptionPane.OPTIONS_PROPERTY)
+          || property.equals(JOptionPane.WANTS_INPUT_PROPERTY))
         {
           uninstallComponents();
           installComponents();
           optionPane.validate();
         }
     }
   }
 
   /**
    * The minimum width for JOptionPanes.
    */
   public static final int MinimumWidth = 262;

Reply via email to