The example has a menu called fruits. When the user clicks the Fruits menu, they can see four Checkbox menu items along with Image Icons. At the bottom of the screen, there is a text field which reports all the checked check boxes. In the above picture, Banana & Cherry check boxes are checked and hence the text field shows Banana and Cherry in it. When the user clicks a menu item, a check mark appears in the check box, and it disappears when the user clicks it again.
Tag Archive for ‘getState’
In this example, we will learn how to use AWT CheckboxMenuItem and Menu Separator.
Here, we use our previous example on AWT Menu and change it to create CheckboxMenuItem. We create three checkbox menu items for Circle, Pentagon and Rectangle. In the above picture, we can also see a sunken line running between normal menu items and checked menu items. This line is called a Menu Separator. We create that here as well in this example.