我的代碼編譯但是當我運行它時,彈出一個奇怪的錯誤消息。StackOverflow運行時出錯
錯誤消息說
"java.lang.StackOverflowError:null(in sun.awt.Win32GraphicsConfig).
什麼它應該做的是打印出一個按鈕排列的4×10面板用按鈕列出所有存儲的信息爲止。按鈕現在不做任何事情,但沒關係,因爲我現在只關心實際的圖形。還有另一個類用於數組列表,如果需要的話我可以將它放在註釋中。
下面是代碼:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.*;
import java.io.File;
import java.io.PrintWriter;
public class CulminatingProjectGUI extends JFrame implements ActionListener
{
private static JButton[][] jbtNumButtons = new JButton[10][4];
private static JButton jbtList = new JButton("List");
ArrayList<Culminating> seats = new ArrayList<Culminating>();
public CulminatingProjectGUI()
{
//Construct JFame object as a container for other objects
JFrame frame = new JFrame("Fly By Buddies");
//Set the dimensions of the window
frame.setSize(750, 720);
//Creates a pane for content
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(11, 4));
jbtList.addActionListener(new CulminatingProjectGUI());
for (int m = 1,n = 1; n < 11;)
{
jbtNumButtons[n][m].addActionListener(new CulminatingProjectGUI());
if(n == 1)
{
jbtNumButtons[n][m].setText(m + "A");
}
else if(n == 2)
{
jbtNumButtons[n][m].setText(m + "B");
}
else if(n == 3)
{
jbtNumButtons[n][m].setText(m + "C");
}
else if(n == 4)
{
jbtNumButtons[n][m].setText(m + "D");
}
pane.add(jbtNumButtons[n][m]);
m++;
if(m > 4)
{
n++;
m = 0;
}
}
//add content pane to a frame
pane.add(jbtList);
frame.setContentPane(pane);
//Display the frame - window
frame.setVisible(true);
//Bring the window to front
frame.toFront();
}
public static void main(String []args)
{
CulminatingProjectGUI frame = new CulminatingProjectGUI();
//Create seat array. Still testing.
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("List"))
{
String listedFlyers = "";
for (int h =0;h< 40;h++)
{
listedFlyers = listedFlyers + seats.get(h).toString() + "\n";
}
JTextArea text = new JTextArea(listedFlyers, 10, 40);
JScrollPane scroll = new JScrollPane(text);
}
else if (e.getActionCommand().equals(""))
{
}
}
}
這是整個錯誤消息? –
是的,這是整個錯誤信息 –