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

Two ActionListeners

Jhon Calado
Greenhorn

Joined: Jun 06, 2013
Posts: 9
Hey guys,

I'm having a little problem with a GUI :

I have a ComboBox and a Button("Submit");
I want to write the content of the ComboBox to a File when I hit submit;
I can do that with TextFields (a simple get.Text, BufferedWriter and an ActionListener for the Button);
To do it with ComboBox I need an extra ActionListener to "listen" to the SelectedItem in my ComboBox;
How do I pass the SelectedItem from the (ComboBox) ActionListener to the (Button) ActionListener so it can be written in my file?

I'm probably making other little mistakes but the two ActionListener(s) using the same variable -the item selected- is what's bothering me.
I tried to find solutions elsewhere but no luck.

I guess here I can't pass the SelectedItem to the other ActionListener as an argument and I must implement the ActionListener for the ComboBox,otherwise if I just do a simple combolist.getSelectedItem it returns null.

Thank you in advance.





Jhon Calado
Greenhorn

Joined: Jun 06, 2013
Posts: 9
I get it now.Problem solved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two ActionListeners