import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Screen implements ActionListener { JButton[][] b=new JButton[200][200]; Screen() { JFrame j = new JFrame("A Star Algorithm"); j.setSize(700,500); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setLayout(new GridLayout(20,20)); j.setResizable(true); //create Buttons for(int row=0;row<200;row++) { for(int col=0;col<200;col++) { b[row][col]=new JButton(); j.add(b[row][col]); b[row][col].addActionListener(this); } } j.setVisible(true); } public void actionPerformed(ActionEvent e) { } }
I am trying to program an A* algorithm and I cannot even get past the buttons. I need a 2D array of buttons to handle this problem but I am getting the following errors.
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)