GUI_菜单练习

package com.mywindow.test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MyMenu extends javax.swing.JFrame {
    private JMenuBar jMenuBar1;
    private JMenu jMenu5;
    private JMenuItem jMenuItem3;
    private JMenuItem jMenuItem2;
    private JMenuItem jMenuItem1;
    private JMenu jMenu6;
    private JMenu jMenu4;
    private JMenu jMenu3;
    private JMenu jMenu2;
    private JMenu jMenu1;
    //private JFileChooser chooser;
    private JDialog dialog;
    /**
    * Auto-generated main method to display this JFrame
    */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                MyMenu inst = new MyMenu();
                inst.setLocationRelativeTo(null);
                inst.setVisible(true);
            }
        });
    }
    
    public MyMenu() {
        super();
        initGUI();
    }
    
    private void initGUI() {
        try {
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            {
                jMenuBar1 = new JMenuBar();
                setJMenuBar(jMenuBar1);
                {
                    jMenu1 = new JMenu();
                    jMenuBar1.add(jMenu1);
                }
                {
                    jMenu2 = new JMenu();
                    jMenuBar1.add(jMenu2);
                    jMenu2.setText("\u6587\u4ef6");
                    {
                        jMenuItem1 = new JMenuItem();
                        jMenu2.add(jMenuItem1);
                        jMenuItem1.setText("\u6253\u5f00");
                        jMenuItem1.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jMenuItem1ActionPerformed(evt);
                            }
                        });
                    }
                }
                {
                    jMenu3 = new JMenu();
                    jMenuBar1.add(jMenu3);
                    jMenu3.setText("\u7f16\u8f91");
                    {
                        jMenuItem2 = new JMenuItem();
                        jMenu3.add(jMenuItem2);
                        jMenuItem2.setText("\u590d\u5236");
                    }
                    {
                        jMenuItem3 = new JMenuItem();
                        jMenu3.add(jMenuItem3);
                        jMenuItem3.setText("\u526a\u5207");
                    }
                }
                {
                    jMenu4 = new JMenu();
                    jMenuBar1.add(jMenu4);
                    jMenu4.setText("\u67e5\u770b");
                }
                {
                    jMenu5 = new JMenu();
                    jMenuBar1.add(jMenu5);
                    jMenu5.setText("\u5de5\u5177");
                }
                {
                    jMenu6 = new JMenu();
                    jMenuBar1.add(jMenu6);
                    jMenu6.setText("\u5e2e\u52a9");
                }
            }
            pack();
            setSize(400, 300);
        } catch (Exception e) {
            //add your error handling code here
            e.printStackTrace();
        }
    }
    
    private void jMenuItem1ActionPerformed(ActionEvent evt) {
        dialog = new JDialog(this);
        dialog.setVisible(true);
    //    chooser = new JFileChooser();
    //    chooser.setVisible(true);
    }

}

 

转载于:https://www.cnblogs.com/LO-ME/p/3606236.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值