Hello guys. I wanted to know how I can go about writing what is selected in a Jcombobox to a datafile. This is an example of what I'm trying to do but when I compile i get an error. How can i correct the line "output.writeUTF(number.getSelectedIndex());"
String[] numbers = { "1","2", "3", "4", "5", "6" };
JComboBox number = new JComboBox(numbers);
if (check())
{
try
{
output.writeUTF(number.getSelectedIndex());
JOptionPane.showMessageDialog(null, "Your number has been saved.",
"Submission Successful", JOptionPane.INFORMATION_MESSAGE);
}
catch(IOException c)
{
System.exit(1);
}
}