FileDocCategorySizeDatePackage
DefaultSwatchChooserPanel.javaAPI DocJava SE 5 API14489Fri Aug 26 14:58:00 BST 2005javax.swing.colorchooser

DefaultSwatchChooserPanel

public 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}.

version
1.26 12/19/03
author
Steve Wilson

Fields Summary
SwatchPanel
swatchPanel
RecentSwatchPanel
recentSwatchPanel
MouseListener
mainSwatchListener
MouseListener
recentSwatchListener
private static String
recentStr
Constructors Summary
public DefaultSwatchChooserPanel()


      
        super();
    
Methods Summary
protected voidbuildChooser()

      
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        JPanel superHolder = new JPanel(gb);

        swatchPanel =  new MainSwatchPanel();
	swatchPanel.getAccessibleContext().setAccessibleName(getDisplayName());

	recentSwatchPanel = new RecentSwatchPanel();
	recentSwatchPanel.getAccessibleContext().setAccessibleName(recentStr);

	mainSwatchListener = new MainSwatchListener();
	swatchPanel.addMouseListener(mainSwatchListener);
	recentSwatchListener = new RecentSwatchListener();
	recentSwatchPanel.addMouseListener(recentSwatchListener);


	Border border = new CompoundBorder( new LineBorder(Color.black),
					    new LineBorder(Color.white) );
	swatchPanel.setBorder(border);
        gbc.weightx = 1.0;
        gbc.gridwidth = 2;
        gbc.gridheight = 2;
        gbc.weighty = 1.0;
        superHolder.add( swatchPanel, gbc );

	recentSwatchPanel.addMouseListener(recentSwatchListener);
	recentSwatchPanel.setBorder(border);
	JPanel recentLabelHolder = new JPanel(new BorderLayout());
	JLabel l = new JLabel(recentStr);
	l.setLabelFor(recentSwatchPanel);
	recentLabelHolder.add(l, BorderLayout.NORTH);
        gbc.weighty = 0.0;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = 1;
	superHolder.add( recentLabelHolder, gbc );
        superHolder.add( recentSwatchPanel, gbc );	

	add(superHolder);
	
    
public java.lang.StringgetDisplayName()

        return UIManager.getString("ColorChooser.swatchesNameText");
    
public intgetDisplayedMnemonicIndex()
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
Character index to render mnemonic for; -1 to provide no visual identifier for this panel.
see
#getMnemonic
since
1.4

        return getInt("ColorChooser.swatchesDisplayedMnemonicIndex", -1);
    
public javax.swing.IcongetLargeDisplayIcon()

        return null;
    
public intgetMnemonic()
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
KeyEvent.VK constant identifying the mnemonic; <= 0 for no mnemonic
see
#getDisplayedMnemonicIndex
since
1.4

        return getInt("ColorChooser.swatchesMnemonic", -1);
    
public javax.swing.IcongetSmallDisplayIcon()

        return null;
    
public voidinstallChooserPanel(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 voiduninstallChooserPanel(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 voidupdateChooser()