This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes ListSelectionListener in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ListSelectionListener in JTable" Watch "ListSelectionListener in JTable" New topic
Author

ListSelectionListener in JTable

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
I have a JTable and am trying to get the program to handle changes in the selections in the JTable. If it were a JList, I would just use the addListSelectionListener(ListSelectionListener listener) in the JList class. But there is no addListSelectionListener method in the JTable class. How can I add some kind of selection listener to JTable objects?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10489
    
    9

Use table.getSelectionModel().addListSelectionListener(ListSelectionListener yourListener)


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ListSelectionListener in JTable