This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JComboBox stores same Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox stores same " Watch "JComboBox stores same " New topic
Author

JComboBox stores same

Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Hi,

The comboBox below, or variable str stores the table name selected thorugh the dropdown of the combobox twice. System.out.println(str); outputs:
test5
test5

Also; constructor initialization in the related class (public class Dat extends AbstractTableModel) through dtable = new Dat(str); happens twice, and since I use the table name to open the table for reading, the table gets opened twice. I have not idea of what is going on? Could you please read my code?
Thank you.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2180
    
    7
Use an ActionListener instead of an ItemListener.

An ItemListener has two states, selected/unselected.
Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Thank you! I did that and it works.
 
Consider Paul's rocket mass heater.
 
subject: JComboBox stores same