learn java
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ListSelectionListener in JTable" Watch "ListSelectionListener in JTable" New topic

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: 10694

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.
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: ListSelectionListener in JTable