一个菜鸟问题
刚学用Java做图形界面,我用的是MyEclipse,软件没什么问题,刚开始的几个小程序也没问题,但到这个以后总显示红色的那一行是Unreachable code,请大仙们帮偶看看错在哪儿( TestPannels 我拼错了,但不影响),
控制台的信息我也打出来了,谢谢。
import java.awt.*;
import javax.swing.*;
public class TestPannels extends JFrame {
public TestPannels(){
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JButton bt = new JButton();
p1.setLayout(new GridLayout(4,3));
p2.setLayout(new BorderLayout());
for(int i=1;1<=9;i++)
p1.add(new JButton(""+i));
p1.add(bt);
p1.add(bt);
p1.add(bt);
p2.add(p1,BorderLayout.CENTER);
p2.add(new JTextField("12345"),BorderLayout.NORTH);
c.add(p2,BorderLayout.EAST);
c.add(new JButton(),BorderLayout.CENTER);
}
public static void main(String[] args) {
TestPannels f = new TestPannels();
f.setTitle("TestPannels");
f.setSize(400,300);
f.setLocation(300,300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unreachable code
at mj2.TestPannels.<init>([color=#0000FF]TestPannels.java:16)
at mj2.TestPannels.main(TestPannels.java:24)[/color]