Swing-JFrame
public class JFrameDemo {//init();初始化public void init(){//顶级窗口JFrame Jf = new JFrame();Jf.setVisible(true);Jf.setBounds(00,100,200,200);Jf.setBackground(Color.cyan);//设置文字 JlabelJLabel label = new JLabel("欢迎进入");Jf.add(label);//获得一个容器Jf.getContentPane().setBackground(Color.cyan);//让文本标签居中 设置水平对齐label.setHorizontalAlignment(SwingConstants.CENTER);//关闭事件Jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}public static void main(String[] args) {//建立一个窗口new JFrameDemo().init();} }