public class BasicComboBoxUI extends ComboBoxUI
组合框是一个复合组件,这意味着它是许多简单的组件的集合。这个类在组合框和组合框模型上创建和管理侦听器。这些侦听器响应组合框的属性和状态的更改而更新用户界面。
所有的事件处理是通过监听器类与createxxxListener()
方法和内部类创建的处理。你可以通过重写createxxxListener()
方法和提供您自己的事件侦听器或子类在这类提供的这类行为的变化。
添加的具体行动,覆盖installKeyboardActions
在响应按键绑定添加动作。看到这篇文章How to Use Key Bindings
Modifier and Type | Class and Description |
---|---|
class |
BasicComboBoxUI.ComboBoxLayoutManager
这个布局管理器处理组合框的“标准”布局。
|
class |
BasicComboBoxUI.FocusHandler
这位听众隐藏弹出时,失去了焦点。
|
class |
BasicComboBoxUI.ItemHandler
此侦听器监视组合框中的选择的更改。
|
class |
BasicComboBoxUI.KeyHandler
此侦听器检查是否关键事件不是导航键。
|
class |
BasicComboBoxUI.ListDataHandler
这位听众手表在
ComboBoxModel 变化。
|
class |
BasicComboBoxUI.PropertyChangeHandler
此侦听器监视组合框中已更改的绑定属性。
|
Modifier and Type | Field and Description |
---|---|
protected JButton |
arrowButton |
protected Dimension |
cachedMinimumSize |
protected JComboBox |
comboBox |
protected CellRendererPane |
currentValuePane |
protected Component |
editor |
protected FocusListener |
focusListener
这个保护字段是实现特定的。
|
protected boolean |
hasFocus
这个保护字段是实现特定的。
|
protected boolean |
isMinimumSizeDirty |
protected ItemListener |
itemListener
这个保护字段是实现特定的。
|
protected KeyListener |
keyListener
这个保护字段是实现特定的。
|
protected JList |
listBox |
protected ListDataListener |
listDataListener
这个保护字段是实现特定的。
|
protected Insets |
padding
如果指定,这些插图作为填充在细胞渲染时铺设和绘画的“选择”项中的组合框。
|
protected ComboPopup |
popup |
protected KeyListener |
popupKeyListener |
protected MouseListener |
popupMouseListener |
protected MouseMotionListener |
popupMouseMotionListener |
protected PropertyChangeListener |
propertyChangeListener
这个保护字段是实现特定的。
|
protected boolean |
squareButton
指示组合框按钮是否应该是正方形的。
|
Constructor and Description |
---|
BasicComboBoxUI() |
Modifier and Type | Method and Description |
---|---|
void |
addEditor()
这种公共方法是实施特定的,应该是私人的。
|
void |
configureArrowButton()
这种公共方法是实施特定的,应该是私人的。
|
protected void |
configureEditor()
这种保护的方法是实现特定的,应该是私有的。
|
protected JButton |
createArrowButton()
创建一个按钮可显示或隐藏的组合框弹出部分的控制。
|
protected ComboBoxEditor |
createEditor()
创建默认的编辑器,用于编辑组合框。
|
protected FocusListener |
createFocusListener()
创建一个
FocusListener 这将被添加到组合框。
|
protected ItemListener |
createItemListener()
创建一个
ItemListener 这将被添加到组合框。
|
protected KeyListener |
createKeyListener()
创建一个
KeyListener 这将被添加到组合框。
|
protected LayoutManager |
createLayoutManager()
创建一个用于管理组成组合框的组件的布局管理器。
|
protected ListDataListener |
createListDataListener()
创建一个列表数据侦听器将被添加到
ComboBoxModel 。
|
protected ComboPopup |
createPopup()
创建组合框弹出的部分。
|
protected PropertyChangeListener |
createPropertyChangeListener()
创建一个
PropertyChangeListener 这将被添加到组合框。
|
protected ListCellRenderer |
createRenderer()
创建默认的渲染器,将用于非editiable组合框。
|
static ComponentUI |
createUI(JComponent c) |
Accessible |
getAccessibleChild(JComponent c, int i)
返回对象的
i th
Accessible 孩子。
|
int |
getAccessibleChildrenCount(JComponent c)
返回对象中可访问的儿童的数量。
|
int |
getBaseline(JComponent c, int width, int height)
返回基线。
|
Component.BaselineResizeBehavior |
getBaselineResizeBehavior(JComponent c)
返回一个枚举指示组件的尺寸的变化的基线。
|
protected Dimension |
getDefaultSize()
返回默认大小的一个空的显示区域的组合框使用当前渲染器和字体。
|
protected Dimension |
getDisplaySize()
返回显示区域的计算大小。
|
protected Insets |
getInsets()
从JComboBox获取插图。
|
Dimension |
getMaximumSize(JComponent c)
返回指定组件的最大大小适合的外观和感觉。
|
Dimension |
getMinimumSize(JComponent c)
最小尺寸的显示面积加上插图加按钮的大小。
|
Dimension |
getPreferredSize(JComponent c)
返回指定组件的首选大小适合的外观和感觉。
|
protected Dimension |
getSizeForComponent(Component comp)
收益的大小的一部分会作为一个单元渲染器。
|
protected void |
installComponents()
创建和初始化,使骨料组合框组件。
|
protected void |
installDefaults()
安装默认的颜色,默认字体,默认渲染器,默认编辑器为JComboBox。
|
protected void |
installKeyboardActions()
添加键盘动作的JComboBox。
|
protected void |
installListeners()
创建和安装组合框的侦听器和它的模型。
|
void |
installUI(JComponent c)
配置指定的组件适当的外观和感觉。
|
boolean |
isFocusTraversable(JComboBox c)
确定JComboBox是遍历的。
|
protected boolean |
isNavigationKey(int keyCode)
返回是否提供的键位映射到一个键,用于导航。
|
boolean |
isPopupVisible(JComboBox c)
告诉如果弹出是可见或不可见的。
|
void |
paint(Graphics g, JComponent c)
适当地绘制指定的组件的外观和感觉。
|
void |
paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
绘制当前选定的项目。
|
void |
paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)
绘制当前选定项目的背景。
|
protected Rectangle |
rectangleForCurrentValue()
返回用于绘制当前选定项目的区域。
|
void |
removeEditor()
这种公共方法是实施特定的,应该是私人的。
|
protected void |
selectNextPossibleValue()
选择列表中的下一个项目。
|
protected void |
selectPreviousPossibleValue()
选择列表中的前一个项目。
|
void |
setPopupVisible(JComboBox c, boolean v)
隐藏弹出。
|
protected void |
toggleOpenClose()
隐藏弹出如果是显示和显示弹出是否隐藏。
|
void |
unconfigureArrowButton()
这种公共方法是实施特定的,应该是私人的。
|
protected void |
unconfigureEditor()
这种保护的方法是实现特定的,应该是私有的。
|
protected void |
uninstallComponents()
骨料成分包括组合框是未注册和未初始化。
|
protected void |
uninstallDefaults()
卸载默认的颜色,默认字体,默认的渲染器,并从组合框的默认编辑器。
|
protected void |
uninstallKeyboardActions()
将焦点inputmap和actionmap。
|
protected void |
uninstallListeners()
从组合框中移除已安装的侦听器和它的模型。
|
void |
uninstallUI(JComponent c)
逆转形态,完成指定的组件在
installUI 。
|
contains, update
protected JComboBox comboBox
protected boolean hasFocus
protected JList listBox
protected CellRendererPane currentValuePane
protected ComboPopup popup
protected Component editor
protected JButton arrowButton
protected KeyListener keyListener
createKeyListener()
protected FocusListener focusListener
createFocusListener()
protected PropertyChangeListener propertyChangeListener
protected ItemListener itemListener
createItemListener()
protected MouseListener popupMouseListener
protected MouseMotionListener popupMouseMotionListener
protected KeyListener popupKeyListener
protected ListDataListener listDataListener
createListDataListener()
protected boolean isMinimumSizeDirty
protected Dimension cachedMinimumSize
protected boolean squareButton
protected Insets padding
public static ComponentUI createUI(JComponent c)
public void installUI(JComponent c)
ComponentUI
ComponentUI
实例被安装在指定组件的UI代理。这种方法应该完全配置的组件外观和感觉,包括以下内容:
LayoutManager
组件上的必要。PropertyChangeListener
变化适当。installUI
方法重写,继承类
ComponentUI
c
-组件,UI代理被安装
ComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
ComponentUI
installUI
。这个方法被调用时,这个
UIComponent
实例被作为指定组件的UI代理删除。这种方法应该撤消配置进行
installUI
,小心留下的
JComponent
实例在干净的状态(没有多余的听众,外观和感觉的特定属性的对象,等)。这应包括以下几个方面:
uninstallUI
方法重写,继承类
ComponentUI
c
-从这个UI代理被删除的组件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
ComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
protected void installDefaults()
protected void installListeners()
protected void uninstallDefaults()
protected void uninstallListeners()
installListeners
protected ComboPopup createPopup()
ComboPopup
实例
ComboPopup
protected KeyListener createKeyListener()
KeyListener
这将被添加到组合框。如果此方法返回的空值,则不会被添加到组合框中。
KeyListener
或空
protected FocusListener createFocusListener()
FocusListener
这将被添加到组合框。如果此方法返回的空值,则不会被添加到组合框中。
FocusListener
或空的实例
protected ListDataListener createListDataListener()
ComboBoxModel
。如果此方法返回的空值,则不会添加到组合框模型中。
ListDataListener
或空的实例
protected ItemListener createItemListener()
ItemListener
这将被添加到组合框。如果此方法返回的空值,则不会被添加到组合框中。
子类可以重写此方法以返回自己的itemevent处理实例。
ItemListener
或空的实例
protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListener
这将被添加到组合框。如果此方法返回的空值,则不会被添加到组合框中。
PropertyChangeListener
或空的实例
protected LayoutManager createLayoutManager()
protected ListCellRenderer createRenderer()
setRenderer
使用。
ListCellRender
JComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)
protected ComboBoxEditor createEditor()
setEditor
使用。
ComboBoxEditor
JComboBox.setEditor(javax.swing.ComboBoxEditor)
protected void installComponents()
protected void uninstallComponents()
public void addEditor()
ComboBoxEditor
public void removeEditor()
addEditor()
protected void configureEditor()
addEditor()
protected void unconfigureEditor()
addEditor()
public void configureArrowButton()
createArrowButton()
public void unconfigureArrowButton()
createArrowButton()
protected JButton createArrowButton()
public boolean isPopupVisible(JComboBox c)
isPopupVisible
方法重写,继承类
ComboBoxUI
public void setPopupVisible(JComboBox c, boolean v)
setPopupVisible
方法重写,继承类
ComboBoxUI
public boolean isFocusTraversable(JComboBox c)
isFocusTraversable
方法重写,继承类
ComboBoxUI
public void paint(Graphics g, JComponent c)
ComponentUI
ComponentUI.update
方法调用时指定的组件正在粉刷。子类应重写此方法,并使用指定的
Graphics
对象呈现的成分含量。
paint
方法重写,继承类
ComponentUI
g
-
Graphics
背景的画
c
-正在绘制的构件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
public Dimension getPreferredSize(JComponent c)
ComponentUI
null
返回,首选大小将由组件的布局管理器的计算(这是与一个特定的布局管理器安装任何组件的首选方法)。此方法的默认实现将返回
null
。
getPreferredSize
方法重写,继承类
ComponentUI
c
优先度的被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
JComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
public Dimension getMinimumSize(JComponent c)
getMinimumSize
方法重写,继承类
ComponentUI
c
最小尺寸的是被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
Dimension
对象或
null
JComponent.getMinimumSize()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
ComponentUI
null
返回,最大规模将由组件的布局管理器的计算(这是与一个特定的布局管理器安装任何组件的首选方法)。此方法的默认实现调用
getPreferredSize
和返回值。
getMaximumSize
方法重写,继承类
ComponentUI
c
-其最大尺寸被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
Dimension
对象或
null
JComponent.getMaximumSize()
,
LayoutManager2.maximumLayoutSize(java.awt.Container)
public int getBaseline(JComponent c, int width, int height)
getBaseline
方法重写,继承类
ComponentUI
c
-
JComponent
基线被要求
width
的宽度得到基线
height
-高度得到基线
null
c
NullPointerException
IllegalArgumentException
如果宽度或高度小于0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
方法重写,继承类
ComponentUI
c
-
JComponent
返回基线调整行为
null
c
NullPointerException
JComponent.getBaseline(int, int)
public int getAccessibleChildrenCount(JComponent c)
ComponentUI
Accessible
孩子,这种方法应该返回此对象的儿童数量。这可能需要重写这个如果他们目前在画面上,可以被看作是组件,但实际成分未被用于展示这些地区。注:如v1.3,建议开发商称
Component.AccessibleAWTComponent.getAccessibleChildrenCount()
代替本法。
getAccessibleChildrenCount
方法重写,继承类
ComponentUI
ComponentUI.getAccessibleChild(javax.swing.JComponent, int)
public Accessible getAccessibleChild(JComponent c, int i)
ComponentUI
i
th
Accessible
孩子。这可能如果他们出现在画面上,可以被看作是部分需要重写,但实际成分未被用于展示这些地区。
注:如v1.3,建议开发商称Component.AccessibleAWTComponent.getAccessibleChild()
代替本法。
getAccessibleChild
方法重写,继承类
ComponentUI
i
-零基础指数的孩子
i
th
Accessible
孩子
ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent)
protected boolean isNavigationKey(int keyCode)
protected void selectNextPossibleValue()
protected void selectPreviousPossibleValue()
protected void toggleOpenClose()
protected Rectangle rectangleForCurrentValue()
protected Insets getInsets()
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)
protected Dimension getDefaultSize()
getDisplaySize()
protected Dimension getDisplaySize()
对于组合框与一个不平凡的项目数,它建议使用一个原型显示值,以显着加快显示尺寸计算。
JComboBox.setPrototypeDisplayValue(E)
protected Dimension getSizeForComponent(Component comp)
comp
-
Component
检查
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
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.