SuperVCD管理系统 完整代码,带各种注释,可以拿这个项目入门。
this.addWindowListener(new WindowCloser());
fileMenu.setMnemonic('f');
exitMenuItem.setMnemonic('x');
helpMenu.setMnemonic('h');
aboutMenuItem.setMnemonic('a');
//设定快捷键
exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
ActionEvent.CTRL_MASK));
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.CTRL_MASK));
aboutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
ActionEvent.CTRL_MASK));
}
/**
* 设定和选择外观
*
*/
protected void setupLookAndFeelMenu(JMenuBar theMenuBar) {
UIManager.LookAndFeelInfo[] lookAndFeelInfo
UIManager.getInstalledLookAndFeels();
JMenu lookAndFeelMenu = new JMenu("选项");
JMenuItem anItem = null;
LookAndFeelListener myListener = new LookAndFeelListener();
try {
for (int i=0; i < lookAndFeelInfo.length; i++) {
anItem = new JMenuItem(lookAndFeelInfo[i].getName() + " 外观"); anItem.setActionCommand(lookAndFeelInfo[i].getClassName());
anItem.addActionListener(myListener);
lookAndFeelMenu.add(anItem);
}
}
catch (Exception e) {
e.printStackTrace();
}
theMenuBar.add(lookAndFeelMenu); =