This is the error i get when i write this line of code.
symbol : variable isSeletecd
location: class java.lang.String
if (dorm[0].isSeletecd && meal[0].
dorm
and meal
are String arrays, there is no isSeletecd
field or isSelected()
method on a java.lang.String
.
dorm
and meal
are String arrays
There is no isSelected()
method for the String
class, but there is a getSelectedIndex()
method for JComboBox
which can be used to get the index no of the currently selected item in the JComboBox
component.
By replacing the condition in the if statement in your ButtonListener
class
from
if (dorm[0].isSeletecd && meal[0].isSeletecd())
to
if(dormBox.getSelectedIndex()==0 && mealBox.getSelectedIndex()==0)
will solve your problem.
So your ButtonListener
class will now be
private class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if(dormBox.getSelectedIndex()==0 && mealBox.getSelectedIndex()==0)
totalCharges.setText("2150.00");
}
}
Reffer getSelectedIndex() for more information.