public class SynthComboBoxUI extends BasicComboBoxUI implements PropertyChangeListener, SynthUI
JComboBox提供Synth L&F UI代表。
BasicComboBoxUI.ComboBoxLayoutManager, BasicComboBoxUI.FocusHandler, BasicComboBoxUI.ItemHandler, BasicComboBoxUI.KeyHandler, BasicComboBoxUI.ListDataHandler, BasicComboBoxUI.PropertyChangeHandlerarrowButton, cachedMinimumSize, comboBox, currentValuePane, editor, focusListener, hasFocus, isMinimumSizeDirty, itemListener, keyListener, listBox, listDataListener, padding, popup, popupKeyListener, popupMouseListener, popupMouseMotionListener, propertyChangeListener, squareButtonDEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED| Constructor and Description |
|---|
SynthComboBoxUI() |
| Modifier and Type | Method and Description |
|---|---|
protected JButton |
createArrowButton()
创建一个按钮,该按钮将用作控件来显示或隐藏组合框的弹出窗口部分。
|
protected ComboBoxEditor |
createEditor()
创建将在可编辑组合框中使用的默认编辑器。
|
protected ComboPopup |
createPopup()
创建组合框的弹出窗口部分。
|
protected ListCellRenderer |
createRenderer()
创建将在不可编辑的组合框中使用的默认渲染器。
|
static ComponentUI |
createUI(JComponent c)
为给定的组件创建一个新的UI对象。
|
SynthContext |
getContext(JComponent c)
返回指定组件的上下文。
|
protected Dimension |
getDefaultSize()
使用当前渲染器和字体返回组合框的空显示区域的默认大小。
|
protected void |
installDefaults()
将默认颜色,默认字体,默认渲染器和默认编辑器安装到JComboBox中。
|
protected void |
installListeners()
为组合框及其模型创建并安装侦听器。
|
void |
installUI(JComponent c)
适当地配置指定的组件的外观和感觉。
|
void |
paint(Graphics g, JComponent c)
根据外观和外观绘制指定的组件。
|
protected void |
paint(SynthContext context, Graphics g)
绘制指定的组件。
|
void |
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
画边框
|
void |
paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
绘制当前选定的项目。
|
void |
propertyChange(PropertyChangeEvent e)
当绑定属性更改时,此方法将被调用。
|
protected void |
uninstallDefaults()
从组合框中卸载默认颜色,默认字体,默认渲染器和默认编辑器。
|
protected void |
uninstallListeners()
从组合框及其模型中删除已安装的监听器。
|
void |
uninstallUI(JComponent c)
在installUI中反转在
installUI上完成的
installUI 。
|
void |
update(Graphics g, JComponent c)
通知此UI代理重新绘制指定的组件。
|
addEditor, configureArrowButton, configureEditor, createFocusListener, createItemListener, createKeyListener, createLayoutManager, createListDataListener, createPropertyChangeListener, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getDisplaySize, getInsets, getMaximumSize, getMinimumSize, getPreferredSize, getSizeForComponent, installComponents, installKeyboardActions, isFocusTraversable, isNavigationKey, isPopupVisible, paintCurrentValueBackground, rectangleForCurrentValue, removeEditor, selectNextPossibleValue, selectPreviousPossibleValue, setPopupVisible, toggleOpenClose, unconfigureArrowButton, unconfigureEditor, uninstallComponents, uninstallKeyboardActionscontainspublic static ComponentUI createUI(JComponent c)
c - 为其创建UI对象的组件
public void installUI(JComponent c)
ComponentUI实例作为指定组件上的UI委托时,将调用此方法。
该方法应该完全配置组件的外观,包括以下内容:
LayoutManager上安装LayoutManager。 PropertyChangeListener上创建/安装PropertyChangeListener,以便适当地检测和响应组件属性的更改。 installUI在
BasicComboBoxUI
c - 正在安装此UI代理的组件
ComponentUI.uninstallUI(javax.swing.JComponent) ,
JComponent.setUI(javax.swing.plaf.ComponentUI) ,
JComponent.updateUI()
protected void installDefaults()
BasicComboBoxUI
protected void installListeners()
public void uninstallUI(JComponent c)
installUI上完成的installUI 。
当将此UIComponent实例作为指定组件的UI委托删除时,将调用此方法。
该方法应该撤消在installUI中执行的installUI ,小心使JComponent实例处于干净状态(无外部侦听器,外观特定属性对象等)。
这应该包括以下内容:
uninstallUI在
BasicComboBoxUI
c - 从中删除此UI代理的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
protected void uninstallDefaults()
protected void uninstallListeners()
installListeners中添加的installListeners
public SynthContext getContext(JComponent c)
getContext在接口
SynthUI
c - 组件请求SynthContext。
protected ComboPopup createPopup()
createPopup在
BasicComboBoxUI
ComboPopup
ComboPopup
protected ListCellRenderer createRenderer()
setRenderer明确设置渲染器时,才会使用默认渲染器。
createRenderer在
BasicComboBoxUI
ListCellRender用于组合框
JComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)
protected ComboBoxEditor createEditor()
setEditor显式设置编辑器时,才会使用默认编辑器。
createEditor在
BasicComboBoxUI
ComboBoxEditor用于组合框
JComboBox.setEditor(javax.swing.ComboBoxEditor)
public void propertyChange(PropertyChangeEvent e)
propertyChange在界面
PropertyChangeListener
e - 描述事件源和已更改的属性的PropertyChangeEvent对象。
protected JButton createArrowButton()
createArrowButton在
BasicComboBoxUI
public void update(Graphics g, JComponent c)
paint(SynthContext,Graphics)方法。
通常,此方法不需要被子类覆盖。 所有的Look和Feel渲染代码都应该在paint方法中。
update在
ComponentUI
g - 用于绘画的
Graphics对象
c - 正在涂漆的组件
paint(SynthContext,Graphics)
public void paint(Graphics g, JComponent c)
Synth Look and Feel不使用此方法。 绘画由paint(SynthContext,Graphics)处理。
paint在
BasicComboBoxUI
g - 用于绘画的
Graphics对象
c - 被绘的部件
paint(SynthContext,Graphics)
protected void paint(SynthContext context, Graphics g)
context - 要绘制的组件的上下文
g - 用于绘画的
Graphics对象
update(Graphics,JComponent)
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
paintBorder在接口
SynthUI
context - 组件上下文
g -
Graphics上画
x - X坐标
y - Y坐标
w - 边框的宽度
h - 边框的高度
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
protected Dimension getDefaultSize()
getDefaultSize在
BasicComboBoxUI
BasicComboBoxUI.getDisplaySize()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.