package cn.rushangw.lesson04;
import javax.swing.*;
import java.awt.*;
public class JFrameDemo02 {
public static void main(String[] args) {
new MyJFrame2().init();
}
}
class MyJFrame2 extends JFrame{
public void init(){
setBounds(1,1,200,200);
setVisible(true);
JLabel jLabel = new JLabel("什么是快乐星球?");
add(jLabel);
//设置水平对齐
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
//获得一个容器
Container contentPane = getContentPane();
contentPane.setBackground(Color.cyan);
}
}