⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menuaction.java

📁 可以单人与电脑单独对战的五子棋小游戏基于JAVA 的强大功能开发!小程序可以玩一下也可以看看!
💻 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 + -