Usman
Usman

Reputation: 87

How to check a menu item selected is further a menu or not?

I want to know How can I differentiate that a Menu Item is of type Menu or MenuItem? As a Menu item can be of both types Menu or MenuItem

like in the code below Both menu and menuitem are added to Menu Object

        Menu format=new Menu("Format");
        Menu font=new Menu("Font");
        format.add(font);

        font.add(new MenuItem("Courier"));
        font.add(new MenuItem("Sans Serif"));
        font.add(new MenuItem("Monospaced"));
        font.add(new MenuItem("Symbol")); 

Upvotes: 1

Views: 40

Answers (1)

McNultyyy
McNultyyy

Reputation: 1032

isMenuItem(MenuItem item) {
    return (item instanceof MenuItem);
}

Upvotes: 1

Related Questions