29 import javax.swing.border.*; 30 import javax.swing.event.*; 31 import java.awt.*; 32 import java.awt.image.*; 33 import java.awt.event.*; 34 import java.beans.PropertyChangeEvent; 35 import java.beans.PropertyChangeListener; 36 import java.io.Serializable; 37 import javax.accessibility.*; 38 39 40 /** 41 * The standard color swatch chooser. 42 * <p> 43 * <strong>Warning:</strong> 44 * Serialized objects of this class will not be compatible with 45 * future Swing releases. The current serialization support is 46 * appropriate for short term storage or RMI between applications running 47 * the same version of Swing. As of 1.4, support for long term storage 48 * of all JavaBeans™ 49 * has been added to the <code>java.beans</code> package. 50 * Please see {@link java.beans.XMLEncoder}. 51 * 52 * @author Steve Wilson 53 */ 54 @SuppressWarnings("serial") // Same-version serialization only 55 class DefaultSwatchChooserPanel extends AbstractColorChooserPanel { 56 57 SwatchPanel swatchPanel; 58 RecentSwatchPanel recentSwatchPanel; 59 MouseListener mainSwatchListener; 60 MouseListener recentSwatchListener; 61 private KeyListener mainSwatchKeyListener; 62 private KeyListener recentSwatchKeyListener; 63 64 public DefaultSwatchChooserPanel() { 65 super(); 66 setInheritsPopupMenu(true); 67 } 68 69 public String getDisplayName() { 70 return UIManager.getString("ColorChooser.swatchesNameText", getLocale()); 71 } 72 73 /** 74 * Provides a hint to the look and feel as to the 75 * <code>KeyEvent.VK</code> constant that can be used as a mnemonic to 76 * access the panel. A return value <= 0 indicates there is no mnemonic. 77 * <p> 78 * The return value here is a hint, it is ultimately up to the look 79 * and feel to honor the return value in some meaningful way. 80 * <p> 81 * This implementation looks up the value from the default 82 * <code>ColorChooser.swatchesMnemonic</code>, or if it 83 * isn't available (or not an <code>Integer</code>) returns -1. 84 * The lookup for the default is done through the <code>UIManager</code>: 85 * <code>UIManager.get("ColorChooser.swatchesMnemonic");</code>. 86 * 87 * @return KeyEvent.VK constant identifying the mnemonic; <= 0 for no 88 * mnemonic 89 * @see #getDisplayedMnemonicIndex 90 * @since 1.4 91 */ 92 public int getMnemonic() { 93 return getInt("ColorChooser.swatchesMnemonic", -1); 94 } 95 96 /** 97 * Provides a hint to the look and feel as to the index of the character in 98 * <code>getDisplayName</code> that should be visually identified as the 99 * mnemonic. The look and feel should only use this if 100 * <code>getMnemonic</code> returns a value > 0. 101 * <p> 102 * The return value here is a hint, it is ultimately up to the look 103 * and feel to honor the return value in some meaningful way. For example, 104 * a look and feel may wish to render each 105 * <code>AbstractColorChooserPanel</code> in a <code>JTabbedPane</code>, 106 * and further use this return value to underline a character in 107 * the <code>getDisplayName</code>. 108 * <p> 109 * This implementation looks up the value from the default 110 * <code>ColorChooser.rgbDisplayedMnemonicIndex</code>, or if it 111 * isn't available (or not an <code>Integer</code>) returns -1. 112 * The lookup for the default is done through the <code>UIManager</code>: 113 * <code>UIManager.get("ColorChooser.swatchesDisplayedMnemonicIndex");</code>. 114 * 115 * @return Character index to render mnemonic for; -1 to provide no 116 * visual identifier for this panel. 117 * @see #getMnemonic 118 * @since 1.4 119 */ 120 public int getDisplayedMnemonicIndex() { 121 return getInt("ColorChooser.swatchesDisplayedMnemonicIndex", -1); 122 } 123 124 public Icon getSmallDisplayIcon() { 125 return null; 126 } 127 128 public Icon getLargeDisplayIcon() { 129 return null; 130 } 131 132 /** 133 * The background color, foreground color, and font are already set to the | 29 import javax.swing.border.*; 30 import javax.swing.event.*; 31 import java.awt.*; 32 import java.awt.image.*; 33 import java.awt.event.*; 34 import java.beans.PropertyChangeEvent; 35 import java.beans.PropertyChangeListener; 36 import java.io.Serializable; 37 import javax.accessibility.*; 38 39 40 /** 41 * The standard color swatch chooser. 42 * <p> 43 * <strong>Warning:</strong> 44 * Serialized objects of this class will not be compatible with 45 * future Swing releases. The current serialization support is 46 * appropriate for short term storage or RMI between applications running 47 * the same version of Swing. As of 1.4, support for long term storage 48 * of all JavaBeans™ 49 * has been added to the {@code java.beans} package. 50 * Please see {@link java.beans.XMLEncoder}. 51 * 52 * @author Steve Wilson 53 */ 54 @SuppressWarnings("serial") // Same-version serialization only 55 class DefaultSwatchChooserPanel extends AbstractColorChooserPanel { 56 57 SwatchPanel swatchPanel; 58 RecentSwatchPanel recentSwatchPanel; 59 MouseListener mainSwatchListener; 60 MouseListener recentSwatchListener; 61 private KeyListener mainSwatchKeyListener; 62 private KeyListener recentSwatchKeyListener; 63 64 public DefaultSwatchChooserPanel() { 65 super(); 66 setInheritsPopupMenu(true); 67 } 68 69 public String getDisplayName() { 70 return UIManager.getString("ColorChooser.swatchesNameText", getLocale()); 71 } 72 73 /** 74 * Provides a hint to the look and feel as to the 75 * {@code KeyEvent.VK} constant that can be used as a mnemonic to 76 * access the panel. A return value <= 0 indicates there is no mnemonic. 77 * <p> 78 * The return value here is a hint, it is ultimately up to the look 79 * and feel to honor the return value in some meaningful way. 80 * <p> 81 * This implementation looks up the value from the default 82 * {@code ColorChooser.swatchesMnemonic}, or if it 83 * isn't available (or not an {@code Integer}) returns -1. 84 * The lookup for the default is done through the {@code UIManager}: 85 * {@code UIManager.get("ColorChooser.swatchesMnemonic");}. 86 * 87 * @return KeyEvent.VK constant identifying the mnemonic; <= 0 for no 88 * mnemonic 89 * @see #getDisplayedMnemonicIndex 90 * @since 1.4 91 */ 92 public int getMnemonic() { 93 return getInt("ColorChooser.swatchesMnemonic", -1); 94 } 95 96 /** 97 * Provides a hint to the look and feel as to the index of the character in 98 * {@code getDisplayName} that should be visually identified as the 99 * mnemonic. The look and feel should only use this if 100 * {@code getMnemonic} returns a value > 0. 101 * <p> 102 * The return value here is a hint, it is ultimately up to the look 103 * and feel to honor the return value in some meaningful way. For example, 104 * a look and feel may wish to render each 105 * {@code AbstractColorChooserPanel} in a {@code JTabbedPane}, 106 * and further use this return value to underline a character in 107 * the {@code getDisplayName}. 108 * <p> 109 * This implementation looks up the value from the default 110 * {@code ColorChooser.rgbDisplayedMnemonicIndex}, or if it 111 * isn't available (or not an {@code Integer}) returns -1. 112 * The lookup for the default is done through the {@code UIManager}: 113 * {@code UIManager.get("ColorChooser.swatchesDisplayedMnemonicIndex");}. 114 * 115 * @return Character index to render mnemonic for; -1 to provide no 116 * visual identifier for this panel. 117 * @see #getMnemonic 118 * @since 1.4 119 */ 120 public int getDisplayedMnemonicIndex() { 121 return getInt("ColorChooser.swatchesDisplayedMnemonicIndex", -1); 122 } 123 124 public Icon getSmallDisplayIcon() { 125 return null; 126 } 127 128 public Icon getLargeDisplayIcon() { 129 return null; 130 } 131 132 /** 133 * The background color, foreground color, and font are already set to the |