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

📄 backchangedialog.java

📁 基于swing界面的蜘蛛纸牌游戏,可以选择花色
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BackChangeDialog extends JDialog{
	JLabel jT = new JLabel("选择了蜘蛛");
	JPanel jMainPane = new JPanel();
	JPanel jBtPane = new JPanel();
	JPanel jTPane = new JPanel();
	private JLabel jL1 = new JLabel();
	private JLabel jL2 = new JLabel();
	private JLabel jL3 = new JLabel();
	private JLabel jL4 = new JLabel();
	private JButton jbt = new JButton("选择结束");
	private int backIndex;
	public BackChangeDialog(){
		backIndex = 0;
		setTitle("J蜘蛛牌背");
		setResizable(false);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		Container c = this.getContentPane();
		c.setLayout(new BorderLayout(5,10));
		jL1.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear.GIF")));
		jL2.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear1.GIF")));
		jL3.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear2.GIF")));
		jL4.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear3.GIF")));
		jL1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jT.setText("选择了蜘蛛");
				backIndex=0;
            }
        });
		jL2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jT.setText("选择了椰树");
				backIndex=1;
            }
        });
		jL3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jT.setText("选择了海鱼");
				backIndex=2;
            }
        });
		jL4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jT.setText("选择了蓝天");
				backIndex=3;
            }
        });

		jbt.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent e){
				setVisible(false);
				JOptionPane.showMessageDialog(null,"选择的信息将在下一轮游戏开始时更新","信息",JOptionPane.INFORMATION_MESSAGE);
			}
		});
		jMainPane.add(jL1);
		jMainPane.add(jL2);
		jMainPane.add(jL3);
		jMainPane.add(jL4);
		jBtPane.add(jbt);
		jTPane.add(jT);
/*		jMainPane.setBackground(new Color(0, 112, 26));
		jBtPane.setBackground(new Color(0, 112, 26));
		jTPane.setBackground(new Color(0, 112, 26));*/
		c.add(jTPane,BorderLayout.NORTH);
		c.add(jMainPane,BorderLayout.CENTER);
		c.add(jBtPane,BorderLayout.SOUTH);
		pack();		
	//	this.getContentPane().setBackground(new Color(0, 112, 26));
		this.setVisible(false);
		this.setLocation(300,200);
	}
	
	public int getBackIndex(){
		return backIndex;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -