aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTable selection listener doesn't listen to column changes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTable selection listener doesn Watch "JTable selection listener doesn New topic
Author

JTable selection listener doesn't listen to column changes

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255


This is a basic implementation of ListSelectionListener with cell selection enabled, so a single column is selected whenever a row is selected, and together the selections determine a cell selection, right?
When nothing in the cell is selected, and then a cell is selected by clicking on it, it triggers a ListSelectionEvent, as it should.
After that, when a cell in a different row on the same table is selected, it triggers an event.
However, when a cell on the same row and a different column is clicked on, or moved to by right or left arrow buttons, it does not trigger a ListSelectionEvent. I think it should change because the column selection does change even though the row selection does not.
How can I make the program listen to changes in column selection, when the row selection does not change?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4164
    
    3

Hint: a JTable's TableColumnModel has its own ListSelectionModel.


luck, db
There are no new questions, but there may be new answers.
Stefan Eidelloth
Greenhorn

Joined: Nov 11, 2010
Posts: 1
You have to add two listeners:

ListSelectListenerObj=new ListSelect()
table.getSelectionModel().addListSelectionListener(ListSelectListenerObj);
table.getColumnModel().getSelectionModel() .addListSelectionListener(ListSelectListenerObj);
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JTable selection listener doesn't listen to column changes
 
Similar Threads
Using cell editors in JTable
Related to JTable( Switching between Row Selection)
Notifying listeners of changes in jtable cell selection
jtable
JTable ListSelection problem