This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.