I am trying to make a Connect Four game with java swing, but I am getting an error with my attempt at making an multi D panel maker when I try to run it.
Any and all help would be awesome
import javax.swing.*; import java.awt.Color; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class ConnectFour implements ActionListener{ JPanel buttonPanel; JButton OneButton, TwoButton, ThreeButton, FourButton, FiveButton, SixButton, SevenButton; int a=0, b=0; public JPanel createContentPane (){ JPanel totalGUI = new JPanel(); totalGUI.setLayout(null); buttonPanel = new JPanel(); buttonPanel.setLayout(null); buttonPanel.setLocation(10, 10); buttonPanel.setSize(780, 40); totalGUI.add(buttonPanel); JPanel panelForPanels = new JPanel(); panelForPanels.setLayout(null); panelForPanels.setLocation(10, 40); panelForPanels.setSize(780, 670); totalGUI.add(panelForPanels); //something right under this is wrong :( for( int x = 0; x < 6; x = x++){ for( int y = 0; y < 5; y = y++){ JPanel blackPanel[][] = new JPanel[6][5]; blackPanel[x][y].setBackground(Color.black); blackPanel[x][y].setLocation(b,a); blackPanel[x][y].setSize(100,100); panelForPanels.add(blackPanel[x][y]); a=a+110; } a=0; b=b+110; } OneButton = new JButton("DropHere"); OneButton.setLocation(0, 0); OneButton.setSize(100, 30); OneButton.addActionListener(this); buttonPanel.add(OneButton); TwoButton = new JButton("DropHere"); TwoButton.setLocation(110, 0); TwoButton.setSize(100, 30); TwoButton.addActionListener(this); buttonPanel.add(TwoButton); ThreeButton = new JButton("DropHere"); ThreeButton.setLocation(220, 0); ThreeButton.setSize(100, 30); ThreeButton.addActionListener(this); buttonPanel.add(ThreeButton); ThreeButton = new JButton("DropHere"); ThreeButton.setLocation(330, 0); ThreeButton.setSize(100, 30); ThreeButton.addActionListener(this); buttonPanel.add(ThreeButton); FourButton = new JButton("DropHere"); FourButton.setLocation(440, 0); FourButton.setSize(100, 30); FourButton.addActionListener(this); buttonPanel.add(FourButton); FiveButton = new JButton("DropHere"); FiveButton.setLocation(550, 0); FiveButton.setSize(100, 30); FiveButton.addActionListener(this); buttonPanel.add(FiveButton); SixButton = new JButton("DropHere"); SixButton.setLocation(660, 0); SixButton.setSize(100, 30); SixButton.addActionListener(this); buttonPanel.add(SixButton); SevenButton = new JButton("DropHere"); SevenButton.setLocation(770, 0); SevenButton.setSize(100, 30); SevenButton.addActionListener(this); buttonPanel.add(SevenButton); totalGUI.setOpaque(true); return totalGUI; } public void actionPerformed(ActionEvent e) { } private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("[=] Connect Four! [=]"); ConnectFour demo = new ConnectFour(); frame.setContentPane(demo.createContentPane()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1060, 800); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }