git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
41c7bc4
)
JAL-3032 revised colour picker, now with ActionListener
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 3 Jul 2018 14:59:01 +0000
(15:59 +0100)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 3 Jul 2018 14:59:01 +0000
(15:59 +0100)
src/jalview/gui/FeatureTypeSettings.java
patch
|
blob
|
history
diff --git
a/src/jalview/gui/FeatureTypeSettings.java
b/src/jalview/gui/FeatureTypeSettings.java
index
b973708
..
0f997bf
100644
(file)
--- a/
src/jalview/gui/FeatureTypeSettings.java
+++ b/
src/jalview/gui/FeatureTypeSettings.java
@@
-58,6
+58,7
@@
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
+import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@
-833,17
+834,38
@@
public class FeatureTypeSettings extends JalviewDialog
return colourByPanel;
}
return colourByPanel;
}
- private void showColourChooser(JPanel colourPanel, String key)
+ /**
+ * Shows a colour chooser dialog, and if a selection is made, updates the
+ * colour of the given panel
+ *
+ * @param colourPanel
+ * the panel whose background colour is being picked
+ * @param key
+ * message bundle key for the dialog title
+ */
+ private void showColourChooser(final JPanel colourPanel, String key)
{
{
- Color col = JColorChooser.showDialog(this,
- MessageManager.getString(key), colourPanel.getBackground());
- if (col != null)
+ // TODO 'final' is (currently) required here for SwingJS to work
+ final JColorChooser colorChooser = new JColorChooser();
+ colorChooser.setColor(colourPanel.getBackground());
+
+ ActionListener listener = new ActionListener()
{
{
- colourPanel.setBackground(col);
- colourPanel.setForeground(col);
- }
- colourPanel.repaint();
- colourChanged(true);
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Color col = colorChooser.getColor();
+ colourPanel.setBackground(col);
+ colourPanel.setForeground(col);
+ colourPanel.repaint();
+ colourChanged(true);
+ }
+ };
+
+ JDialog dialog = JColorChooser.createDialog(this,
+ MessageManager.getString(key), true, colorChooser, listener,
+ null);
+ dialog.setVisible(true);
}
/**
}
/**