首页>代码>Java Swing开发扑克牌游戏>/ClassDesign/src/Poker_Swing/PokerGame.java
package Poker_Swing;


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Set;
import javax.swing.*;


public class PokerGame extends JFrame  {
	
	/*******数组存放初始化扑克牌,52张(除开大小王)********/
	String[] color = {"黑桃","红桃","梅花","方块"};
	String[] name = {"2","3","4","5","6","7","8","9",":10","J","Q","K","A"};
	 List<Poker> poker = new ArrayList<Poker>();  //List集合,用来承装洗牌前的扑克牌
	Set<Poker>poker2 = new HashSet<Poker>();  //洗牌的集合
	List<Poker>poker3 = new ArrayList<Poker>();  //用来承装洗牌后的扑克牌
	 List<Poker>st1 = new ArrayList<Poker>();  //用来承装选手1拿的扑克牌
	 List<Poker>st2 = new ArrayList<Poker>();  //用来承装选手2拿的扑克牌
	 String regex = "\\d+";  //ID的正则表达式格式
	 String regex1 = "\\D{1,}";  //name的正则表达式格式
	 
	private static final long serialVersionUID = 1L;
	/**
	 * 构造函数
	 */
	public PokerGame() throws Exception{
		
		/********************文本框,存放扑克******************************/
		JLabel save = new JLabel("游戏规则:",JLabel.CENTER);
		save.setBounds(246, 100, 90, 20);
		JTextArea savepoker = new JTextArea(); //文本	
		savepoker.setText("1、创建一副扑克牌包括四种花色:黑桃、红桃、梅花、方片十三种点数:2-10,J、Q、K、A,不考虑大小王\n2、创建两名玩家玩家至少要有ID、姓名、手牌等属性,手牌为扑克牌的集合\n3、洗牌将之前创建的“一副扑克牌”顺序打乱\n4、发牌将洗牌之后的扑克牌集合,从第一张开始,发给两名玩家,按照一人一张的方式,每人发两张\n5、游戏比较两名玩家手中的扑克牌,规则为:取两人各自手中点数最大的牌进行比较,点数大的赢;若两人各自的点数最大的牌相等,则再按花色比较。");
		JScrollPane show =new JScrollPane(savepoker); 
		show.setBounds(346, 100, 600, 80);
		show.setVisible(true);
		
		/**
		 * 窗体基本设置
		 */
		JFrame jf = new JFrame();	 //Jframe窗体
		// 设置窗体大小
		jf.setBounds(0, 0, 600, 400);
		jf.setVisible(true); // 使窗体可见	
		jf.setTitle("简易扑克牌游戏");
		// 设置窗体关闭模式
		jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);		
		
		/**
		 * 顶部游戏名
		 */
		
		Container container = jf.getContentPane();
		container.setLayout(null); //取消原来布局,使用绝对布局
		// 创建一个标签
		JLabel title = new JLabel("*****两人简易扑克牌游戏*****",JLabel.CENTER);
		title.setBounds(507, 0, 200, 50);
		title.setBackground(Color.yellow);
		title.setOpaque(true);
		/**
		 * 左右选手图片
		 */
		JLabel Lpicture = new JLabel();
		JLabel Rtpicture = new JLabel();
		// 获取图片所在的URL
		
		URL url1 = PokerGame.class.getResource("鸣人216463.png");
		URL url2 = PokerGame.class.getResource("鼬216463.png");
		Icon icon2 = new ImageIcon(url1); // 实例化左边选手Icon对象
		Icon icon3 = new ImageIcon(url2); // 实例化右边选手Icon对象
		Lpicture.setIcon(icon2); // 为标签设置图片
		Rtpicture.setIcon(icon3); // 为标签设置图片
		Lpicture.setBounds(0, 100, 216, 463);
		Rtpicture.setBounds(1000, 100, 216, 463);
		
		/**
		 * 开始按钮
		 */
		final JButton jbstart = new JButton(); 
		jbstart.setText("开始游戏"); // 设置按钮提示为文字
		jbstart.setBounds(507, 400,100,40 );
		/**
		 * 系统分配选手名字和ID
		 */
		final JButton System = new JButton("系统分配ID和名称");
		System.setBounds(427, 220, 140, 40);
		/**
		 * 自定义选手名称和ID
		 */
		final JButton custom = new JButton("自定义ID和名称");
		custom.setBounds(587, 220, 140, 40);
		/**
		 * 创建扑克牌
		 */
		final JButton Create = new JButton("创建扑克牌");
		Create.setBounds(507, 320, 100, 40);
		/**
		 * 洗牌按钮
		 */
		final JButton randPoker = new JButton("洗牌");
		randPoker.setBounds(507, 360, 100, 40);
		/**
		 * 发牌按钮
		 */
		final JButton sendPoker = new JButton("发牌");
		sendPoker.setBounds(627, 360, 100, 40);

		/**
		 * 退出按钮
		 */
		
		final JButton jbend = new JButton("退出游戏"); 
		jbend.setBounds(627, 400,100,40 );

		
		/**
		 * 创建标签
		 */
		JLabel player1 = new JLabel("选手1的ID:");
		player1.setBounds(246, 190, 90, 40);
		JLabel player1_1 = new JLabel("选手1的名字:");
		player1_1.setBounds(246, 230, 90, 40);
		JLabel player2 = new JLabel("选手2的ID:");
		player2.setBounds(750, 190, 90, 40);
		JLabel player2_2 = new JLabel("选手2的名字:");
		player2_2.setBounds(750, 230, 90, 40);
	
		
		/***************创建文本框,用于输入选手信息********************/
		JTextField playerID = new JTextField();  //输入选手1的ID
		playerID.setBounds(330, 200, 80, 20);
		playerID.setEditable(false);  //文本框不可被修改和选定
		JTextField playerName = new JTextField();  //输入选手1的名字
		playerName.setBounds(330, 240, 80, 20);
		playerName.setEditable(false);
		JTextField player2ID = new JTextField();  //输入选手2的ID
		player2ID.setBounds(830, 200, 80, 20);
		player2ID.setEditable(false);
		JTextField player2Name = new JTextField();  //输入选手2的名字
		player2Name.setBounds(830, 240, 80, 20);
		player2Name.setEditable(false);
		
		/**
		 * 选手1的两张手牌
		 */
		JLabel playerFirstPoker = new JLabel("选手1第一张手牌:");
		playerFirstPoker.setBounds(246, 270, 120, 40);
		 JLabel showFirstPoker = new JLabel();  //选手1手牌文本框
		 showFirstPoker.setBounds(370, 280, 80, 20);
		 JLabel playerSecondPoker = new JLabel("选手1第二张手牌:");
		 playerSecondPoker.setBounds(246, 300, 120, 40);
		 JLabel showSecondPoker = new JLabel();  //选手1手牌文本框
		 showSecondPoker.setBounds(370, 310, 80, 20);
		/**
		 * 选手1中最大的手牌
		 */
		JLabel player1MaxPoker = new JLabel("选手1中最大的手牌:");
		player1MaxPoker.setBounds(246, 330, 120, 40);
		 JLabel show1Poker = new JLabel();  //选手1手牌文本框
		 show1Poker.setBounds(370, 340, 80, 20);
		 /**
			 * 选手2的两张手牌
			 */
			JLabel player2FirstPoker = new JLabel("选手2第一张手牌:");
			player2FirstPoker.setBounds(750, 270, 120, 40);
			 JLabel show2FirstPoker = new JLabel();  //选手1手牌文本框
			 show2FirstPoker.setBounds(870, 280, 80, 20);
			 JLabel player2SecondPoker = new JLabel("选手2第二张手牌:");
			 player2SecondPoker.setBounds(750, 300, 120, 40);
			 JLabel show2SecondPoker = new JLabel();  //选手1手牌文本框
			 show2SecondPoker.setBounds(870, 310, 80, 20);
		 /**
		  * 选手2中最大的手牌
		  */
		 JLabel player2MaxPoker = new JLabel("选手2中最大的手牌:");
		 player2MaxPoker.setBounds(750, 330, 120, 40);
		 JLabel show2Poker = new JLabel();  //选手2手牌文本框
		 show2Poker.setBounds(870, 340, 80, 20);
		/**
		 * 获胜结果
		 */
		JLabel result = new JLabel("获胜者:",JLabel.LEFT);
		result.setBounds(560, 450, 90, 40);
		JLabel result1 = new JLabel("",JLabel.CENTER);
		result1.setBounds(620, 450, 100, 40);
		result1.setBackground(Color.lightGray);
		result1.setOpaque(true);
		/**
		 * 为容器增加各组件
		 */
		container.add(jbstart);  //开始
		container.add(jbend);  //退出
		container.add(System); //系统分配
		container.add(custom); //自定义
		container.add(Create); //创建扑克牌
		container.add(randPoker); //洗牌
		container.add(sendPoker); //发牌
		container.add(Lpicture); // 左图
		container.add(Rtpicture); // 右图
		container.add(title); // 标题
		/**显示游戏规则**/
		container.add(save);
		container.add(show);
		/**选手1**/
		container.add(player1);
		container.add(player1_1);
		container.add(playerID);
		container.add(playerName);
		/**选手2**/
		container.add(player2);
		container.add(player2_2);
		container.add(player2ID);
		container.add(player2Name);
		/**结果**/
		container.add(result);
		container.add(result1);	
		/**选手1拿到的手牌**/
		container.add(playerFirstPoker);
		container.add(playerSecondPoker);
		container.add(player1MaxPoker);
		container.add(showFirstPoker);
		container.add(showSecondPoker);
		container.add(show1Poker);
		/**选手2拿到的手牌**/
		container.add(player2MaxPoker);
		container.add(player2FirstPoker);
		container.add(player2SecondPoker);
		container.add(show2FirstPoker);
		container.add(show2SecondPoker);
		container.add(show2Poker);
		/**
		 * 系统分配ID和名称
		 */
		System.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
					playerID.setText("1");
					playerName.setText("鸣人");
					player2ID.setText("2");
					player2Name.setText("鼬");
				}catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
		/**
		 * 自定义ID和名称
		 */
		custom.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {	
				//清空
				playerID.setText("");
				playerName.setText("");
				player2ID.setText("");
				player2Name.setText("");
				try{
					playerID.setText(JOptionPane.showInputDialog("请输入选手1的ID"));
					if(playerID.getText().matches(regex)==false){
					boolean flag = true;
					while(flag){
					JOptionPane.showMessageDialog(null,"输入不合法,请输入数字");
					playerID.setText("");
					playerID.setText(JOptionPane.showInputDialog("请输入选手1的ID"));
					if(playerID.getText().matches(regex)==true){
						flag=false;
					}	
					}
					}
				}catch(InputMismatchException id1){
					id1.printStackTrace();
				}
				try{
				player2ID.setText(JOptionPane.showInputDialog("请输入选手2的ID"));	
				if(player2ID.getText().matches(regex)==false){
					boolean flag = true;
					while(flag){
					JOptionPane.showMessageDialog(null,"输入不合法,请输入数字");
					player2ID.setText("");
					player2ID.setText(JOptionPane.showInputDialog("请输入选手2的ID"));
					if(player2ID.getText().matches(regex)==true){
						flag=false;
						}
					}
				 }
				}catch(InputMismatchException id2){
			   }
				try{
				playerName.setText(JOptionPane.showInputDialog("请输入选手1的姓名"));
				if(playerName.getText().matches(regex1)==false){
					boolean flag = true;
					while(flag){
					JOptionPane.showMessageDialog(null,"输入不合法,请输入字符或汉字");
					playerName.setText("");
					playerName.setText(JOptionPane.showInputDialog("请输入选手1的姓名"));
					if(playerName.getText().matches(regex1)==true){
						flag=false;
								}
							}
						}
				 }catch(Exception name1){
				}
				player2Name.setText(JOptionPane.showInputDialog("请输入选手2的姓名"));
				if(player2Name.getText().matches(regex1)==false){
					boolean flag = true;				
					while(flag){
					JOptionPane.showMessageDialog(null,"输入不合法,请输入字符或汉字");
					player2Name.setText("");
					player2Name.setText(JOptionPane.showInputDialog("请输入选手2的姓名"));
					if(player2Name.getText().matches(regex1)==true){
						if(playerName.getText().toString()==(player2Name.getText().toString())){
						flag=false;
						}
						else{
							JOptionPane.showMessageDialog(null, "名字不能重复");
								}
							}
						}
				    }	
			}
		});
		/**
		 * 创建扑克牌按钮
		 */
		Create.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
				for(int i=0;i<color.length;i++){
					for(int j=0;j<name.length;j++){
						Poker p = new Poker(color[i],name[j]);
						poker.add(p);	
					}
				} 
				JOptionPane.showMessageDialog(null,"创建扑克牌成功");
			}catch (ArrayIndexOutOfBoundsException e3) {
				e3.printStackTrace();
			}
		}
		});
		
		/**
		 * 洗牌按钮
		 */
		randPoker.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
					if(poker.isEmpty()){
						JOptionPane.showMessageDialog(null, "你还没创建牌呢");
					}else{
						poker2.addAll(poker);	
						poker3.addAll(poker2);		
						JOptionPane.showMessageDialog(null,"洗牌成功");
						}
				}catch(Exception e4){
					e4.printStackTrace();
				}
				
			}
		});
		
			/**
			 * 发牌按钮事件
			 */
				sendPoker.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					try{
					if(poker3.isEmpty()){	
						JOptionPane.showMessageDialog(null, "还没洗牌或者创建扑克牌");
				}else{
					for(int i=0;i<4;i++){
			if(i%2==0){
				st1.add(poker3.get(i)); //选手1拿第一张和第三张
							}
			else { 
				st2.add(poker3.get(i));  //选手2拿第二张和最后一张
					}
												}			
				showFirstPoker.setText(st1.get(0).toString());
				showSecondPoker.setText(st1.get(1).toString());
				show2FirstPoker.setText(st2.get(0).toString());
				show2SecondPoker.setText(st2.get(1).toString());
				JOptionPane.showMessageDialog(null, "发牌成功");
				}
				}catch(Exception e5){
					e5.printStackTrace();
				}
				}
		});
				
		
		/************开始游戏按钮增加事件***********/
		jbstart.addActionListener(new ActionListener() {	
			/**
			 * 判断有没有填信息,创建扑克牌,洗牌,发牌
			 */
			public void actionPerformed(ActionEvent e) {
				try{
				if(playerID.getText().trim().length()==0 && playerName.getText().trim().length()==0 
						&& player2ID.getText().trim().length()==0 &&player2Name.getText().trim().length()==0){
					JOptionPane.showMessageDialog(null, "你还没填信息呢");
					
				}
				if(poker.isEmpty()){
					JOptionPane.showMessageDialog(null, "你还没创建扑克牌呢");
				}
				if(poker3.isEmpty()){  
					JOptionPane.showMessageDialog(null, "你还没洗牌呢");
				}if(st1.size()==0 || st2.size()==0 ){
					JOptionPane.showMessageDialog(null, "你还没发牌呢");
						
				}
				else{
				/**
				 * 判断各输入是否为空,输入是否符合正则表达式
				 */
				if(playerID.getText().matches(regex) &&  player2ID.getText().matches(regex) &&playerName.getText().matches(regex1) 
					&& player2Name.getText().matches(regex1)){
					StudentPlayer st1_1 = new StudentPlayer(playerID.getText(),playerName.getText());     //选手1
					StudentPlayer st2_2 = new StudentPlayer(player2ID.getText(),player2Name.getText());    //选手2
					/**********显示在文本框中***********/
					showFirstPoker.setText(st1.get(0).toString());
					showSecondPoker.setText(st1.get(1).toString());
					show2FirstPoker.setText(st2.get(0).toString());
					show2SecondPoker.setText(st2.get(1).toString());
					/**************选手1和选手2各自比较出自己手里最大的牌,显示在文本框中***********************/
					if( (st1.get(0).getBrandName().toString().compareTo(st1.get(1).getBrandName().toString()) )>0 && st1.get(1).getBrandName().equals("A")==false || (st1.get(0).getBrandName().equals("K")==true &&st1.get(1).getBrandName().toString().equals("Q")==true) ){
						show1Poker.setText(st1.get(0).toString());		
					}
					if( (st1.get(0).getBrandName().toString().compareTo(st1.get(1).getBrandName().toString()) )<0 && st1.get(0).getBrandName().equals("A")==false || (st1.get(1).getBrandName().equals("K")==true &&st1.get(0).getBrandName().toString().equals("Q")==true) ){
						show1Poker.setText(st1.get(1).toString());
					}
					if( (st1.get(0).getBrandName().toString().compareTo(st1.get(1).getBrandName().toString()) )<0 && st1.get(0).getBrandName().equals("A")==true || (st1.get(0).getBrandName().equals("K")==true &&st1.get(1).getBrandName().toString().equals("Q")==true)){
						show1Poker.setText(st1.get(0).toString());
					}
					if( (st1.get(0).getBrandName().toString().compareTo(st1.get(1).getBrandName().toString()) )>0 && st1.get(1).getBrandName().equals("A")==true || (st1.get(1).getBrandName().equals("K")==true &&st1.get(0).getBrandName().toString().equals("Q")==true)){
						show1Poker.setText(st1.get(1).toString());
					}
					if( (st2.get(0).getBrandName().toString().compareTo(st2.get(1).getBrandName().toString()) ) >0 && st2.get(1).getBrandName().equals("A")==false || (st2.get(0).getBrandName().equals("K")==true &&st2.get(1).getBrandName().toString().equals("Q")==true)){
						show2Poker.setText(st2.get(0).toString());
					}
					if( (st2.get(0).getBrandName().toString().compareTo(st2.get(1).getBrandName().toString()) ) <0 && st2.get(0).getBrandName().equals("A")==false || (st2.get(1).getBrandName().equals("K")==true &&st2.get(0).getBrandName().toString().equals("Q")==true)){
						show2Poker.setText(st2.get(1).toString());
					}
					if( (st2.get(0).getBrandName().toString().compareTo(st2.get(1).getBrandName().toString()) ) <0 && st2.get(0).getBrandName().equals("A")==true || (st2.get(0).getBrandName().equals("K")==true &&st2.get(1).getBrandName().toString().equals("Q")==true)){
						show2Poker.setText(st2.get(0).toString());
					}
					if( (st2.get(0).getBrandName().toString().compareTo(st2.get(1).getBrandName().toString()) )>0 && st2.get(1).getBrandName().equals("A")==true || (st2.get(1).getBrandName().equals("K")==true &&st2.get(0).getBrandName().toString().equals("Q")==true)){
						show2Poker.setText(st2.get(1).toString());
					}
				    if((st1.get(0).getBrandName().toString().compareTo(st1.get(1).getBrandName().toString()) )==0 ){
								if(st1.get(0).getColor().equals("黑桃") ||(st1.get(0).getColor().equals("红桃") && st1.get(1).getColor().equals("方块"))||
								(st1.get(0).getColor().equals("红桃") && st1.get(1).getColor().equals("梅花"))||(st1.get(0).getColor().equals("梅花") && st1.get(1).getColor().equals("方块")) ){
							show1Poker.setText(st1.get(0).toString());	
						}
					}
				    else 	if(st1.get(1).getColor().equals("黑桃") ||(st1.get(1).getColor().equals("红桃") && st1.get(0).getColor().equals("方块"))||
							(st1.get(1).getColor().equals("红桃") && st1.get(0).getColor().equals("梅花"))||(st1.get(1).getColor().equals("梅花") && st1.get(0).getColor().equals("方块")) ){
				    	show1Poker.setText(st1.get(1).toString());
				    }
				     if((st2.get(0).getBrandName().toString().compareTo(st2.get(1).getBrandName().toString()) )==0 ){
				    		if(st2.get(0).getColor().equals("黑桃") ||(st2.get(0).getColor().equals("红桃") && st2.get(1).getColor().equals("方块"))||
									(st2.get(0).getColor().equals("红桃") && st2.get(1).getColor().equals("梅花"))||(st2.get(0).getColor().equals("梅花") && st2.get(1).getColor().equals("方块")) ){
					show2Poker.setText(st2.get(0).toString());	
				}else	if(st2.get(1).getColor().equals("黑桃") ||(st2.get(1).getColor().equals("红桃") && st2.get(0).getColor().equals("方块"))||
						(st2.get(1).getColor().equals("红桃") && st2.get(0).getColor().equals("梅花"))||(st2.get(1).getColor().equals("梅花") && st2.get(0).getColor().equals("方块")) ){
					show2Poker.setText(st2.get(1).toString());
				}
				    }
					/**
					 * 最后比较两者最大的手牌的点数
					 * 思路:字符串分割,数组中第一个存放的是花色,第二个是名称。
					 * 先比较名称,如果名称大得选手,直接就是赢家。名称比较采用字符串compareTo方法,比较的是ascii码的大小。A是一个特殊的要处理的数。
					 * 如果名称相同,比较花色,花色大得选手,就是赢家
					 * 代码如下,先名称,后花色
					 */
					if(show1Poker.getText().toString().split(",")[1].compareTo(show2Poker.getText().toString().split(",")[1]) < 0 && show1Poker.getText().toString().split(",")[1].equals("A")==false || (show2Poker.getText().toString().split(",")[1].equals("K")==true &&show1Poker.getText().toString().split(",")[1].equals("Q")==true)){
						result1.setText(st2_2.getName());   
					}else if(show1Poker.getText().toString().split(",")[1].compareTo(show2Poker.getText().toString().split(",")[1]) > 0 && show2Poker.getText().toString().split(",")[1].equals("A")==true || (show2Poker.getText().toString().split(",")[1].equals("K")==true &&show1Poker.getText().toString().split(",")[1].equals("Q")==true)){
						result1.setText(st2_2.getName());
					}else if( show1Poker.getText().toString().split(",")[1].compareTo(show2Poker.getText().toString().split(",")[1]) > 0 && show2Poker.getText().toString().split(",")[1].equals("A")==false || (show1Poker.getText().toString().split(",")[1].equals("K")==true &&show2Poker.getText().toString().split(",")[1].equals("Q")==true)){
						result1.setText(st1_1.getName());
					}else if(show1Poker.getText().toString().split(",")[1].compareTo(show2Poker.getText().toString().split(",")[1]) < 0 && show1Poker.getText().toString().split(",")[1].equals("A")==true || (show1Poker.getText().toString().split(",")[1].equals("K")==true &&show2Poker.getText().toString().split(",")[1].equals("Q")==true)){
						result1.setText(st1_1.getName());
					}
					/********************除了以上名称比较情况,名称相同,比较花色*************************************/
					else if(show1Poker.getText().toString().split(",")[1].compareTo(show2Poker.getText().toString().split(",")[1])==0) {
						if(show1Poker.getText().toString().split(",")[0].equals("黑桃")==true || (show1Poker.getText().toString().split(",")[0].equals("红桃")==true && show2Poker.getText().split(",")[0].equals("梅花")==true ) 
							|| (show1Poker.getText().toString().split(",")[0].equals("红桃")==true && show2Poker.getText().toString().split(",")[0].equals("方块")==true )
							|| (show1Poker.getText().toString().split(",")[0].equals("梅花")==true && show2Poker.getText().toString().split(",")[0].equals("方块")==true )){
							
							result1.setText(st1_1.getName());	
						}
						if(show2Poker.getText().toString().split(",")[0].equals("黑桃")==true || (show2Poker.getText().toString().split(",")[0].equals("红桃")==true && show1Poker.getText().split(",")[0].equals("梅花")==true ) 
								|| (show2Poker.getText().toString().split(",")[0].equals("红桃")==true && show1Poker.getText().toString().split(",")[0].equals("方块")==true )
								|| (show2Poker.getText().toString().split(",")[0].equals("梅花")==true && show1Poker.getText().toString().split(",")[0].equals("方块")==true )){
							result1.setText(st2_2.getName());
					}		
					}
					JOptionPane.showMessageDialog(null, "游戏运行成功");
				}else{
					JOptionPane.showMessageDialog(null, "游戏运行失败,请先输入相关信息,还有空白处或者输入不正常(ID处请输入数字,名字处请输入非标识字符或汉字)");
				}
			}
			}catch(Exception e6){
					e6.printStackTrace();
				}
			}
		});
		/**
		 * 退出按钮事件
		 */
		jbend.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
				int option = JOptionPane.showConfirmDialog(jf, "你忍心退出游戏吗!");
				if(option == JOptionPane.YES_OPTION){
					jf.dispose();
				}		
			}catch(Exception e7){
				e7.printStackTrace();
			}
			}
		});
		
	}
	
	
	public static void main(String args[]) throws Exception {
		JOptionPane.showMessageDialog(null, "窗口显示慢,请点击右上角最大化按钮((^o^))");
		PokerGame poker = new PokerGame(); // 实例化MyImageIcon对象
		
	}

}
最近下载更多
微信网友_6233325343920128  LV1 2022年11月30日
huevnn  LV5 2022年6月15日
Czhiyi  LV6 2022年3月29日
一头土猪  LV7 2021年12月22日
Demo1111  LV30 2021年12月9日
quiyian  LV4 2021年6月8日
234123141  LV7 2021年5月10日
bg12123  LV1 2021年3月25日
2458165357  LV1 2021年2月19日
qq454952101  LV4 2021年2月5日
最近浏览更多
feelinfer  LV1 6月27日
qqqww11  LV2 6月26日
azzzz1  LV2 6月26日
ffffwwrgch  LV1 4月28日
gzcznb  LV8 4月1日
王少波  LV5 4月1日
2890892945  LV2 2023年12月26日
b5438b  LV7 2023年12月20日
unprecedented 2023年11月22日
暂无贡献等级
微信网友_6699076084797440  LV7 2023年10月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友