import java.awt.GridLayout;
import java.util.HashSet;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
//1~9까지 숫자 랜덤으로 3x3 판에 생성
//큰 숫자부터 작은숫자까지 차례대로 클릭 하여 시간계산
//다음 턴 사람도 동일하게 시간계산
//가장 시간이 짧은 사람이 1등
public class Client extends JFrame{
private static final int HashSet = 0;
private static final int Integer = 0;
private JPanel panel = new JPanel(new GridLayout(3,3,2,2)); //3x3 판 생성
private JButton bt1 = new JButton();
private JButton bt2 = new JButton();
private JButton bt3 = new JButton();
private JButton bt4 = new JButton();
private JButton bt5 = new JButton();
private JButton bt6 = new JButton();
private JButton bt7 = new JButton();
private JButton bt8 = new JButton();
private JButton bt9 = new JButton();
private JLabel jl1= new JLabel();
public void numInit(){
HashSet<Integer> hs = new HashSet<Integer>();
while(hs.size() <9){
hs.add((int)(Math.random()*(20-1+1)+1));
}
}
public void compInit(){
// bt1.add(jl1);
panel.add(bt1);
panel.add(bt2);
panel.add(bt3);
panel.add(bt4);
panel.add(bt5);
panel.add(bt6);
panel.add(bt7);
panel.add(bt8);
panel.add(bt9);
this.add(panel);
}
public Client(){
super("speed count game");
this.setSize(500, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.compInit();
this.numInit();
//this.eventInit();
this.setVisible(true);
}
public static void main(String[] ar){
new Client();
}
}
랜덤으로 숫자 생성하고 그 숫자 9개를
JLabel이나 JTextField에 넣는게 가능하긴 해요????????????????????????????????????
댓글 0