java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
javax.swing.colorchooser.AbstractColorChooserPanel
- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
这是颜色选择器的抽象超类。如果要将新的颜色选择器面板添加到
JColorChooser
中,请对此类进行子类化。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4版本开始,已将所有JavaBeans的长期存储支持添加到java.beans
包中。请参阅XMLEncoder
。
-
Nested Class Summary
Nested classes/interfaces declared in class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields declared in class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields declared in class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
构建一个新的选择器面板。protected Color
返回当前选择的颜色。返回选择器面板正在编辑的模型。int
向外观提供一个提示,指示在getDisplayName
中的字符索引应该在视觉上被识别为助记键。abstract String
返回包含面板显示名称的字符串。abstract Icon
返回面板的大显示图标。int
向外观提供一个提示,指示可以用作访问面板的助记键的KeyEvent.VK
常量。abstract Icon
返回面板的小显示图标。void
installChooserPanel
(JColorChooser enclosingChooser) 当面板添加到选择器时调用。boolean
获取颜色选择器面板是否允许选择颜色的透明度(alpha值)。void
绘制面板。void
setColorTransparencySelectionEnabled
(boolean b) 设置颜色选择器面板是否允许选择颜色的透明度(alpha值)。void
uninstallChooserPanel
(JColorChooser enclosingChooser) 当面板从选择器中移除时调用。abstract void
当模型状态发生变化时自动调用。Methods declared in class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods declared in class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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 declared in 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 declared in 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, 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
-
Field Details
-
TRANSPARENCY_ENABLED_PROPERTY
标识颜色的透明度(alpha值)可以被选择- 参见:
-
-
Constructor Details
-
AbstractColorChooserPanel
protected AbstractColorChooserPanel()子类调用的构造函数。
-
-
Method Details
-
updateChooser
public abstract void updateChooser()当模型状态发生变化时自动调用。它也被installChooserPanel
调用,以允许您设置选择器的初始状态。重写此方法以更新您的ChooserPanel
。 -
buildChooser
protected abstract void buildChooser()构建一个新的选择器面板。 -
getDisplayName
返回包含面板显示名称的字符串。- 返回:
- 显示面板的名称
-
getMnemonic
public int getMnemonic()向外观提供一个提示,指示可以用作访问面板的助记键的KeyEvent.VK
常量。返回值<= 0表示没有助记键。这里的返回值是一个提示,最终取决于外观如何以有意义的方式尊重返回值。
此实现返回0,表示
AbstractColorChooserPanel
不支持助记键,希望使用助记键的子类需要覆盖此方法。- 返回:
- 用于标识助记键的KeyEvent.VK常量;<= 0表示没有助记键
- 自1.4版本起:
- 1.4
- 参见:
-
getDisplayedMnemonicIndex
public int getDisplayedMnemonicIndex()向外观提供一个提示,指示在getDisplayName
中的字符索引应该在视觉上被识别为助记键。只有在getMnemonic
返回值> 0时,外观才应该使用此功能。这里的返回值是一个提示,最终取决于外观如何以有意义的方式尊重返回值。例如,外观可能希望在
getDisplayName
中的每个AbstractColorChooserPanel
中呈现一个JTabbedPane
,并进一步使用此返回值来在getDisplayName
中的字符下划线。此实现返回-1,表示
AbstractColorChooserPanel
不支持助记键,希望使用助记键的子类需要覆盖此方法。- 返回:
- 用于呈现助记键的字符索引;-1表示不为此面板提供任何视觉标识符。
- 自1.4版本起:
- 1.4
- 参见:
-
getSmallDisplayIcon
返回面板的小显示图标。- 返回:
- 小显示图标
-
getLargeDisplayIcon
返回面板的大显示图标。- 返回:
- 大显示图标
-
installChooserPanel
当面板添加到选择器时调用。如果要重写此方法,请确保调用super
。- 参数:
-
enclosingChooser
- 要将面板添加到的选择器 - 抛出:
-
RuntimeException
- 如果选择器面板已经安装
-
uninstallChooserPanel
当面板从选择器中移除时调用。如果要重写此方法,请确保调用super
。- 参数:
-
enclosingChooser
- 要从中移除面板的选择器
-
getColorSelectionModel
返回选择器面板正在编辑的模型。- 返回:
-
此面板正在编辑的
ColorSelectionModel
模型
-
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
- 如果可以选择颜色的透明度 - 参见:
-
isColorTransparencySelectionEnabled
public boolean isColorTransparencySelectionEnabled()获取颜色选择器面板是否允许选择颜色的透明度(alpha值)。- 返回:
- 如果可以选择颜色的透明度,则为true
- 参见:
-
paint
绘制面板。- 覆盖:
-
paint
在类JComponent
中 - 参数:
-
g
-Graphics
对象 - 参见:
-