X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTextColourChooser.java;fp=src%2Fjalview%2Fgui%2FTextColourChooser.java;h=5d22abb82fc441d362d1d7322f858617b857dabb;hb=ec8f3cedf60fb1feed6d34de6b49f6bfa78b9dd8;hp=53e2deef647887ac138a8bda1fcd58d5d2c0de9b;hpb=056dad85a910551cc95e44d451a61f6b8c4dd35d;p=jalview.git diff --git a/src/jalview/gui/TextColourChooser.java b/src/jalview/gui/TextColourChooser.java index 53e2dee..5d22abb 100644 --- a/src/jalview/gui/TextColourChooser.java +++ b/src/jalview/gui/TextColourChooser.java @@ -21,6 +21,7 @@ package jalview.gui; import jalview.datamodel.SequenceGroup; +import jalview.gui.JalviewColourChooser.ColourChooserListener; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -32,7 +33,6 @@ import java.util.HashMap; import java.util.Map; import javax.swing.BorderFactory; -import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; @@ -84,7 +84,7 @@ public class TextColourChooser col2.setToolTipText(MessageManager.getString("label.light_colour")); col2.setBackground(original2); final JPanel bigpanel = new JPanel(new BorderLayout()); - JPanel panel = new JPanel(); + JPanel panel = new JPanel(new BorderLayout()); bigpanel.add(panel, BorderLayout.CENTER); bigpanel.add( new JLabel("" @@ -92,23 +92,27 @@ public class TextColourChooser "label.select_dark_light_set_threshold") + ""), BorderLayout.NORTH); - panel.add(col1); - panel.add(slider); - panel.add(col2); + panel.add(col1, BorderLayout.WEST); + panel.add(slider, BorderLayout.CENTER); + panel.add(col2, BorderLayout.EAST); col1.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - Color col = JColorChooser.showDialog(bigpanel, - MessageManager.getString("label.select_colour_for_text"), - col1.getBackground()); - if (col != null) + String ttl = MessageManager.getString("label.select_colour_for_text"); + ColourChooserListener listener = new ColourChooserListener() { - colour1Changed(col); - col1.setBackground(col); - } + @Override + public void colourSelected(Color c) + { + colour1Changed(c); + col1.setBackground(c); + } + }; + JalviewColourChooser.showColourChooser(bigpanel, ttl, + col1.getBackground(), listener); } }); @@ -117,14 +121,18 @@ public class TextColourChooser @Override public void mousePressed(MouseEvent e) { - Color col = JColorChooser.showDialog(bigpanel, - MessageManager.getString("label.select_colour_for_text"), - col2.getBackground()); - if (col != null) + String ttl = MessageManager.getString("label.select_colour_for_text"); + ColourChooserListener listener = new ColourChooserListener() { - colour2Changed(col); - col2.setBackground(col); - } + @Override + public void colourSelected(Color c) + { + colour2Changed(c); + col2.setBackground(c); + } + }; + JalviewColourChooser.showColourChooser(bigpanel, ttl, + col2.getBackground(), listener); } }); @@ -137,16 +145,23 @@ public class TextColourChooser } }); - int reply = JvOptionPane.showInternalOptionDialog(alignPanel, bigpanel, - MessageManager.getString( - "label.adjunst_foreground_text_colour_threshold"), - JvOptionPane.OK_CANCEL_OPTION, JvOptionPane.QUESTION_MESSAGE, - null, null, null); - - if (reply == JvOptionPane.CANCEL_OPTION) + Object[] options = new Object[] { MessageManager.getString("action.ok"), + MessageManager.getString("action.cancel") }; + String title = MessageManager + .getString("label.adjust_foreground_text_colour_threshold"); + Runnable action = new Runnable() // response for 1 = Cancel { - restoreInitialSettings(); - } + @Override + public void run() + { + restoreInitialSettings(); + } + }; + JvOptionPane.newOptionDialog(alignPanel).setResponseHandler(1, action) + .showInternalDialog(bigpanel, title, + JvOptionPane.YES_NO_CANCEL_OPTION, + JvOptionPane.PLAIN_MESSAGE, null, options, + MessageManager.getString("action.ok")); } /** @@ -177,6 +192,8 @@ public class TextColourChooser group.textColour2 = groupColour2.get(group); group.thresholdTextColour = groupThreshold.get(group); } + + ap.paintAlignment(false, false); } /**