Type CENTER cannot be resolved or is not a field

我刚学java,求助:编译报错:Type CENTER cannot be resolved or is not a field
报错代码为: getContentPane().add(p1, BorderLayout.NORTH);
getContentPane().add(p2, BorderLayout.SOUTH);
getContentPane().add(new JScrollPane(tbl), BorderLayout.CENTER);
具体全部代码如下:
import javax.swing.*;
import java.awt.*;
class mWin extends JFrame {
JTable tbl;
Object data[][];
Object title[] = {"学号", "姓名", "性别", "出生年月"};
final int ROW = 5;
final int COL = 4;
JPanel p1, p2;
public mWin(String s) {
super(s);
data = new Object[ROW][COL];
for (int i = 0; i < ROW; i++) {
for (int j = 0; j < COL; j++) {
data[i][j] = "";
}
}
tbl = new JTable(data, title);
p1 = new JPanel();
p2 = new JPanel();
p1.add(new JLabel("学生基本信息"));
getContentPane().add(p1, BorderLayout.NORTH);
getContentPane().add(p2, BorderLayout.SOUTH);
getContentPane().add(new JScrollPane(tbl), BorderLayout.CENTER);
setSize(240, 200);
setVisible(true);
validate();
}
}
public static void main(String[] args) {
new mWin("表格的例子");
}
}

查看全部
younglee2013
younglee2013
2014/08/30 12:07
  • java
  • 点赞
  • 收藏
  • 回答
    私信

1个回复