Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select row(s) in JTable ? 1

Status
Not open for further replies.

Strannik

Programmer
Joined
Jul 4, 2002
Messages
132
Location
UA
I need to select some row(s) in a table. The following code does nothing:

table.GetColumnModel().setColumnSelectionAllowed(true);
table.setRowSelectionAllowed(true);
table.setRowSelectionInterval(0, 0);
table.setColumnSelectionInterval(0,3);

I've looked through all help but found nothing :( Can somebody resolve this problem ??
 
You're almost there.

If you want to select a range of cells, do this:

//clear the selections, if needed.
table.clearSelection();

//Allow the selection if needed.
table.setColumnSelectionAllowed(true);
table.setRowSelectionAllowed(true);

//Starting cell.
table.changeSelection(0,0,false,false);
//Bottom corner cell, with everything between.
table.changeSelection(5,3,false, true);
 
to dbleyl:

Many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top