开发者

Creating a table with an initial element selected

I want to create a table which displays in each row a set of data, in addition to a radio button for possible selection. This can be achieved easily by using a si开发者_高级运维mple table model class which extends the DefaultTableModel and a cell renderer and editor class which implements the TableCellRenderer and TableCellEditor interfaces respectively. What I really couldn't manage to do is to make the table to display initially one of the elements (rows) initially selected. It seems straightforward but it isn't...does anybody have a clue about it?


Depends on your exact requirement.

table.changeSelection(2, 0, false, false);

will select the row and make the cell have focus in the table


Use the setSelectionInterval() method of the table's ListSelectionModel:

table.getSelectionModel().setSelectionInterval(4, 5);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜