javaGUI 中继承 JPanel 的问题
献上代码 package cn.seu.ecampus.ServerView;
import java.awt.BorderLayout;
import java.
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import cn.seu.ecampus.ServerControl.SControl;
public class SBankView extends JPanel{
SControl sc;
public JButton add;
public JButton delete;
public JTable table;
public SBankView(SControl sc){
super();
this.sc = sc;
init();
}
private void init() {
setSize(570,410);
// setLocation(ViewTool.getLocation(800,600));
// setTitle("银行管理");
// setDefaultCloseOperation(EXIT_ON_CLOSE);
// setContentPane(createPane());
setOpaque(false);
setLayout(null);
setVisible(true);
add(createPane(),BorderLayout.CENTER);
}
private Container createPane() {
JPanel jp = new JPanel(new BorderLayout());
jp.add(createNorthPane(), BorderLayout.CENTER);
jp.add(createSouthPane(), BorderLayout.SOUTH);
jp.setOpaque(false);
System.out.println(1);
return jp;
}
private Component createSouthPane() {
JPanel jp = new JPanel(new FlowLayout());
JButton fresh = new JButton("刷新信息");
jp.setOpaque(false);
System.out.println(2);
return jp;
}
private Component createNorthPane() {
JPanel jp = new JPanel(new BorderLayout());
JPanel left = new JPanel(new GridLayout(2,1));
JPanel right = new JPanel(new BorderLayout());
jp.setOpaque(false);
left.setOpaque(false);
right.setOpaque(false);
add = new JButton("添加账户");
delete = new JButton("删除账户");
add.setEnabled(false);
delete.setEnabled(false);
left.add(add);
left.add(delete);
String[] cols = {"户主姓名","账号","账户余额"};
table = new JTable(new MyTableModel(sc,cols, "bank"));
right.add(table);
System.out.println(3);
return jp;
}
}
然后再另一个继承JFrame的类中用setcontpane()中加上new 的这个实例化,结果显示一片灰色,什么组件都没有,求大神解答。