在Eclipse中运行为什么不显示

import java.awt.*;
import javax.swing.*;
public class Example extends JFrame{
public void CreateJFrame(String title){
JFrame jf=new JFrame(title);
Container container=jf.getContentPane();
JLabel jl=new JLabel("这是一个JFrame窗体");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
jl.setVisible(true);
jl.setBackground(Color.white);
jl.setSize(200,150);
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
new Example().CreateJFrame("创建一个JFrame窗体");

}

}

第1个回答  2016-04-22
就是这样的
相似回答