SuperVCD管理系统 完整代码,带各种注释,可以拿这个项目入门。
container.add(BorderLayout.CENTER, tabbedPane); JMenuBar myMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu("文件"); JMenu openMenu = new JMenu("打开"); JMenuItem localMenuItem = new JMenuItem("本地硬盘..."); openMenu.add(localMenuItem); JMenuItem networkMenuItem = new JMenuItem("网络..."); openMenu.add(networkMenuItem); JMenuItem webMenuItem = new JMenuItem("互联网..."); openMenu.add(webMenuItem); fileMenu.add(openMenu); JMenuItem saveMenuItem = new JMenuItem("保存"); fileMenu.add(saveMenuItem); JMenuItem exitMenuItem = new JMenuItem("退出"); fileMenu.add(exitMenuItem); myMenuBar.add(fileMenu); exitMenuItem.addActionListener(new ExitActionListener()); setupLookAndFeelMenu(myMenuBar); JMenu helpMenu = new JMenu("帮助"); JMenuItem aboutMenuItem = new JMenuItem("关于"); helpMenu.add(aboutMenuItem); myMenuBar.add(helpMenu); aboutMenuItem.addActionListener(new AboutActionListener()); this.setJMenuBar(myMenuBar); setSize(500, 400); setLocation(100, 100);