File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes MultipleCell Selection in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MultipleCell Selection in JTable" Watch "MultipleCell Selection in JTable" New topic
Author

MultipleCell Selection in JTable

Vrunda Joshi
Ranch Hand

Joined: Dec 03, 2001
Posts: 104
I have a JTable which is set individual cell selectable and allow multipleselection. I have a display problem when I use "CTRL" key and mouse toselect cells. The problem is that I cannot select them individually. (Someof Other cell are also selected) . Is it the
behaviour of JTable? And what can I do ?
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi,
If you look at the JTable docs you'll see there's a getSelectedRows() and a getSelectedColumns() but not a getSelectedCells() method.
This is just an idea but why not try to set Row and Column selectionAllowed() to true and extend the JTable to return a series of (row, col) coords by adding them to a Vector using a mouseListener to detect each new (row,col) selection and storing it in a Vector.
A nice little idea would be to create a SelectedCell class that held a row,col pair of ints with that were set in the constructor and then had appropiate getXX() methods to be used later when you want to query the JTable about the cells that were selected.
Let us know how you get on.

Bye,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
Don't get me started about those stupid light bulbs.
 
subject: MultipleCell Selection in JTable