java.lang.StackOverflowError
当我运行此代码时,我得到了:
Map<JButton, Integer> buttons = new HashMap<JButton, Integer>();
JPanel main = new JPanel(new GridLayout(4, 4, 4, 4));
for(int i = 0; i < 16; i++) {
JButton jb = new JButton(i+"");
jb.addActionListener(new MyActionListener());
switch(i) {
case 0:
jb.setText("1");
case 1:
jb.setText("2");
case 2:
jb.setText("3");
(...)
case 15:
jb.setText("/");
}
buttons.put(jb, i);
main.add(jb);
}
this.getContentPane().add(main);
为什么会发生这种错误?我该如何解决?谢谢。