Chapter 25. The javax.swing.colorchooser PackageThe classes and interfaces of the javax.swing.colorchooser package support the JColorChooser component of the javax.swing package and allow customization of that component. Figure 25-1 shows the class hierarchy of this package. Figure 25-1. The javax.swing.colorchooser package
This abstract subclass of JPanel provides the basic framework for creating new color selection panels for the JColorChooser component. The default color selection panels provided by the JColorChooser are adequate for most applications. If you want to add a custom panel, you must subclass this class and provide implementations for the abstract methods. The buildChooser() method should create the GUI components that your color selection panel uses. getDisplayName(), getLargeDisplayIcon(), and getSmallDisplayIcon() should return a name and icons for your custom panel, respectively. These are displayed in the JTabbedPane tab for your color selection panel. The most important task for your AbstractColorChooserPanel, however, is communicating with the ColorSelectionModel object of the JColorChooser. Call the getColorSelectionModel() method to obtain the model. When the user selects a color in your panel, you must change the selected color in the model, so that the JColorChooser knows of your selection. Conversely, if the user selects a color in some other panel, the abstract updateChooser() method is called to notify your panel of the change. Your panel should update itself to reflect the new color selection.
Hierarchy: Object-->Component(java.awt.image.ImageObserver,java.awt.MenuContainer,Serializable)-->Container-->JComponent(Serializable)-->JPanel(Accessible)-->AbstractColorChooserPanel Passed To: JColorChooser.{addChooserPanel(), removeChooserPanel(), setChooserPanels()} Returned By: JColorChooser.{getChooserPanels(), removeChooserPanel()}, ColorChooserComponentFactory.getDefaultChooserPanels()
This class consists of static methods that return the individual color selection and color preview components that are used to create a default JColorChooser component. This class is used by the JColorChooser UI delegate object and normally is not used by applications. However, you may find it useful if you want to arrange standard color chooser components in a custom custom dialog box of your own.
This interface defines the methods that must be implemented by an object that wants to keep track of a selected color for a JColorChooser. The interface is a simple one, consisting only of a pair of property accessor methods for the selected color and a pair of event registration methods for listeners that are interested in knowing when the selection changes. DefaultColorSelectionModel provides a simple implementation of this interface.
Implementations: DefaultColorSelectionModel Passed To: JColorChooser.{JColorChooser(), setSelectionModel()} Returned By: JColorChooser.getSelectionModel(), AbstractColorChooserPanel.getColorSelectionModel()
This class is a simple default implementation of the ColorSelectionModel interface.
Hierarchy: Object-->DefaultColorSelectionModel(ColorSelectionModel,Serializable) Copyright © 2001 O'Reilly & Associates. All rights reserved. |
|