aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable action listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable action listener" Watch "JTable action listener" New topic
Author

JTable action listener

Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Please see my code below. I am trying to integrate the action listener (commented code) to refresh the table upon table name selection from the combo box and I cannot make it work. What am I missing? Thank you.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

If you want to be notified when the selection in a JComboBox changes, then you need an ItemListener.
Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Could you please post an example. When i use the action listeners in a different program, please see below, it works very well.
When I tried to integrate it with my JTable program, it does not work.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You should already have read Oracle's JComboBox tutorial. Far better to read Oracle's tutorials than to wait for people to answer questions on forums. (By the way the tutorial shows you how to use an ActionListener...)
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
Your code doesn't compile.



I have never used an ItemSelectable and have no idea what it is.

"selectedString' is not defined.

"Dat" is not defined.

Most code I've seen on the forums would be something like:



If your code isn't working then its probably because either the "tableName" or your code to create the TableModel isn't correct.

If you need more help then post a proper SSCCE. That is we don't have access to your database, so any SQL code is useless to us. Just hardcode the values in the combo box. Same think when you recreate the model. Just use hardecoded values. Once you determine if the ActionListener code is correct, then you can work on your SQL.
Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Hi,

I figured what the problem was. All the events related to the table set inside the action listener method (different editors and so on....) need to be inside the action listener method. Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable action listener