I started coding a few Weeks ago and I need your help. I want to make a Sudoku with Swing/AWT. I googled a lot and it doesn't work
My idea is to set the 4 buttons above the JTextField
s. (The JTextField
s are the Sudoku fields.) When the GUI first appears, the Sudoku fields are not visible. Only after I maximize the window the JTextField
s appear.
import java.awt.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
public class Sudokuu {
public JFrame f;
Sudokuu() {
f = new JFrame("Sudoku");
f.setVisible(true);
f.setSize(1920, 1000);
f.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setBorder(BorderFactory.createLineBorder(Color.cyan));
p.setSize(700, 50);
p.setVisible(true);
p.setLayout(new FlowLayout());
JButton o = new JButton("One Step");
o.setSize(200, 50);
JButton e = new JButton("Easy");
e.setSize(200, 50);
JButton m = new JButton("Medium");
m.setSize(200, 50);
JButton h = new JButton("Hard");
h.setSize(200, 50);
p.add(o);
p.add(e);
p.add(m);
p.add(h);
JPanel field = new JPanel();
field.setLayout(new GridLayout(9, 9));
field.setVisible(true);
field.setSize(500, 500);
f.add(p);
f.add(field, BorderLayout.CENTER);
JTextField tf = new JTextField("", 1);
JTextField tf1 = new JTextField("", 1);
JTextField tf2 = new JTextField("", 1);
JTextField tf3 = new JTextField("", 1);
JTextField tf4 = new JTextField("", 1);
JTextField tf5 = new JTextField("", 1);
JTextField tf6 = new JTextField("", 1);
JTextField tf7 = new JTextField("", 1);
JTextField tf8 = new JTextField("", 1);
JTextField tf9 = new JTextField("", 1);
JTextField tf10 = new JTextField("", 1);
JTextField tf11 = new JTextField("", 1);
JTextField tf12 = new JTextField("", 1);
JTextField tf13 = new JTextField("", 1);
JTextField tf14 = new JTextField("", 1);
JTextField tf15 = new JTextField("", 1);
JTextField tf16 = new JTextField("", 1);
JTextField tf17 = new JTextField("", 1);
JTextField tf18 = new JTextField("", 1);
JTextField tf19 = new JTextField("", 1);
JTextField tf20 = new JTextField("", 1);
JTextField tf21 = new JTextField("", 1);
JTextField tf22 = new JTextField("", 1);
JTextField tf23 = new JTextField("", 1);
JTextField tf24 = new JTextField("", 1);
JTextField tf25 = new JTextField("", 1);
JTextField tf26 = new JTextField("", 1);
JTextField tf27 = new JTextField("", 1);
JTextField tf28 = new JTextField("", 1);
JTextField tf29 = new JTextField("", 1);
JTextField tf30 = new JTextField("", 1);
JTextField tf31 = new JTextField("", 1);
JTextField tf32 = new JTextField("", 1);
JTextField tf33 = new JTextField("", 1);
JTextField tf34 = new JTextField("", 1);
JTextField tf35 = new JTextField("", 1);
JTextField tf36 = new JTextField("", 1);
JTextField tf37 = new JTextField("", 1);
JTextField tf38 = new JTextField("", 1);
JTextField tf39 = new JTextField("", 1);
JTextField tf40 = new JTextField("", 1);
JTextField tf41 = new JTextField("", 1);
JTextField tf42 = new JTextField("", 1);
JTextField tf43 = new JTextField("", 1);
JTextField tf44 = new JTextField("", 1);
JTextField tf45 = new JTextField("", 1);
JTextField tf46 = new JTextField("", 1);
JTextField tf47 = new JTextField("", 1);
JTextField tf48 = new JTextField("", 1);
JTextField tf49 = new JTextField("", 1);
JTextField tf50 = new JTextField("", 1);
JTextField tf51 = new JTextField("", 1);
JTextField tf52 = new JTextField("", 1);
JTextField tf53 = new JTextField("", 1);
JTextField tf54 = new JTextField("", 1);
JTextField tf55 = new JTextField("", 1);
JTextField tf56 = new JTextField("", 1);
JTextField tf57 = new JTextField("", 1);
JTextField tf58 = new JTextField("", 1);
JTextField tf59 = new JTextField("", 1);
JTextField tf60 = new JTextField("", 1);
JTextField tf61 = new JTextField("", 1);
JTextField tf62 = new JTextField("", 1);
JTextField tf63 = new JTextField("", 1);
JTextField tf64 = new JTextField("", 1);
JTextField tf65 = new JTextField("", 1);
JTextField tf66 = new JTextField("", 1);
JTextField tf67 = new JTextField("", 1);
JTextField tf68 = new JTextField("", 1);
JTextField tf69 = new JTextField("", 1);
JTextField tf70 = new JTextField("", 1);
JTextField tf71 = new JTextField("", 1);
JTextField tf72 = new JTextField("", 1);
JTextField tf73 = new JTextField("", 1);
JTextField tf74 = new JTextField("", 1);
JTextField tf75 = new JTextField("", 1);
JTextField tf76 = new JTextField("", 1);
JTextField tf77 = new JTextField("", 1);
JTextField tf78 = new JTextField("", 1);
JTextField tf79 = new JTextField("", 1);
JTextField tf80 = new JTextField("", 1);
JTextField tf81 = new JTextField("", 1);
// Setting the Line
tf.setBorder(new LineBorder(Color.black, 2));
tf1.setBorder(new LineBorder(Color.black, 2));
tf2.setBorder(new LineBorder(Color.black, 2));
tf3.setBorder(new LineBorder(Color.black, 2));
tf4.setBorder(new LineBorder(Color.black, 2));
tf5.setBorder(new LineBorder(Color.black, 2));
tf6.setBorder(new LineBorder(Color.black, 2));
tf7.setBorder(new LineBorder(Color.black, 2));
tf8.setBorder(new LineBorder(Color.black, 2));
tf9.setBorder(new LineBorder(Color.black, 2));
tf10.setBorder(new LineBorder(Color.black, 2));
tf11.setBorder(new LineBorder(Color.black, 2));
tf12.setBorder(new LineBorder(Color.black, 2));
tf13.setBorder(new LineBorder(Color.black, 2));
tf14.setBorder(new LineBorder(Color.black, 2));
tf15.setBorder(new LineBorder(Color.black, 2));
tf16.setBorder(new LineBorder(Color.black, 2));
tf17.setBorder(new LineBorder(Color.black, 2));
tf18.setBorder(new LineBorder(Color.black, 2));
tf19.setBorder(new LineBorder(Color.black, 2));
tf20.setBorder(new LineBorder(Color.black, 2));
tf21.setBorder(new LineBorder(Color.black, 2));
tf22.setBorder(new LineBorder(Color.black, 2));
tf23.setBorder(new LineBorder(Color.black, 2));
tf24.setBorder(new LineBorder(Color.black, 2));
tf25.setBorder(new LineBorder(Color.black, 2));
tf26.setBorder(new LineBorder(Color.black, 2));
tf27.setBorder(new LineBorder(Color.black, 2));
tf28.setBorder(new LineBorder(Color.black, 2));
tf29.setBorder(new LineBorder(Color.black, 2));
tf30.setBorder(new LineBorder(Color.black, 2));
tf31.setBorder(new LineBorder(Color.black, 2));
tf32.setBorder(new LineBorder(Color.black, 2));
tf33.setBorder(new LineBorder(Color.black, 2));
tf34.setBorder(new LineBorder(Color.black, 2));
tf35.setBorder(new LineBorder(Color.black, 2));
tf36.setBorder(new LineBorder(Color.black, 2));
tf37.setBorder(new LineBorder(Color.black, 2));
tf38.setBorder(new LineBorder(Color.black, 2));
tf39.setBorder(new LineBorder(Color.black, 2));
tf40.setBorder(new LineBorder(Color.black, 2));
tf41.setBorder(new LineBorder(Color.black, 2));
tf42.setBorder(new LineBorder(Color.black, 2));
tf43.setBorder(new LineBorder(Color.black, 2));
tf44.setBorder(new LineBorder(Color.black, 2));
tf45.setBorder(new LineBorder(Color.black, 2));
tf46.setBorder(new LineBorder(Color.black, 2));
tf47.setBorder(new LineBorder(Color.black, 2));
tf48.setBorder(new LineBorder(Color.black, 2));
tf49.setBorder(new LineBorder(Color.black, 2));
tf50.setBorder(new LineBorder(Color.black, 2));
tf51.setBorder(new LineBorder(Color.black, 2));
tf52.setBorder(new LineBorder(Color.black, 2));
tf53.setBorder(new LineBorder(Color.black, 2));
tf54.setBorder(new LineBorder(Color.black, 2));
tf55.setBorder(new LineBorder(Color.black, 2));
tf56.setBorder(new LineBorder(Color.black, 2));
tf57.setBorder(new LineBorder(Color.black, 2));
tf58.setBorder(new LineBorder(Color.black, 2));
tf59.setBorder(new LineBorder(Color.black, 2));
tf60.setBorder(new LineBorder(Color.black, 2));
tf61.setBorder(new LineBorder(Color.black, 2));
tf62.setBorder(new LineBorder(Color.black, 2));
tf63.setBorder(new LineBorder(Color.black, 2));
tf64.setBorder(new LineBorder(Color.black, 2));
tf65.setBorder(new LineBorder(Color.black, 2));
tf66.setBorder(new LineBorder(Color.black, 2));
tf67.setBorder(new LineBorder(Color.black, 2));
tf68.setBorder(new LineBorder(Color.black, 2));
tf69.setBorder(new LineBorder(Color.black, 2));
tf70.setBorder(new LineBorder(Color.black, 2));
tf71.setBorder(new LineBorder(Color.black, 2));
tf72.setBorder(new LineBorder(Color.black, 2));
tf73.setBorder(new LineBorder(Color.black, 2));
tf74.setBorder(new LineBorder(Color.black, 2));
tf75.setBorder(new LineBorder(Color.black, 2));
tf76.setBorder(new LineBorder(Color.black, 2));
tf77.setBorder(new LineBorder(Color.black, 2));
tf78.setBorder(new LineBorder(Color.black, 2));
tf79.setBorder(new LineBorder(Color.black, 2));
tf80.setBorder(new LineBorder(Color.black, 2));
tf81.setBorder(new LineBorder(Color.black, 2));
// adding buttons to the frame
field.add(p);
field.add(tf1);
field.add(tf2);
field.add(tf3);
field.add(tf4);
field.add(tf5);
field.add(tf6);
field.add(tf7);
field.add(tf8);
field.add(tf9);
field.add(tf10);
field.add(tf11);
field.add(tf12);
field.add(tf13);
field.add(tf14);
field.add(tf15);
field.add(tf16);
field.add(tf17);
field.add(tf18);
field.add(tf19);
field.add(tf20);
field.add(tf21);
field.add(tf22);
field.add(tf23);
field.add(tf24);
field.add(tf25);
field.add(tf26);
field.add(tf27);
field.add(tf28);
field.add(tf29);
field.add(tf30);
field.add(tf31);
field.add(tf32);
field.add(tf33);
field.add(tf34);
field.add(tf35);
field.add(tf36);
field.add(tf37);
field.add(tf38);
field.add(tf39);
field.add(tf40);
field.add(tf41);
field.add(tf42);
field.add(tf43);
field.add(tf44);
field.add(tf45);
field.add(tf46);
field.add(tf47);
field.add(tf48);
field.add(tf49);
field.add(tf50);
field.add(tf51);
field.add(tf52);
field.add(tf53);
field.add(tf54);
field.add(tf55);
field.add(tf56);
field.add(tf57);
field.add(tf58);
field.add(tf59);
field.add(tf60);
field.add(tf61);
field.add(tf62);
field.add(tf63);
field.add(tf64);
field.add(tf65);
field.add(tf66);
field.add(tf67);
field.add(tf68);
field.add(tf69);
field.add(tf70);
field.add(tf71);
field.add(tf72);
field.add(tf73);
field.add(tf74);
field.add(tf75);
field.add(tf76);
field.add(tf77);
field.add(tf78);
field.add(tf79);
field.add(tf80);
field.add(tf81);
}
public static void main(String[] args) {
new Sudokuu();
}
}
CodePudding user response:
Thx nili for your help. I named it out now..how can i take two Layouts together in one Frame...i want the "Easy" "Medium" buttons above and the Textfields in an other Layout underneath..
`panel.add(one);
panel.add(easy);
panel.add(medium);
panel.add(hard);
`
CodePudding user response:
Let's first talk about how you can improve your code.
- Don't duplicate your code. (In this case, use a loop)
- Don't put everything in the constructor.
- Give your components (i.e JButtons, JPanel, etc) good names that are easier to remember and not single variables.
Belief explanation.
Instead of creating, setting the border, and adding JTextFields to the panel separately. In this case 82 times. Use a
for
loop. Avoid duplicate code to keep your code clean and more OO.for (int x=0; x<=82; x ){ JTextField textField = new JTextField("",1); textField.setBorder(new LineBorder(Color.black, 2)); field.add(textField);
Use a constructor if you want to initialize values for an object or read the doc for more information.
Naming your JButton "o", "p", etc will only create confusion. Name then more generic, like oneStep, easy, etc.
Now let's talk about some redundant code.
JPanel p = new JPanel();
p.setBorder(BorderFactory.createLineBorder(Color.cyan));
p.setSize(700,50);
p.setVisible(true);
p.setLayout(new FlowLayout());
There is no need to call JPanel's setVisible method because you will add it to the frame. Setting the size of the JPanel is kind-off redundant, cause the frame's layout manager will likely gonna ignore it.
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
public class Sudokuu {
JFrame frame;
JPanel mainPanel;
public static void main(String[] args) {
new Sudokuu().buildGUI();
}
private void buildGUI(){
frame = new JFrame("Sudoku");
mainPanel = new JPanel();
mainPanel.setBorder(BorderFactory.createLineBorder(Color.cyan));
JButton oneStep = new JButton("One Step");
oneStep.setSize(200,50);
JButton Easy = new JButton("Easy");
Easy.setSize(200,50);
JButton medium = new JButton("Medium");
medium.setSize(200,50);
JButton hard = new JButton("Hard");
hard.setSize(200,50);
mainPanel.add(oneStep);
mainPanel.add(Easy);
mainPanel.add(medium);
mainPanel.add(hard);
JPanel field = new JPanel();
field.setLayout (new GridLayout(9,9));
frame.add(BorderLayout.NORTH,mainPanel);
for (int x=0; x<=82; x ){
JTextField textField = new JTextField("",1);
textField.setBorder(new LineBorder(Color.black, 2));
field.add(textField);
}
frame.add(BorderLayout.CENTER, field);
frame.setVisible(true);
frame.setSize(1920,1000);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}```
Also, first, create the JTextFields then add them to the JPanel. Run this code or see the image below is this want you want?
CodePudding user response:
f.setVisible(true);
This should be the last line in the Sudokuu
constructor.
f.add(p);
This means you are adding p
to the center of f
. You wrote in your question that p
should appear above the Sudoku board (which is field
in your code). Hence you should chenge the above line to:
f.add(p, BorderLayout.PAGE_START);
You are also adding p
to field
.
field.add(p);
You need to remove this line.
field.setLayout(new GridLayout(9, 9));
For GridLayout you only need to set one dimension, so replace the above line with:
field.setLayout(new GridLayout(0, 9));
This ensures that there will be, at most, nine columns in each row of the grid.
f.setLayout(new BorderLayout());
This is not required as BorderLayout
is the default.
field.setVisible(true);
This is not required since visible is true by default.
f.add(field, BorderLayout.CENTER);
Add field
to f
after you have added all the components to field
.
p.setSize(700, 50);
I think it is more correct to set the preferred size, i.e.
p.setPreferredSize(new Dimension(700, 50));
Here is your code with my corrections, as explained above.
import java.awt.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
public class Sudokuu {
public JFrame f;
Sudokuu() {
f = new JFrame("Sudoku");
JPanel p = new JPanel();
p.setBorder(BorderFactory.createLineBorder(Color.cyan));
p.setPreferredSize(new Dimension(700, 50));
p.setVisible(true);
p.setLayout(new FlowLayout());
JButton o = new JButton("One Step");
o.setPreferredSize(new Dimension(200, 50));
JButton e = new JButton("Easy");
e.setPreferredSize(new Dimension(200, 50));
JButton m = new JButton("Medium");
m.setPreferredSize(new Dimension(200, 50));
JButton h = new JButton("Hard");
h.setPreferredSize(new Dimension(200, 50));
p.add(o);
p.add(e);
p.add(m);
p.add(h);
JPanel field = new JPanel();
field.setLayout(new GridLayout(0, 9));
field.setPreferredSize(new Dimension(500, 500));
f.add(p, BorderLayout.PAGE_START);
JTextField tf = new JTextField("", 1);
JTextField tf1 = new JTextField("", 1);
JTextField tf2 = new JTextField("", 1);
JTextField tf3 = new JTextField("", 1);
JTextField tf4 = new JTextField("", 1);
JTextField tf5 = new JTextField("", 1);
JTextField tf6 = new JTextField("", 1);
JTextField tf7 = new JTextField("", 1);
JTextField tf8 = new JTextField("", 1);
JTextField tf9 = new JTextField("", 1);
JTextField tf10 = new JTextField("", 1);
JTextField tf11 = new JTextField("", 1);
JTextField tf12 = new JTextField("", 1);
JTextField tf13 = new JTextField("", 1);
JTextField tf14 = new JTextField("", 1);
JTextField tf15 = new JTextField("", 1);
JTextField tf16 = new JTextField("", 1);
JTextField tf17 = new JTextField("", 1);
JTextField tf18 = new JTextField("", 1);
JTextField tf19 = new JTextField("", 1);
JTextField tf20 = new JTextField("", 1);
JTextField tf21 = new JTextField("", 1);
JTextField tf22 = new JTextField("", 1);
JTextField tf23 = new JTextField("", 1);
JTextField tf24 = new JTextField("", 1);
JTextField tf25 = new JTextField("", 1);
JTextField tf26 = new JTextField("", 1);
JTextField tf27 = new JTextField("", 1);
JTextField tf28 = new JTextField("", 1);
JTextField tf29 = new JTextField("", 1);
JTextField tf30 = new JTextField("", 1);
JTextField tf31 = new JTextField("", 1);
JTextField tf32 = new JTextField("", 1);
JTextField tf33 = new JTextField("", 1);
JTextField tf34 = new JTextField("", 1);
JTextField tf35 = new JTextField("", 1);
JTextField tf36 = new JTextField("", 1);
JTextField tf37 = new JTextField("", 1);
JTextField tf38 = new JTextField("", 1);
JTextField tf39 = new JTextField("", 1);
JTextField tf40 = new JTextField("", 1);
JTextField tf41 = new JTextField("", 1);
JTextField tf42 = new JTextField("", 1);
JTextField tf43 = new JTextField("", 1);
JTextField tf44 = new JTextField("", 1);
JTextField tf45 = new JTextField("", 1);
JTextField tf46 = new JTextField("", 1);
JTextField tf47 = new JTextField("", 1);
JTextField tf48 = new JTextField("", 1);
JTextField tf49 = new JTextField("", 1);
JTextField tf50 = new JTextField("", 1);
JTextField tf51 = new JTextField("", 1);
JTextField tf52 = new JTextField("", 1);
JTextField tf53 = new JTextField("", 1);
JTextField tf54 = new JTextField("", 1);
JTextField tf55 = new JTextField("", 1);
JTextField tf56 = new JTextField("", 1);
JTextField tf57 = new JTextField("", 1);
JTextField tf58 = new JTextField("", 1);
JTextField tf59 = new JTextField("", 1);
JTextField tf60 = new JTextField("", 1);
JTextField tf61 = new JTextField("", 1);
JTextField tf62 = new JTextField("", 1);
JTextField tf63 = new JTextField("", 1);
JTextField tf64 = new JTextField("", 1);
JTextField tf65 = new JTextField("", 1);
JTextField tf66 = new JTextField("", 1);
JTextField tf67 = new JTextField("", 1);
JTextField tf68 = new JTextField("", 1);
JTextField tf69 = new JTextField("", 1);
JTextField tf70 = new JTextField("", 1);
JTextField tf71 = new JTextField("", 1);
JTextField tf72 = new JTextField("", 1);
JTextField tf73 = new JTextField("", 1);
JTextField tf74 = new JTextField("", 1);
JTextField tf75 = new JTextField("", 1);
JTextField tf76 = new JTextField("", 1);
JTextField tf77 = new JTextField("", 1);
JTextField tf78 = new JTextField("", 1);
JTextField tf79 = new JTextField("", 1);
JTextField tf80 = new JTextField("", 1);
JTextField tf81 = new JTextField("", 1);
// Setting the Line
tf.setBorder(new LineBorder(Color.black, 2));
tf1.setBorder(new LineBorder(Color.black, 2));
tf2.setBorder(new LineBorder(Color.black, 2));
tf3.setBorder(new LineBorder(Color.black, 2));
tf4.setBorder(new LineBorder(Color.black, 2));
tf5.setBorder(new LineBorder(Color.black, 2));
tf6.setBorder(new LineBorder(Color.black, 2));
tf7.setBorder(new LineBorder(Color.black, 2));
tf8.setBorder(new LineBorder(Color.black, 2));
tf9.setBorder(new LineBorder(Color.black, 2));
tf10.setBorder(new LineBorder(Color.black, 2));
tf11.setBorder(new LineBorder(Color.black, 2));
tf12.setBorder(new LineBorder(Color.black, 2));
tf13.setBorder(new LineBorder(Color.black, 2));
tf14.setBorder(new LineBorder(Color.black, 2));
tf15.setBorder(new LineBorder(Color.black, 2));
tf16.setBorder(new LineBorder(Color.black, 2));
tf17.setBorder(new LineBorder(Color.black, 2));
tf18.setBorder(new LineBorder(Color.black, 2));
tf19.setBorder(new LineBorder(Color.black, 2));
tf20.setBorder(new LineBorder(Color.black, 2));
tf21.setBorder(new LineBorder(Color.black, 2));
tf22.setBorder(new LineBorder(Color.black, 2));
tf23.setBorder(new LineBorder(Color.black, 2));
tf24.setBorder(new LineBorder(Color.black, 2));
tf25.setBorder(new LineBorder(Color.black, 2));
tf26.setBorder(new LineBorder(Color.black, 2));
tf27.setBorder(new LineBorder(Color.black, 2));
tf28.setBorder(new LineBorder(Color.black, 2));
tf29.setBorder(new LineBorder(Color.black, 2));
tf30.setBorder(new LineBorder(Color.black, 2));
tf31.setBorder(new LineBorder(Color.black, 2));
tf32.setBorder(new LineBorder(Color.black, 2));
tf33.setBorder(new LineBorder(Color.black, 2));
tf34.setBorder(new LineBorder(Color.black, 2));
tf35.setBorder(new LineBorder(Color.black, 2));
tf36.setBorder(new LineBorder(Color.black, 2));
tf37.setBorder(new LineBorder(Color.black, 2));
tf38.setBorder(new LineBorder(Color.black, 2));
tf39.setBorder(new LineBorder(Color.black, 2));
tf40.setBorder(new LineBorder(Color.black, 2));
tf41.setBorder(new LineBorder(Color.black, 2));
tf42.setBorder(new LineBorder(Color.black, 2));
tf43.setBorder(new LineBorder(Color.black, 2));
tf44.setBorder(new LineBorder(Color.black, 2));
tf45.setBorder(new LineBorder(Color.black, 2));
tf46.setBorder(new LineBorder(Color.black, 2));
tf47.setBorder(new LineBorder(Color.black, 2));
tf48.setBorder(new LineBorder(Color.black, 2));
tf49.setBorder(new LineBorder(Color.black, 2));
tf50.setBorder(new LineBorder(Color.black, 2));
tf51.setBorder(new LineBorder(Color.black, 2));
tf52.setBorder(new LineBorder(Color.black, 2));
tf53.setBorder(new LineBorder(Color.black, 2));
tf54.setBorder(new LineBorder(Color.black, 2));
tf55.setBorder(new LineBorder(Color.black, 2));
tf56.setBorder(new LineBorder(Color.black, 2));
tf57.setBorder(new LineBorder(Color.black, 2));
tf58.setBorder(new LineBorder(Color.black, 2));
tf59.setBorder(new LineBorder(Color.black, 2));
tf60.setBorder(new LineBorder(Color.black, 2));
tf61.setBorder(new LineBorder(Color.black, 2));
tf62.setBorder(new LineBorder(Color.black, 2));
tf63.setBorder(new LineBorder(Color.black, 2));
tf64.setBorder(new LineBorder(Color.black, 2));
tf65.setBorder(new LineBorder(Color.black, 2));
tf66.setBorder(new LineBorder(Color.black, 2));
tf67.setBorder(new LineBorder(Color.black, 2));
tf68.setBorder(new LineBorder(Color.black, 2));
tf69.setBorder(new LineBorder(Color.black, 2));
tf70.setBorder(new LineBorder(Color.black, 2));
tf71.setBorder(new LineBorder(Color.black, 2));
tf72.setBorder(new LineBorder(Color.black, 2));
tf73.setBorder(new LineBorder(Color.black, 2));
tf74.setBorder(new LineBorder(Color.black, 2));
tf75.setBorder(new LineBorder(Color.black, 2));
tf76.setBorder(new LineBorder(Color.black, 2));
tf77.setBorder(new LineBorder(Color.black, 2));
tf78.setBorder(new LineBorder(Color.black, 2));
tf79.setBorder(new LineBorder(Color.black, 2));
tf80.setBorder(new LineBorder(Color.black, 2));
tf81.setBorder(new LineBorder(Color.black, 2));
// adding buttons to the frame
field.add(tf1);
field.add(tf2);
field.add(tf3);
field.add(tf4);
field.add(tf5);
field.add(tf6);
field.add(tf7);
field.add(tf8);
field.add(tf9);
field.add(tf10);
field.add(tf11);
field.add(tf12);
field.add(tf13);
field.add(tf14);
field.add(tf15);
field.add(tf16);
field.add(tf17);
field.add(tf18);
field.add(tf19);
field.add(tf20);
field.add(tf21);
field.add(tf22);
field.add(tf23);
field.add(tf24);
field.add(tf25);
field.add(tf26);
field.add(tf27);
field.add(tf28);
field.add(tf29);
field.add(tf30);
field.add(tf31);
field.add(tf32);
field.add(tf33);
field.add(tf34);
field.add(tf35);
field.add(tf36);
field.add(tf37);
field.add(tf38);
field.add(tf39);
field.add(tf40);
field.add(tf41);
field.add(tf42);
field.add(tf43);
field.add(tf44);
field.add(tf45);
field.add(tf46);
field.add(tf47);
field.add(tf48);
field.add(tf49);
field.add(tf50);
field.add(tf51);
field.add(tf52);
field.add(tf53);
field.add(tf54);
field.add(tf55);
field.add(tf56);
field.add(tf57);
field.add(tf58);
field.add(tf59);
field.add(tf60);
field.add(tf61);
field.add(tf62);
field.add(tf63);
field.add(tf64);
field.add(tf65);
field.add(tf66);
field.add(tf67);
field.add(tf68);
field.add(tf69);
field.add(tf70);
field.add(tf71);
field.add(tf72);
field.add(tf73);
field.add(tf74);
field.add(tf75);
field.add(tf76);
field.add(tf77);
field.add(tf78);
field.add(tf79);
field.add(tf80);
field.add(tf81);
f.add(field, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
public static void main(String[] args) {
new Sudokuu();
}
}