X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FJalviewColourChooser.java;h=2a6c2c5d8b7934e9a3edb45970e3f39ef4fa4869;hb=1f41372a2bda3efcc27abaed092495548135b6b4;hp=e0c4eeb54b31c963bf722edc57c7ad0fbe08b902;hpb=217274a8e9ea2ae20d5a6d21989b8b16840ca6f0;p=jalview.git diff --git a/src/jalview/gui/JalviewColourChooser.java b/src/jalview/gui/JalviewColourChooser.java index e0c4eeb..2a6c2c5 100644 --- a/src/jalview/gui/JalviewColourChooser.java +++ b/src/jalview/gui/JalviewColourChooser.java @@ -1,16 +1,32 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.gui; -import jalview.gui.JalviewColourChooser.ColourChooserListener; - import java.awt.Color; import java.awt.Component; -import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JColorChooser; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JPanel; /** * A helper class that shows a JColorChooser and passes the selected colour back @@ -21,6 +37,10 @@ public class JalviewColourChooser public interface ColourChooserListener { void colourSelected(Color c); + + default void cancel() + { + }; } /** @@ -41,16 +61,11 @@ public class JalviewColourChooser { colorChooser.setColor(initialColour); } - ActionListener al = new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - listener.colourSelected(colorChooser.getColor()); - }; - }; + ActionListener onChoose = evt -> listener + .colourSelected(colorChooser.getColor()); + ActionListener onCancel = evt -> listener.cancel(); JDialog dialog = JColorChooser.createDialog(parent, title, true, - colorChooser, al, null); + colorChooser, onChoose, onCancel); dialog.setVisible(true); }