ListSelectiononclicklistenerr无法解析为类型

TableColumnModel (Java Platform SE 7 )
JavaScript is disabled on your browser.
Interface TableColumnModel
All Known Implementing Classes:
public interface TableColumnModel
Defines the requirements for a table column model object suitable for
use with JTable.
Method Summary
Modifier and Type
Method and Description
(&aColumn)
Appends aColumn to the end of the
tableColumns array.
Adds a listener for table column model events.
(int&columnIndex)
Returns the TableColumn object for the column at
columnIndex.
Returns the number of columns in the model.
(&columnIdentifier)
Returns the index of the first column in the table
whose identifier is equal to identifier,
when compared using equals.
(int&xPosition)
Returns the index of the column that lies on the
horizontal point, xPosition;
or -1 if it lies outside the any of the column's bounds.
Returns the width between the cells in each column.
Returns an Enumeration of all the columns in the model.
Returns true if columns may be selected.
Returns the number of selected columns.
Returns an array of indicies of all selected columns.
Returns the current selection model.
Returns the total width of all the columns.
(int&columnIndex,
int&newIndex)
Moves the column and its header at columnIndex to
Deletes the TableColumn column from the
tableColumns array.
Removes a listener for table column model events.
(int&newMargin)
Sets the TableColumn's column margin to
newMargin.
(boolean&flag)
Sets whether the columns in this model may be selected.
(&newModel)
Sets the selection model.
Method Detail
void&addColumn(&aColumn)
Appends aColumn to the end of the
tableColumns array.
This method posts a columnAdded
event to its listeners.
Parameters:aColumn - the TableColumn to be addedSee Also:
removeColumn
void&removeColumn(&column)
Deletes the TableColumn column from the
tableColumns array.
This method will do nothing if
column is not in the table's column list.
This method posts a columnRemoved
event to its listeners.
Parameters:column - the TableColumn to be removedSee Also:
moveColumn
void&moveColumn(int&columnIndex,
int&newIndex)
Moves the column and its header at columnIndex to
The old column at columnIndex
will now be found at newIndex.
The column that used
to be at newIndex is shifted left or right
to make room.
This will not move any columns if
columnIndex equals newIndex.
This method
posts a columnMoved event to its listeners.
Parameters:columnIndex - the index of column to be movednewIndex - index of the column's new location
- if columnIndex or
are not in the valid range
setColumnMargin
void&setColumnMargin(int&newMargin)
Sets the TableColumn's column margin to
newMargin.
This method posts
a columnMarginChanged event to its listeners.
Parameters:newMargin - the width, in pixels, of the new column marginsSee Also:
getColumnCount
int&getColumnCount()
Returns the number of columns in the model.
Returns:the number of columns in the model
getColumns
&&&getColumns()
Returns an Enumeration of all the columns in the model.
Returns:an Enumeration of all the columns in the model
getColumnIndex
int&getColumnIndex(&columnIdentifier)
Returns the index of the first column in the table
whose identifier is equal to identifier,
when compared using equals.
Parameters:columnIdentifier - the identifier object
Returns:the index of the first table column
whose identifier is equal to identifier
- if identifier
is null, or no
TableColumn has this
identifierSee Also:
&getColumn(int&columnIndex)
Returns the TableColumn object for the column at
columnIndex.
Parameters:columnIndex - the index of the desired column
Returns:the TableColumn object for
the column at columnIndex
getColumnMargin
int&getColumnMargin()
Returns the width between the cells in each column.
Returns:the margin, in pixels, between the cells
getColumnIndexAtX
int&getColumnIndexAtX(int&xPosition)
Returns the index of the column that lies on the
horizontal point, xPosition;
or -1 if it lies outside the any of the column's bounds.
In keeping with Swing's separable model architecture, a
TableColumnModel does not know how the table columns actually appear on
The visual presentation of the columns is the responsibility
of the view/controller object using this model (typically JTable).
view/controller need not display the columns sequentially from left to
For example, columns could be displayed from right to left to
accomodate a locale preference or some columns might be hidden at the
request of the user.
Because the model does not know how the columns
are laid out on screen, the given xPosition should not be
considered to be a coordinate in 2D graphics space.
Instead, it should
be considered to be a width from the start of the first column in the
If the column index for a given X coordinate in 2D space is
required, JTable.columnAtPoint can be used instead.
Returns:the or -1 if no column is foundSee Also:
getTotalColumnWidth
int&getTotalColumnWidth()
Returns the total width of all the columns.
Returns:the total computed width of all columns
setColumnSelectionAllowed
void&setColumnSelectionAllowed(boolean&flag)
Sets whether the columns in this model may be selected.
Parameters:flag - true if col otherwise falseSee Also:
getColumnSelectionAllowed
boolean&getColumnSelectionAllowed()
Returns true if columns may be selected.
Returns:true if columns may be selectedSee Also:
getSelectedColumns
int[]&getSelectedColumns()
Returns an array of indicies of all selected columns.
Returns:an array of integers containing the indicies of all
or an empty array if nothing is selected
getSelectedColumnCount
int&getSelectedColumnCount()
Returns the number of selected columns.
Returns:the number or 0 if no columns are selected
setSelectionModel
void&setSelectionModel(&newModel)
Sets the selection model.
Parameters:newModel - a ListSelectionModel objectSee Also:
getSelectionModel
&getSelectionModel()
Returns the current selection model.
Returns:a ListSelectionModel objectSee Also:
addColumnModelListener
void&addColumnModelListener(&x)
Adds a listener for table column model events.
Parameters:x - a TableColumnModelListener object
removeColumnModelListener
void&removeColumnModelListener(&x)
Removes a listener for table column model events.
Parameters:x - a TableColumnModelListener object
For further API reference and developer documentation, see . That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
© , Oracle and/or its affiliates.
All rights reserved. Use is subject to . Also see the .
Scripting on this page tracks web page traffic, but does not change the content in any way.1853人阅读
java学习(58)
&//Jlist.java//为Jlist添加事件//
//&applet code=Jlist.class width=200 height=100&//&/applet&
import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.event.*;
public class Jlist extends JApplet{&&String[] s={"choice1","choice2","choice3","choice4"};&JTextField txt=new JTextField(10);&JList list=new JList(s);&
&class SelecTry implements ListSelectionListener&{&&public void valueChanged(ListSelectionEvent e){&&&txt.setText("you selected:"+list.getSelectedIndex()); &&}&}
&SelecTry selectIndex=new SelecTry();
&public void init(){&&Container cp=getContentPane();&&cp.setLayout(new FlowLayout());&&list.addListSelectionListener(selectIndex);&&cp.add(list);&&cp.add(txt);&&&}&}
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:70514次
积分:1225
积分:1225
排名:千里之外
原创:60篇
(1)(8)(2)(38)(16)2400人阅读
SWing(4)
1。选择某一行(当选择这一行时,需要产生某种事件)
当用鼠标对表格进行选取,在响应行选取变化事件()时,鼠标按下会响应一次,鼠标释放又会响应一次,因此一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中,后者是。因此,可以通过判断来区别鼠标按下和释放,进行不同的操作。
&&& 而用键盘的上下键选取时,只有一次事件响应。
table.getSelectionModel().addListSelectionListener(new ListSelectionListener()
public void valueChanged(ListSelectionEvent e)
//do you what to do
2。选择某一列(当选择这一列时,需要产生某种事件)[ListSelectionListener]
table.getColumnModel().addColumnModelListener(
new TableColumnModelListener() {
public void columnAdded(TableColumnModelEvent e) {}
public void columnMarginChanged(ChangeEvent e) {
public void columnMoved(TableColumnModelEvent e) {
public void columnRemoved(TableColumnModelEvent e) {
public void columnSelectionChanged(ListSelectionEvent e) {}
3.单元格响应事件[TableModelListener此细粒度通知告知侦听器单元格、行或列的哪些具体范围发生了更改]
table.getModel().addTableModelListener(new
TableModelListener() ...{
&&&&&&&&&&&&public
void tableChanged(TableModelEvent e)
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:33308次
排名:千里之外
转载:10篇
评论:11条
(1)(8)(1)(4)如何让Editor类和Runtime类共享一个类的数据结构_百度知道如何用runtime获取类的属性_百度知道

我要回帖

更多关于 listener 的文章

 

随机推荐