forked from keenPioneer/Suduko-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBox.java
52 lines (51 loc) · 1.1 KB
/
Box.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Box{
public JButton btn;
public int val;
public int row;
public int col;
public int gno;
public int uniqueId;
Box(int x,int y){
val=0;
btn=new JButton();
btn.setBounds(x,y,50,50);
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){System.out.println(uniqueId);}
});
btn.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
val=Character.getNumericValue(ke.getKeyChar());
reset();
}
});
btn.setVisible(true);
}
public void setG(int g){gno=g;}
public void setVal(int val){
this.val=val;
reset();
}
public int getVal(){
return val;
}
public int uniqueId(){
return uniqueId();
}
public int getR(){
return row;
}
public int getC(){
return col;
}
public void setUniqueId(int ui){
uniqueId=ui;
}
public void reset(){
if(val==0)btn.setLabel(null);
else
btn.setLabel(Integer.toString(val));
}
}