Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.util.ArrayList;
- public class Window extends JFrame {
- private ArrayList<ArrayList<JButton>> fields = new ArrayList<>();
- private JButton start = new JButton("start");
- void gameSetup() {
- start.setVisible(false);
- for(int i = 0; i < 9; i++) {
- fields.add(new ArrayList<>());
- for(int j = 0; j < 9; j++) {
- fields.get(i).add(new JButton("A"));
- fields.get(i).get(j).setBounds(j*50, i*50, 49, 49);
- fields.get(i).get(j).setVisible(true);
- add(fields.get(i).get(j));
- System.out.println(i + " " + j);
- }
- }
- }
- Window() {
- super("GUI");
- setSize(500, 500);
- setLayout(null);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setVisible(true);
- start.setBounds(100, 100, 200, 30);
- add(start);
- start.addActionListener(e -> {
- gameSetup();
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement