DefaultSwatchChooserPanelpublic class DefaultSwatchChooserPanel extends AbstractColorChooserPanel The standard color swatch chooser.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
Fields Summary |
---|
SwatchPanel | swatchPanel | RecentSwatchPanel | recentSwatchPanel | MouseListener | mainSwatchListener | MouseListener | recentSwatchListener | private static String | recentStr |
Constructors Summary |
---|
public DefaultSwatchChooserPanel()
super();
setInheritsPopupMenu(true);
|
Methods Summary |
---|
protected void | buildChooser()
GridBagLayout gb = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
JPanel superHolder = new JPanel(gb);
swatchPanel = new MainSwatchPanel();
swatchPanel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
getDisplayName());
swatchPanel.setInheritsPopupMenu(true);
recentSwatchPanel = new RecentSwatchPanel();
recentSwatchPanel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
recentStr);
mainSwatchListener = new MainSwatchListener();
swatchPanel.addMouseListener(mainSwatchListener);
recentSwatchListener = new RecentSwatchListener();
recentSwatchPanel.addMouseListener(recentSwatchListener);
JPanel mainHolder = new JPanel(new BorderLayout());
Border border = new CompoundBorder( new LineBorder(Color.black),
new LineBorder(Color.white) );
mainHolder.setBorder(border);
mainHolder.add(swatchPanel, BorderLayout.CENTER);
gbc.anchor = GridBagConstraints.LAST_LINE_START;
gbc.gridwidth = 1;
gbc.gridheight = 2;
Insets oldInsets = gbc.insets;
gbc.insets = new Insets(0, 0, 0, 10);
superHolder.add(mainHolder, gbc);
gbc.insets = oldInsets;
recentSwatchPanel.addMouseListener(recentSwatchListener);
recentSwatchPanel.setInheritsPopupMenu(true);
JPanel recentHolder = new JPanel( new BorderLayout() );
recentHolder.setBorder(border);
recentHolder.setInheritsPopupMenu(true);
recentHolder.add(recentSwatchPanel, BorderLayout.CENTER);
JLabel l = new JLabel(recentStr);
l.setLabelFor(recentSwatchPanel);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridheight = 1;
gbc.weighty = 1.0;
superHolder.add(l, gbc);
gbc.weighty = 0;
gbc.gridheight = GridBagConstraints.REMAINDER;
gbc.insets = new Insets(0, 0, 0, 2);
superHolder.add(recentHolder, gbc);
superHolder.setInheritsPopupMenu(true);
add(superHolder);
| public java.lang.String | getDisplayName()
return UIManager.getString("ColorChooser.swatchesNameText");
| public int | getDisplayedMnemonicIndex()Provides a hint to the look and feel as to the index of the character in
getDisplayName that should be visually identified as the
mnemonic. The look and feel should only use this if
getMnemonic returns a value > 0.
The return value here is a hint, it is ultimately up to the look
and feel to honor the return value in some meaningful way. For example,
a look and feel may wish to render each
AbstractColorChooserPanel in a JTabbedPane ,
and further use this return value to underline a character in
the getDisplayName .
This implementation looks up the value from the default
ColorChooser.rgbDisplayedMnemonicIndex , or if it
isn't available (or not an Integer ) returns -1.
The lookup for the default is done through the UIManager :
UIManager.get("ColorChooser.swatchesDisplayedMnemonicIndex"); .
return getInt("ColorChooser.swatchesDisplayedMnemonicIndex", -1);
| public javax.swing.Icon | getLargeDisplayIcon()
return null;
| public int | getMnemonic()Provides a hint to the look and feel as to the
KeyEvent.VK constant that can be used as a mnemonic to
access the panel. A return value <= 0 indicates there is no mnemonic.
The return value here is a hint, it is ultimately up to the look
and feel to honor the return value in some meaningful way.
This implementation looks up the value from the default
ColorChooser.swatchesMnemonic , or if it
isn't available (or not an Integer ) returns -1.
The lookup for the default is done through the UIManager :
UIManager.get("ColorChooser.swatchesMnemonic"); .
return getInt("ColorChooser.swatchesMnemonic", -1);
| public javax.swing.Icon | getSmallDisplayIcon()
return null;
| public void | installChooserPanel(javax.swing.JColorChooser enclosingChooser)The background color, foreground color, and font are already set to the
defaults from the defaults table before this method is called.
super.installChooserPanel(enclosingChooser);
| public void | uninstallChooserPanel(javax.swing.JColorChooser enclosingChooser)
super.uninstallChooserPanel(enclosingChooser);
swatchPanel.removeMouseListener(mainSwatchListener);
recentSwatchPanel.removeMouseListener(recentSwatchListener);
swatchPanel = null;
recentSwatchPanel = null;
mainSwatchListener = null;
recentSwatchListener = null;
removeAll(); // strip out all the sub-components
| public void | updateChooser()
|
|