Package jmri.util.swing
Class JmriColorChooser
- java.lang.Object
-
- jmri.util.swing.JmriColorChooser
-
public class JmriColorChooser extends java.lang.Object
Display the Java color chooser that includes a custom JMRI panel. The custom panel is provided byJmriColorChooserPanel
.Maintain a list of recently used colors. This includes colors found during loading and subsequent changes.
- Since:
- 4.13.1
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.awt.Color
color
The number of tabs in the color chooser, 5 standard plus the custom JMRI tab
-
Constructor Summary
Constructors Constructor Description JmriColorChooser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addRecentColor(java.awt.Color color)
Add a new color to the recent list.static javax.swing.JColorChooser
extendColorChooser(javax.swing.JColorChooser chooser)
Add or replace the JMRI custom panel at the beginning of the chooser tabsstatic java.util.ArrayList<java.awt.Color>
getRecentColors()
Provide a copy of the recent color list.static java.awt.Color
showDialog(java.awt.Component comp, java.lang.String dialogTitle, java.awt.Color currentColor)
Display the customized color selection dialog.static void
suppressAddRecentColor(boolean set)
Suppress adding colors while temporarily displaying colors to wysiwyg applications of JmriColorChooser - e.g. use of RGB tab while editing colors on CPE panels.
-
-
-
Field Detail
-
color
static java.awt.Color color
The number of tabs in the color chooser, 5 standard plus the custom JMRI tab
-
-
Constructor Detail
-
JmriColorChooser
public JmriColorChooser()
-
-
Method Detail
-
addRecentColor
public static void addRecentColor(java.awt.Color color)
Add a new color to the recent list. Null values and duplicates are not added.- Parameters:
color
- The color object to be added.
-
suppressAddRecentColor
public static void suppressAddRecentColor(boolean set)
Suppress adding colors while temporarily displaying colors to wysiwyg applications of JmriColorChooser - e.g. use of RGB tab while editing colors on CPE panels.- Parameters:
set
- if true, previewed color is not added.
-
getRecentColors
public static java.util.ArrayList<java.awt.Color> getRecentColors()
Provide a copy of the recent color list. This is used byJmriColorChooserPanel
to build the recent color list.- Returns:
- the recent color list.
-
showDialog
public static java.awt.Color showDialog(java.awt.Component comp, java.lang.String dialogTitle, java.awt.Color currentColor)
Display the customized color selection dialog. The JMRI custom panel is added before the Java supplied panels so that it will be the default panel.- Parameters:
comp
- The calling component. It is not used but provided to simplify migration.dialogTitle
- The title at the top of the dialog.currentColor
- The color that will be set as the starting value for the dialog.- Returns:
- the selected color for a OK response, the orignal color for a Cancel response.
-
extendColorChooser
public static javax.swing.JColorChooser extendColorChooser(javax.swing.JColorChooser chooser)
Add or replace the JMRI custom panel at the beginning of the chooser tabs- Parameters:
chooser
- The chooser object to be updated.- Returns:
- the updated chooser object
-
-