• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable action listener

 
Giuseppa Cefalu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to be notified when the selection in a JComboBox changes, then you need an ItemListener.
 
Giuseppa Cefalu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2565
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic