In Java there are two types of menus: menubar and popup. The following section shows how to add a menubar to a frame.
Import the JMenuBar class from java.swing.
>>> from javax.swing import JJMenuBar
Create an instance of it.
>>> bar = JJMenuBar()
Import and create an instance of JFrame.
>>> from javax.swing import JFrame >>> frame = JFrame()
Set the JMenuBar property of the frame to the JMenuBar instance.
>>> frame.JJMenuBar = bar >>> frame.visible=1
Now that we have a menubar added in the frame, we need to add a menu to it. Create a menu (JMenu), and add it to the menubar.
>>> from javax.swing import JMenu >>> fruitMenu = JMenu("Fruit") >>> bar.add(fruitMenu) >>> frame.pack()
Add menu items to the menu.
>>> from javax.swing ...