📄 randommaster.java
字号:
package poker;
/**
* <p>Title: 斗地主</p>
* <p>Description: 随机产生地主</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author 李艳生
* @version 1.0
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.net.URL;
import java.net.URLClassLoader;
public class RandomMaster extends JDialog{
GridLayout gridLayout1 = new GridLayout();
JLabel lblName = new JLabel();
JLabel lblImage = new JLabel();
ImageIcon img1,img2,img3;
public RandomMaster() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
gridLayout1.setColumns(3);
gridLayout1.setHgap(5);
gridLayout1.setRows(1);
this.setSize(new Dimension(205, -1));
this.setModal(false);
this.setResizable(false);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width - 205)/2,(screenSize.height)/2);
this.getContentPane().setLayout(gridLayout1);
this.setTitle("正在随机产生地主,请稍等... ");
//随机产生地主
Random r = new Random();
int n = r.nextInt(4);
while((n<1)||(n>3)){
n = r.nextInt(4);
}
img1 = new ImageIcon(PokerKernal.one.image);
img2 = new ImageIcon(PokerKernal.two.image);
img3 = new ImageIcon(PokerKernal.three.image);
switch(n){
case 1:
PokerKernal.master = "one";
lblName.setText(" "+PokerKernal.one.name);
this.getContentPane().add(lblName, null);
lblImage.setIcon(img1);
this.getContentPane().add(lblImage, null);
break;
case 2:
PokerKernal.master = "two";
lblName.setText(" "+PokerKernal.two.name);
this.getContentPane().add(lblName, null);
lblImage.setIcon(img2);
this.getContentPane().add(lblImage, null);
break;
case 3:
PokerKernal.master = "three";
lblName.setText(" "+PokerKernal.three.name);
this.getContentPane().add(lblName, null);
lblImage.setIcon(img3);
this.getContentPane().add(lblImage, null);
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -