I asked a few hours ago (see: Java CheckboxMenuItem get/setState)
how I can change the state from my CheckBoxMenuItem
.
The user GhostCat
correctly suggested to me that in order to change the state I have to tell the object's entries its values.
My Menu:
Menu notiSET = new Menu("Benachrichtigungen");
CheckboxMenuItem ns1 = new CheckboxMenuItem("On");
CheckboxMenuItem ns2 = new CheckboxMenuItem("Off");
I tried using notiSET.countItems()
which gives me correctly 2
as an answer.
Following that I used
System.out.println(notiSET.getItem(0));
System.out.println(notiSET.getItem(1));
to identify the entries.
Output:
java.awt.CheckboxMenuItem[chkmenuitem0,label=On,state=false]
java.awt.CheckboxMenuItem[chkmenuitem1,label=Off,state=false]
Now I am trying to change the value of state=false
from chkmenuitem0
.
I tried using notiSET.getItem(0).
setState(boolean);
but the method is not known.
What am I doing wrong? Thanks.