public class DefaultTableColumnModel extends Object implements TableColumnModel, PropertyChangeListener, ListSelectionListener, Serializable
JTable标准列处理。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans包。请看XMLEncoder。
JTable
| Modifier and Type | Field and Description |
|---|---|
protected ChangeEvent |
changeEvent
更改事件(只需要一个)
|
protected int |
columnMargin
每个列之间的宽度间隔
|
protected boolean |
columnSelectionAllowed
在该列模型中允许的列选择
|
protected EventListenerList |
listenerList
tablecolumnmodellistener列表
|
protected ListSelectionModel |
selectionModel
保持列选择的轨道的模型
|
protected Vector<TableColumn> |
tableColumns
在这个模型中,tablecolumn对象数组
|
protected int |
totalColumnWidth
一个所有列的组合宽度的本地缓存
|
| Constructor and Description |
|---|
DefaultTableColumnModel()
创建一个默认的表列模型。
|
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(TableColumn aColumn)
追加
aColumn的
tableColumns数组的末尾。
|
void |
addColumnModelListener(TableColumnModelListener x)
添加一个用于表列模型事件的侦听器。
|
protected ListSelectionModel |
createSelectionModel()
创建一个新的默认列表选择模型。
|
protected void |
fireColumnAdded(TableColumnModelEvent e)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireColumnMarginChanged()
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireColumnMoved(TableColumnModelEvent e)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireColumnRemoved(TableColumnModelEvent e)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireColumnSelectionChanged(ListSelectionEvent e)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
TableColumn |
getColumn(int columnIndex)
返回在
columnIndex柱
TableColumn对象。
|
int |
getColumnCount()
在
tableColumns返回数组的列数。
|
int |
getColumnIndex(Object identifier)
返回的数组中的
tableColumns标识符等于
identifier第一列的索引,使用
equals相比。
|
int |
getColumnIndexAtX(int x)
返回位于位置
x列的索引,或1如果没有栏目涵盖这一点。
|
int |
getColumnMargin()
返回
TableColumn宽缘。
|
TableColumnModelListener[] |
getColumnModelListeners()
返回在该模型上注册的所有列模型侦听器的数组。
|
Enumeration<TableColumn> |
getColumns()
回归模型中所有的列的
Enumeration。
|
boolean |
getColumnSelectionAllowed()
如果允许的列选择,则返回真的,否则为假。
|
<T extends EventListener> |
getListeners(类<T> listenerType)
返回对象的当前注册为
FooListeners在此模型上的数组。
|
int |
getSelectedColumnCount()
返回选定的列数。
|
int[] |
getSelectedColumns()
返回选定列的数组。
|
ListSelectionModel |
getSelectionModel()
返回
ListSelectionModel是用来保持色谱柱的选择状态。
|
int |
getTotalColumnWidth()
返回所有列的总组合宽度。
|
void |
moveColumn(int columnIndex, int newIndex)
移动列和标题在
columnIndex到
newIndex。
|
void |
propertyChange(PropertyChangeEvent evt)
属性更改侦听器更改方法。
|
protected void |
recalcWidthCache()
重新计算所有列的总宽度。
|
void |
removeColumn(TableColumn column)
删除
column从
tableColumns阵列。
|
void |
removeColumnModelListener(TableColumnModelListener x)
移除表列模型事件的侦听器。
|
void |
setColumnMargin(int newMargin)
集
newMargin柱边缘。
|
void |
setColumnSelectionAllowed(boolean flag)
设置是否允许列选择。
|
void |
setSelectionModel(ListSelectionModel newModel)
设置此
TableColumnModel到
newModel和寄存器从新选择模型监听器通知选择模型。
|
void |
valueChanged(ListSelectionEvent e)
一个
ListSelectionListener转发
ListSelectionEvents当有柱的选择变化。
|
protected Vector<TableColumn> tableColumns
protected ListSelectionModel selectionModel
protected int columnMargin
protected EventListenerList listenerList
protected transient ChangeEvent changeEvent
protected boolean columnSelectionAllowed
protected int totalColumnWidth
public void addColumn(TableColumn aColumn)
aColumn的
tableColumns数组的末尾。这种方法也帖
columnAdded事件的听众。
addColumn 接口
TableColumnModel
aColumn -
TableColumn加以补充
null
aColumn
IllegalArgumentException
removeColumn(javax.swing.table.TableColumn)
public void removeColumn(TableColumn column)
column从
tableColumns阵列。这个方法如果
column不在表中的列列表中做什么。
tile来改变图片的标题和表视图。这种方法也发表了
columnRemoved事件的听众。
removeColumn 接口
TableColumnModel
column -
TableColumn被删除
addColumn(javax.swing.table.TableColumn)
public void moveColumn(int columnIndex,
int newIndex)
columnIndex到
newIndex。在
columnIndex老柱将被发现在
newIndex,曾在
newIndex列左或右移使房间。这将没有任何列,如果
columnIndex等于
newIndex。这种方法也发表了
columnMoved事件的听众。
moveColumn 接口
TableColumnModel
columnIndex -柱感动指数
newIndex -移动列的新指标
IllegalArgumentException -如果
column或
newIndex不在有效范围
public void setColumnMargin(int newMargin)
newMargin柱边缘。这种方法也发表了
columnMarginChanged事件的听众。
setColumnMargin 接口
TableColumnModel
newMargin -新的边缘的宽度,以像素为单位
getColumnMargin(),
getTotalColumnWidth()
public int getColumnCount()
tableColumns返回数组的列数。
getColumnCount 接口
TableColumnModel
tableColumns阵列的列数
getColumns()
public Enumeration<TableColumn> getColumns()
Enumeration。
getColumns 接口
TableColumnModel
Enumeration
public int getColumnIndex(Object identifier)
tableColumns标识符等于
identifier第一列的索引,使用
equals相比。
getColumnIndex 接口
TableColumnModel
identifier的标识对象
tableColumns的数组标识符等于
identifier第一列的索引
IllegalArgumentException -如果
identifier是
null,或者如果没有
TableColumn这
identifier
getColumn(int)
public TableColumn getColumn(int columnIndex)
columnIndex柱
TableColumn对象。
getColumn 接口
TableColumnModel
columnIndex -索引列的期望
columnIndex柱
TableColumn对象
public int getColumnMargin()
TableColumn宽度默认是1
columnMargin边缘。
getColumnMargin 接口
TableColumnModel
TableColumn最大宽度
setColumnMargin(int)
public int getColumnIndexAtX(int x)
x列的索引,或1如果没有栏目涵盖这一点。在保持与摆动的分离模型体系,一个tablecolumnmodel不知道怎么表列实际上出现在屏幕上。列的视觉呈现的是责任的视图/控制器对象使用这个模型(通常JTable)。视图/控制器不需要从左到右依次显示列。例如,可以显示从右到左的列,以适应区域设置偏好或一些列可能被隐藏在用户的请求。由于模型不知道怎么列放在屏幕上,给
xPosition不应该被认为是二维图形的空间坐标。相反,它应该被认为是一个宽度从第一列在模型中的开始。如果索引列为一个给定的二维空间中的x坐标是必需的,
JTable.columnAtPoint可以代替。
getColumnIndexAtX 接口
TableColumnModel
x -感兴趣的水平位置
JTable.columnAtPoint(java.awt.Point)
public int getTotalColumnWidth()
getTotalColumnWidth 接口
TableColumnModel
totalColumnWidth财产
public void setSelectionModel(ListSelectionModel newModel)
TableColumnModel到
newModel和寄存器从新选择模型监听器通知选择模型。如果
newModel是
null,抛出一个异常。
setSelectionModel 接口
TableColumnModel
newModel -选择新模式
null
newModel
IllegalArgumentException
getSelectionModel()
public ListSelectionModel getSelectionModel()
ListSelectionModel是用来保持色谱柱的选择状态。
getSelectionModel 接口
TableColumnModel
null如果行的选择是不允许的。
setSelectionModel(javax.swing.ListSelectionModel)
public void setColumnSelectionAllowed(boolean flag)
setColumnSelectionAllowed 接口
TableColumnModel
flag -如果色谱柱的选择将被允许,否则为假
TableColumnModel.getColumnSelectionAllowed()
public boolean getColumnSelectionAllowed()
getColumnSelectionAllowed 接口
TableColumnModel
columnSelectionAllowed财产
TableColumnModel.setColumnSelectionAllowed(boolean)
public int[] getSelectedColumns()
selectionModel是
null,返回一个空数组。
getSelectedColumns 接口
TableColumnModel
selectionModel是
null空数组的数组
public int getSelectedColumnCount()
getSelectedColumnCount 接口
TableColumnModel
public void addColumnModelListener(TableColumnModelListener x)
addColumnModelListener 接口
TableColumnModel
x -
TableColumnModelListener对象
public void removeColumnModelListener(TableColumnModelListener x)
removeColumnModelListener 接口
TableColumnModel
x -
TableColumnModelListener对象
public TableColumnModelListener[] getColumnModelListeners()
ColumnModelListeners或空数组如果没有柱模型的听众正在注册
addColumnModelListener(javax.swing.event.TableColumnModelListener),
removeColumnModelListener(javax.swing.event.TableColumnModelListener)
protected void fireColumnAdded(TableColumnModelEvent e)
e -接收事件
EventListenerList
protected void fireColumnRemoved(TableColumnModelEvent e)
e -接收事件
EventListenerList
protected void fireColumnMoved(TableColumnModelEvent e)
e -接收事件
EventListenerList
protected void fireColumnSelectionChanged(ListSelectionEvent e)
e -接收事件
EventListenerList
protected void fireColumnMarginChanged()
EventListenerList
public <T extends EventListener> T[] getListeners(类<T> listenerType)
FooListeners在此模型上的数组。
FooListeners使用
addFooListener方法注册。
您可以指定一个类的listenerType字面的说法,如FooListener.class。例如,你可以查询其柱模型的听众与下面的代码DefaultTableColumnModel m:
columnmodellistener [] CMLS =(columnmodellistener [ ])(m.getlisteners(columnmodellistener。类));如果没有这样的听众的存在,此方法将返回空数组。
listenerType -听众的类型要求;这个参数应该指定一个接口,从
java.util.EventListener
FooListeners数组,或一个空数组如果没有这样的听众已添加
ClassCastException -如果
listenerType不指定一个类或接口实现
java.util.EventListener
getColumnModelListeners()
public void propertyChange(PropertyChangeEvent evt)
propertyChange 接口
PropertyChangeListener
evt -
PropertyChangeEvent
public void valueChanged(ListSelectionEvent e)
ListSelectionListener转发
ListSelectionEvents当有柱的选择变化。
valueChanged 接口
ListSelectionListener
e -更改事件
protected ListSelectionModel createSelectionModel()
protected void recalcWidthCache()
totalColumnWidth财产。
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.