package Myself;
import java.awt.Container;
import javax.swing.*;
public class Test1 extends JFrame {
public Test1(){
Container c=new Container();
JButton jb3=new JButton("这是一个按钮");
c.add(jb3);
setSize(300,200);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Test1();
}
}
为什么在窗体中按钮不显示呢,求各位大神给予解答解答!
关于java中的JButton
------解决方案--------------------
Container c=getContentPane();
public Container getContentPane()
Returns the contentPane object for this frame.