-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSudoko2D.java
More file actions
74 lines (64 loc) · 1.6 KB
/
Sudoko2D.java
File metadata and controls
74 lines (64 loc) · 1.6 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.awt.event.*;
import java.awt.*;
class Sudoko2D extends Frame implements ActionListener
{
Panel panel1;
Panel panel2;
Button button;
TextField[] text;
Label l;
public static void main(String args[])
{
Sudoko2D obj = new Sudoko2D();
obj.method();
}
public void method()
{
text = new TextField[81];
l = new Label();
this.setTitle("SUDOKO by sameer");
this.setSize(360,445);
this.setResizable(false);
this.addWindowListener(new MyWindowAdapter(this));
this.setLayout(new BorderLayout());
panel1 = new Panel(new GridLayout(9,9));
this.add(panel1);
panel1.setSize(360,365);
for(int x =0;x<81;x++)
{
text[x] = new TextField("0");
text[x].setSize(40,80);
panel1.add(text[x]);
}
button = new Button("solve");
button.setSize(40,40);
this.add(button,BorderLayout.SOUTH);
button.addActionListener(this);
setVisible(true);
}
String array[][];
@Override
public void actionPerformed(ActionEvent ae)
{
array = new String[9][9];
for(int a=0;a<9;a++)
{
for(int b =0;b<9;b++)
{
String d = text[(a)*9 +(b)].getText();
if(d == null)
array[a][b] = "0";
else
array[a][b] = d;
}
}
int array[][] = Algo4.main(this);
for(int a =0;a<81;a++)
{
for(int b =0;b<9;b++)
{
text[(a)*9 +(b)].setText(Integer.toString(array[a][b])) ;
}
}
}
}