Link to home
Start Free TrialLog in
Avatar of John4343
John4343

asked on

JTable row select

How do I get a row in JTable selected when user clicks on first column in that row?

Rest of the time I want user to be able to block individual or group of cells so I have:

myTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
myTable.setCellSelectionEnabled(true);
Avatar of zzynx
zzynx
Flag of Belgium image

>> Rest of the time I want user to be able to block individual or group of cells so I have:
What do you mean with block?
I don't know if I understand you well, but if you *don't* want users to be able to select individual cells, you should have

myTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);  // = selected rows shouldn't be consecutive
myTable.setCellSelectionEnabled(false);  // false instead of true = you can't select individual cells

Then clicking in whatever column of a row, selects automatically the whole row.
Is that what you want?
Avatar of John4343
John4343

ASKER

Sorry for lack of clarity (and delay is response).

I want user to be able to select an individual cell or a block of cells by clicking and draging across a rectangular block of contiguos cells.  In addition select a single row.  For row selection I thought I could put a select arrow in the first column which, when clicked, would select the complete row.
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanx 4 axxepting