public class BasicListUI extends ListUI
ListUI
实施。
BasicListUI
实例之间不能共享多个列表。
Modifier and Type | Class and Description |
---|---|
class |
BasicListUI.FocusHandler
这个类应该被视为一个“受保护的”内部类。
|
class |
BasicListUI.ListDataHandler
的listdatalistener的installui时间添加到jlists模型,当jlist.model性质变化。
|
class |
BasicListUI.ListSelectionHandler
的listselectionlistener的installui时间添加到jlists选择模型,当jlist.selectionmodel性质变化。
|
class |
BasicListUI.MouseInputHandler
鼠标输入,并集中处理JList。
|
class |
BasicListUI.PropertyChangeHandler
的propertychangelistener的installui时间添加到列表框。
|
Modifier and Type | Field and Description |
---|---|
protected int |
cellHeight |
protected int[] |
cellHeights |
protected static int |
cellRendererChanged |
protected int |
cellWidth |
protected static int |
fixedCellHeightChanged |
protected static int |
fixedCellWidthChanged |
protected FocusListener |
focusListener |
protected static int |
fontChanged |
protected JList |
list |
protected ListDataListener |
listDataListener |
protected ListSelectionListener |
listSelectionListener |
protected static int |
modelChanged |
protected MouseInputListener |
mouseInputListener |
protected PropertyChangeListener |
propertyChangeListener |
protected static int |
prototypeCellValueChanged |
protected CellRendererPane |
rendererPane |
protected static int |
selectionModelChanged |
protected int |
updateLayoutStateNeeded |
Constructor and Description |
---|
BasicListUI() |
Modifier and Type | Method and Description |
---|---|
protected int |
convertRowToY(int row)
返回列表框相对坐标指定行的起源或1如果行无效。
|
protected int |
convertYToRow(int y0)
将JList相对坐标包含它的行,基于当前的布局。
|
protected FocusListener |
createFocusListener() |
protected ListDataListener |
createListDataListener()
创建一个实例listdatalistener的模型添加到jlists需要。
|
protected ListSelectionListener |
createListSelectionListener()
创建一个实例listselectionhandler的选择模式添加到jlists需要。
|
protected MouseInputListener |
createMouseInputListener()
创建一个委托,实现了MouseInputListener。
|
protected PropertyChangeListener |
createPropertyChangeListener()
创建propertychangehandler的installui()添加到列表框的一个实例。
|
static ComponentUI |
createUI(JComponent list)
返回一个新的实例basiclistui。
|
int |
getBaseline(JComponent c, int width, int height)
返回基线。
|
Component.BaselineResizeBehavior |
getBaselineResizeBehavior(JComponent c)
返回一个枚举指示组件的尺寸的变化的基线。
|
Rectangle |
getCellBounds(JList list, int index1, int index2)
返回给定列表的坐标系统中的包围矩形,用于由两个索引指定的单元格的范围。
|
Dimension |
getPreferredSize(JComponent c)
列表的preferredsize取决于布局方向。
|
protected int |
getRowHeight(int row)
返回基于当前布局的指定行的高度。
|
Point |
indexToLocation(JList list, int index)
返回原点在给定的
JList ,指定的项,在列表中的坐标系统。
|
protected void |
installDefaults()
初始化列表属性如字体、前景和背景,并添加cellrendererpane。
|
protected void |
installKeyboardActions()
寄存器的
JList ,
BasicListUI 与键盘绑定。
|
protected void |
installListeners()
创建并安装听众对于JList,其模型和选择模型。
|
void |
installUI(JComponent c)
通过调用初始化
this.list
installDefaults() ,
installListeners() ,和
installKeyboardActions() 为。
|
int |
locationToIndex(JList list, Point location)
返回列表的坐标系统在指定的
JList 接近给定位置的细胞指数。
|
protected void |
maybeUpdateLayoutState()
如果updatelayoutstateneeded是非零,叫updatelayoutstate()和复位updatelayoutstateneeded。
|
void |
paint(Graphics g, JComponent c)
油漆行,cliprect相交的图形对象。
|
protected void |
paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex)
画一列细胞:计算有关的状态,让“橡皮图章”单元格渲染器组件,然后用cellrendererpane漆。
|
protected void |
selectNextIndex()
选择前面的行,并强制它是可见的。
|
protected void |
selectPreviousIndex()
选择前面的行,并强制它是可见的。
|
protected void |
uninstallDefaults()
设置列表属性未显式重写到
null 。
|
protected void |
uninstallKeyboardActions()
将键盘安装
installKeyboardActions 行动。
|
protected void |
uninstallListeners()
消除听众从JList,其模型和选择模型。
|
void |
uninstallUI(JComponent c)
this.list 反初始化调用
uninstallListeners() ,
uninstallKeyboardActions() ,和
uninstallDefaults() 为。
|
protected void |
updateLayoutState()
返回当前单元的高度或cellheights重构和基于返回当前单元的宽度值,基于当前字体和fixedcellwidth,fixedcellheight的当前值,并prototypecellvalue。
|
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
protected JList list
protected CellRendererPane rendererPane
protected FocusListener focusListener
protected MouseInputListener mouseInputListener
protected ListSelectionListener listSelectionListener
protected ListDataListener listDataListener
protected PropertyChangeListener propertyChangeListener
protected int[] cellHeights
protected int cellHeight
protected int cellWidth
protected int updateLayoutStateNeeded
protected static final int modelChanged
protected static final int selectionModelChanged
protected static final int fontChanged
protected static final int fixedCellWidthChanged
protected static final int fixedCellHeightChanged
protected static final int prototypeCellValueChanged
protected static final int cellRendererChanged
protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex)
public void paint(Graphics g, JComponent c)
paint
方法重写,继承类
ComponentUI
g
-
Graphics
背景的画
c
-正在绘制的构件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int)
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 Dimension getPreferredSize(JComponent c)
Layout Orientation | Preferred Size |
---|---|
JList.VERTICAL | The preferredSize of the list is total height of the rows and the maximum width of the cells. If JList.fixedCellHeight is specified then the total height of the rows is just (cellVerticalMargins + fixedCellHeight) * model.getSize() where rowVerticalMargins is the space we allocate for drawing the yellow focus outline. Similarly if fixedCellWidth is specified then we just use that. |
JList.VERTICAL_WRAP | If the visible row count is greater than zero, the preferredHeight is the maximum cell height * visibleRowCount. If the visible row count is <= 0, the preferred height is either the current height of the list, or the maximum cell height, whichever is bigger. The preferred width is than the maximum cell width * number of columns needed. Where the number of columns needs is list.height / max cell height. Max cell height is either the fixed cell height, or is determined by iterating through all the cells to find the maximum height from the ListCellRenderer. |
JList.HORIZONTAL_WRAP | If the visible row count is greater than zero, the preferredHeight is the maximum cell height * adjustedRowCount. Where visibleRowCount is used to determine the number of columns. Because this lays out horizontally the number of rows is then determined from the column count. For example, lets say you have a model with 10 items and the visible row count is 8. The number of columns needed to display this is 2, but you no longer need 8 rows to display this, you only need 5, thus the adjustedRowCount is 5. If the visible row count is <= 0, the preferred height is dictated by the number of columns, which will be as many as can fit in the width of the |
Insets
确定
list.getInsets()
。
getPreferredSize
方法重写,继承类
ComponentUI
c
- JList组件。
JComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
protected void selectPreviousIndex()
protected void selectNextIndex()
protected void installKeyboardActions()
JList
,
BasicListUI
与键盘绑定。这种方法是在installui()称。
protected void uninstallKeyboardActions()
installKeyboardActions
行动。这种方法是在uninstallui()时间称为subclassess应确保所有在installui时间注册的键盘操作被删除。
protected void installListeners()
protected void uninstallListeners()
protected void installDefaults()
protected void uninstallDefaults()
null
。属性是重写如果其当前值不是一个
UIResource
。
public void installUI(JComponent c)
this.list
installDefaults()
,
installListeners()
,和
installKeyboardActions()
为。
installUI
方法重写,继承类
ComponentUI
c
-组件,UI代理被安装
installDefaults()
,
installListeners()
,
installKeyboardActions()
public void uninstallUI(JComponent c)
this.list
反初始化调用
uninstallListeners()
,
uninstallKeyboardActions()
,和
uninstallDefaults()
为。集this.list空。
uninstallUI
方法重写,继承类
ComponentUI
c
-从这个UI代理被删除的组件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
uninstallListeners()
,
uninstallKeyboardActions()
,
uninstallDefaults()
public static ComponentUI createUI(JComponent list)
public int locationToIndex(JList list, Point location)
JList
接近给定位置的细胞指数。确定细胞实际上包含了指定位置,比较细胞的边界点,由
getCellBounds
。如果列表是空的模型,此方法返回
-1
。
locationToIndex
方法重写,继承类
ListUI
list
-列表
location
-的点的坐标
-1
NullPointerException
-如果
location
是空的
public Point indexToLocation(JList list, int index)
JList
,指定的项,在列表中的坐标系统。返回
null
如果索引无效。
indexToLocation
方法重写,继承类
ListUI
list
-列表
index
-细胞指数
null
public Rectangle getCellBounds(JList list, int index1, int index2)
如果小指标是细胞外的列表的范围,此方法返回null
。如果小指标是有效的,但更大的指标是名单之外的范围,只是第一指数范围返回。否则,返回有效范围的范围。
getCellBounds
方法重写,继承类
ListUI
list
-列表
index1
-范围内的第一个指标
index2
-范围内的第二指数
null
protected int getRowHeight(int row)
convertYToRow(int)
,
convertRowToY(int)
,
updateLayoutState()
protected int convertYToRow(int y0)
getRowHeight(int)
,
updateLayoutState()
protected int convertRowToY(int row)
getRowHeight(int)
,
updateLayoutState()
protected void maybeUpdateLayoutState()
updateLayoutState()
protected void updateLayoutState()
maybeUpdateLayoutState()
protected MouseInputListener createMouseInputListener()
类mylistui延伸basiclistui {保护mouseinputlistener z-bbfef798-450e-4da2-b727- 2e18978fc5e5() {返回新的mymouseinputhandler();}公共课mymouseinputhandler延伸MouseInputHandler {公共无效负责处理鼠标移动事件(MouseEvent e){当鼠标移动时,做一些额外的工作超级负责处理鼠标移动事件(E);}}}
protected FocusListener createFocusListener()
protected ListSelectionListener createListSelectionListener()
类mylistui延伸basiclistui {保护listselectionlistener z-94b86616-1855-4b51-baba- 5868cb6f3716() {返回新的myselectionlistener();}公共课myselectionlistener延伸listselectionhandler {public void valueChanged(listselectionevent e){当选择改变时做一些额外的工作超级valuechange(E);}}}
protected ListDataListener createListDataListener()
类mylistui延伸basiclistui {保护listdatalistener z-8479e060-7d3c-438c-979a- 1416ab3715ce() {返回新的mylistdatalistener();}公共课mylistdatalistener延伸listdatahandler {公共无效contentschanged(listdataevent e){当模型内容改变时,做一些额外的工作超级contentschange(E);}}}
protected PropertyChangeListener createPropertyChangeListener()
类mylistui延伸basiclistui {保护propertychangelistener z-03ba4d35-12c0-4a4b-9fb0- 79eb300277ba() {返回新的mypropertychangelistener();}公共课mypropertychangelistener延伸propertychangehandler {公共无效propertychange(PropertyChangeEvent e){如果(如getpropertyname()。等于(“模型”)){当模型改变时,做一些额外的工作}超级propertychange(E);}}}
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.