- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- javax.swing.colorchooser.AbstractColorChooserPanel
-
- All Implemented Interfaces:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
public abstract class AbstractColorChooserPanel extends JPanel
这是颜色选择器的抽象超类。 如果你想添加一个新的颜色选择器面板到一个JColorChooser
,亚类这个类。警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,对于所有JavaBeans的长期存储的支持已被添加到
java.beans
包中。 请参阅XMLEncoder
。- 另请参见:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
-
Field Summary
Fields Modifier and Type Field 描述 static String
TRANSPARENCY_ENABLED_PROPERTY
标识可以选择颜色的透明度(alpha值)-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
构造方法摘要
构造方法 Constructor 描述 AbstractColorChooserPanel()
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 protected abstract void
buildChooser()
建立一个新的选择面板。protected Color
getColorFromModel()
返回当前选择的颜色。ColorSelectionModel
getColorSelectionModel()
返回选择器面板正在编辑的模型。int
getDisplayedMnemonicIndex()
提供一个关于getDisplayName
中视觉识别为助记符的字符索引的外观和感觉的提示。abstract String
getDisplayName()
返回一个包含面板显示名称的字符串。abstract Icon
getLargeDisplayIcon()
返回面板的大显示图标。int
getMnemonic()
提供一个关于KeyEvent.VK
常数的外观和感觉的提示,可以用作助记符来访问面板。abstract Icon
getSmallDisplayIcon()
返回面板的小显示图标。void
installChooserPanel(JColorChooser enclosingChooser)
当面板添加到选择器时调用。boolean
isColorTransparencySelectionEnabled()
获取颜色选择器面板是否允许选择颜色的透明度(alpha值)。void
paint(Graphics g)
画面板。void
setColorTransparencySelectionEnabled(boolean b)
设置颜色选择器面板是否允许选择颜色的透明度(alpha值)。void
uninstallChooserPanel(JColorChooser enclosingChooser)
当面板从选择器中移除时调用。abstract void
updateChooser()
模型状态更改时自动调用。-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
-
-
-
字段详细信息
-
TRANSPARENCY_ENABLED_PROPERTY
public static final String TRANSPARENCY_ENABLED_PROPERTY
标识可以选择颜色的透明度(alpha值)- 另请参见:
- Constant Field Values
-
-
方法详细信息
-
updateChooser
public abstract void updateChooser()
模型状态更改时自动调用。 它也被称为installChooserPanel
,允许您设置您的选择器的初始状态。 覆盖此方法来更新您的ChooserPanel
。
-
buildChooser
protected abstract void buildChooser()
建立一个新的选择面板。
-
getDisplayName
public abstract String getDisplayName()
返回一个包含面板显示名称的字符串。- 结果
- 显示面板的名称
-
getMnemonic
public int getMnemonic()
提供关于KeyEvent.VK
常数的外观和感觉的提示,可以用作助记符来访问面板。 返回值<= 0表示没有助记符。这里的回报值是一个提示,它最终取决于以某种有意义的方式兑现回报价值的外观和感觉。
此实现返回0,表示
AbstractColorChooserPanel
不支持助记符,希望助记符的子类将需要覆盖此。- 结果
- KeyEvent.VK常数识别助记符; <= 0,没有助记符
- 从以下版本开始:
- 1.4
- 另请参见:
-
getDisplayedMnemonicIndex()
-
getDisplayedMnemonicIndex
public int getDisplayedMnemonicIndex()
提供关于getDisplayName
中视觉识别为助记符的字符索引的外观和感觉的提示。 只要getMnemonic
返回值> 0,外观和感觉就应该使用。这里的回报值是一个提示,它最终取决于以某种有意义的方式兑现回报价值的外观和感觉。 例如,外观可能希望将
AbstractColorChooserPanel
呈现在JTabbedPane
,并进一步使用此返回值来标注getDisplayName
中的getDisplayName
。此实现返回-1,表示
AbstractColorChooserPanel
不支持助记符,希望助记符的子类将需要覆盖此。- 结果
- 提供助记符的字符索引 -1,不提供此面板的视觉标识符。
- 从以下版本开始:
- 1.4
- 另请参见:
-
getMnemonic()
-
getSmallDisplayIcon
public abstract Icon getSmallDisplayIcon()
返回面板的小显示图标。- 结果
- 小显示图标
-
getLargeDisplayIcon
public abstract Icon getLargeDisplayIcon()
返回面板的大显示图标。- 结果
- 大显示图标
-
installChooserPanel
public void installChooserPanel(JColorChooser enclosingChooser)
当面板添加到选择器时调用。 如果您覆盖此,请务必致电super
。- 参数
-
enclosingChooser
- 要添加面板的选择器 - 异常
-
RuntimeException
- 如果选择器面板已经安装
-
uninstallChooserPanel
public void uninstallChooserPanel(JColorChooser enclosingChooser)
当面板从选择器中移除时调用。 如果覆盖此,请务必致电super
。- 参数
-
enclosingChooser
- 要从中删除面板的选择器
-
getColorSelectionModel
public ColorSelectionModel getColorSelectionModel()
返回选择器面板正在编辑的模型。- 结果
-
该面板正在编辑的
ColorSelectionModel
型号
-
getColorFromModel
protected Color getColorFromModel()
返回当前选择的颜色。- 结果
-
选择的是
Color
-
setColorTransparencySelectionEnabled
@BeanProperty(description="Sets the transparency of a color selection on or off.") public void setColorTransparencySelectionEnabled(boolean b)
设置颜色选择器面板是否允许选择颜色的透明度(alpha值)。 此方法触发属性更改事件,使用字符串值TRANSPARENCY_ENABLED_PROPERTY
作为属性的名称。该值是一个提示,可能不适用于所有类型的选择面板。
默认值为
true
。- 参数
-
b
- 如果可以选择颜色的透明度,b
true - 另请参见:
-
isColorTransparencySelectionEnabled()
-
isColorTransparencySelectionEnabled
public boolean isColorTransparencySelectionEnabled()
获取颜色选择器面板是否允许选择颜色的透明度(alpha值)。- 结果
- 如果可以选择颜色的透明度,则为true
- 另请参见:
-
setColorTransparencySelectionEnabled(boolean)
-
paint
public void paint(Graphics g)
画面板。
-
-