File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 10828

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.
I agree. Here's the link:
subject: ListSelectionListener in JTable
It's not a secret anymore!