Anto
Anto

Reputation: 4305

Item always selected in JTable

I have created a JTable where the included items are provided with radio buttons in order to enable users to select any of these once at a time. In order to show always the first item selected when the JTable is initialised (or when the item previously selected has been deleted) what method should I use?

Upvotes: 1

Views: 463

Answers (1)

Guillaume Poussel
Guillaume Poussel

Reputation: 9822

You should see the JTable Javadoc and particularly at :

getCellRect(int row, int column, boolean includeSpacing)

and

scrollRectToVisible(Rectangle aRect)

Something like

table.scrollRectToVisible(table.getCellRect(table.getSelectedRows()[0], 0, true));

should suit you.

Upvotes: 2

Related Questions