import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class GUI { static int x =9; static int y =9; static JButton polje[][]= new JButton[x][y]; public static void main(String[] args) { //naredimo okvir JFrame okvir = new JFrame(); okvir.setSize(800, 600); okvir.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //naredimo panel JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); //naredimo dva gumba JButton gumb = new JButton("New game"); JButton gumb2 = new JButton("Save game"); gumb2.setEnabled(false); JButton gumb3 = new JButton("Load game"); //dodamo gumba na panel panel.add(gumb); panel.add(gumb2); panel.add(gumb3); //zalepimo panel na okvir okvir.add(panel, BorderLayout.NORTH); gumb3.setBackground(Color.blue); gumb3.setForeground(Color.white); JPanel center = new JPanel(); center.setLayout(new GridLayout(x, y)); Poslusalec poslusalec = new Poslusalec(); for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { JButton b = new JButton(i +","+j); b.addActionListener(poslusalec); polje[i][j] = b; center.add(b); } } okvir.add(center, BorderLayout.CENTER); polje[3][7].setEnabled(false); polje[3][7].setBackground(Color.black); okvir.setVisible(true); } }