Use cases of drop-down menu, pop-up menu and jtabbedpane components in Java Swing

Menu is the most commonly used component in GUI. It is not a subclass of component class and cannot be placed in ordinary containers. It is not constrained by the layout manager and can only be placed in the menu bar

The menu component consists of menu bar, menu and MenuItem. A menu bar consists of several menus, and a menu consists of several menu items. Generally, the menu bar is placed in the frame window. Just call the setmenubar() method of the frame class.

Commonly used menus are: pull-down menu and pop-up menu (displayed independently and can appear anywhere)

1: To create a drop-down menu:

1. Create a menu bar. 2. Call the setmenubar() method of the frame to add the menu bar to the frame. 3. Create several menu objects and add them to the menubar. 4. For each menu object, create several MenuItem objects and add them to the menu.

example:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>