Java Swing Interface Programming (+)---menu bar: jmenu

Source: Internet
Author: User

Package Com.beyole.test;import Javax.swing.jframe;import Javax.swing.jmenu;import javax.swing.jmenubar;import Javax.swing.jmenuitem;public class Swingtest {public static void main (string[] args) {JFrame JFrame = new JFrame ("Beyole") ; Jframe.setsize (+); jframe.setdefaultcloseoperation (jframe.exit_on_close);//set off exit JMenuBar MenuBar = new JMenuBar (); Jframe.setjmenubar (MenuBar); JMenu menu1 = new JMenu ("file"); JMenu menu2 = new JMenu ("edit"); JMenu menu3 = new JMenu ("View"); Menubar.add (menu1); Menubar.add (MENU2); Menubar.add (MENU3); JMenuItem item1 = new JMenuItem ("open"); JMenuItem item2 = new JMenuItem ("Save"); JMenuItem item3 = new JMenuItem ("Save As"); JMenuItem item4 = new JMenuItem ("Exit"); Menu1.add (item1); Menu1.add (item2); Menu1.add (ITEM3); Menu1.addseparator (); Menu1.add (ITEM4); jframe.setvisible (True);}}

Program:

How to create a menu bar of your own program, the above code clearly shows how swing creates the menu bar.

The jmenu of swing can be mastered simply by having the logical order of the containers and panels of Java swing clear.


Java Swing Interface Programming (+)---menu bar: jmenu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.