0
나는이 코드를 가지고있다. (예, 나는 초보자이다.)하지만 JTable은 보여주지 않는다. 패널을 만들기 전에 (아직 데이터 모델을 만들지 않았기 때문에) 마젠타 상자를 볼 수있었습니다.JTable이 보이지 않는 이유는 무엇입니까?
그러나 패널을 추가 한 후, 그것은 사라졌습니다. 아무도 그 이유를 말할 수 있습니까?. 미리 감사드립니다.
public Ost() {
super();
JTable table;
OstBridge bridge;
JButton btn;
JPanel p1=new JPanel(new FlowLayout());
JPanel p2=new JPanel(new FlowLayout());
Container cp=getContentPane();
cp.setLayout(new BoxLayout(cp,BoxLayout.Y_AXIS));
p1.setBorder(BorderFactory.createTitledBorder("Panel 1"));
p2.setBorder(BorderFactory.createTitledBorder("Panel 2"));
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setSize(320, 240);
this.setTitle("OST - Downloader");
//this.setLayout(new FlowLayout());
cp.add(p1);
cp.add(p2);
table=new JTable();
table.setBackground(new Color(0xFF00FF));
table.setSize(100, 100);
table.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
p2.add(table);
bridge=new OstBridge();
btn=new JButton("Prueba");
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("Action event");
System.out.println(e);
System.out.println(bridge);
new Ost();
}
});
p1.add(btn);
p1.setVisible(true);
this.pack();
this.setVisible(true);
}