optionPane.removeAll(); messageAreaContainer = createMessageArea(); optionPane.add(messageAreaContainer); optionPane.add(buttonContainer);
optionPane.remove(messageAreaContainer); messageAreaContainer = createMessageArea(); optionPane.add(messageAreaContainer); Container newButtons = createButtonArea(); optionPane.remove(buttonContainer); optionPane.add(newButtons); buttonContainer = newButtons; optionPane.add(buttonContainer);
    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))        {	  optionPane.removeAll();	  messageAreaContainer = createMessageArea();	  optionPane.add(messageAreaContainer);	  optionPane.add(buttonContainer);        }      optionPane.invalidate();      optionPane.repaint();    }