JAL-3032 JAL-3048 adjust how colour chooser is shown
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 4 Jul 2018 14:44:56 +0000 (15:44 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 4 Jul 2018 14:44:56 +0000 (15:44 +0100)
src/jalview/gui/AnnotationPanel.java

index dee56b0..bf8c709 100755 (executable)
@@ -58,6 +58,7 @@ import java.util.Collections;
 import java.util.List;
 
 import javax.swing.JColorChooser;
+import javax.swing.JDialog;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
@@ -339,24 +340,29 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     }
     else if (action.equals(COLOUR))
     {
-      Color col = JColorChooser.showDialog(this,
-              MessageManager.getString("label.select_foreground_colour"),
-              Color.black);
-
-      for (int index : av.getColumnSelection().getSelected())
-      {
-        if (!av.getAlignment().getHiddenColumns().isVisible(index))
+      final Annotation[] fAnot = anot;
+      JColorChooser colorChooser = new JColorChooser();
+      colorChooser.setColor(Color.black);
+      String title = MessageManager.getString("label.select_foreground_colour");
+      ActionListener listener = new ActionListener() {
+        @Override
+        public void actionPerformed(ActionEvent e)
         {
-          continue;
-        }
-
-        if (anot[index] == null)
-        {
-          anot[index] = new Annotation("", "", ' ', 0);
-        }
-
-        anot[index].colour = col;
-      }
+          HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns();
+          for (int index : av.getColumnSelection().getSelected())
+          {
+            if (hiddenColumns.isVisible(index))
+            {
+              if (fAnot[index] == null)
+              {
+                fAnot[index] = new Annotation("", "", ' ', 0);
+              }
+              fAnot[index].colour = colorChooser.getColor();
+            }
+        }};
+      };
+      JDialog dialog = JColorChooser.createDialog(this, title, true, colorChooser, listener, null);
+      dialog.setVisible(true);
     }
     else
     // HELIX, SHEET or STEM