?? menuaction.java
字號:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
class menuAction implements ActionListener{
mainPanel mp=null;
menuAction(mainPanel mp){
super();
this.mp=mp;
}
public void actionPerformed(ActionEvent e){
String arg=e.getActionCommand();
// String arg=e.getSource();
if(arg.equals("Exit")){
System.exit(0);
}
if(arg.equals("Option")){
mainClass.thisGame.showOption(true);
}
if(arg.equals("About")){
JOptionPane.showMessageDialog( mainClass.thisGame, "Thanks,http://blog.daywonder.com ???","About",0);
// System.out.println("dd");
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
}
if(arg.equals("Start a new game")){
mp.restart();
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
}
if(arg.equals("Windows Style")){
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
} catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog( mainClass.thisGame, "oops,sorry,but this style is only support in windows system","Not Windows System",0);
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
JOptionPane.showMessageDialog( mainClass.thisGame, "oops,sorry,but this style is only support in windows system","Not Windows System",0);
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
mainClass.thisGame.setWindowsMenu(false);
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
if(arg.equals("Metal Style")){
try {
UIManager.setLookAndFeel(
// "com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
"javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
if(arg.equals("Motif Style")){
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(mainClass.thisGame);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -