public void putValue(String key, Object newValue) {
   super.putValue(key, newValue);
   if (key == Actions.SELECTED_KEY) {
     if (palette != null) {
       AbstractOSXApplication application = getApplication();
       boolean b = (Boolean) newValue;
       if (b) {
         application.addPalette(palette);
         palette.setVisible(true);
       } else {
         application.removePalette(palette);
         palette.setVisible(false);
       }
     }
   }
 }
  public void setPalette(Window newValue) {
    AbstractOSXApplication application = getApplication();
    if (palette != null) {
      palette.removeWindowListener(windowHandler);
    }

    palette = newValue;

    if (palette != null) {
      palette.addWindowListener(windowHandler);
      if (getValue(Actions.SELECTED_KEY) == Boolean.TRUE) {
        application.addPalette(palette);
        palette.setVisible(true);
      } else {
        application.removePalette(palette);
        palette.setVisible(false);
      }
    }
  }
 public void actionPerformed(ActionEvent e) {
   if (palette != null) {
     putValue(Actions.SELECTED_KEY, !palette.isVisible());
   }
 }