public class JframeDemo02 {
public static void main(String[] args) {
new MyJframe2().init();
}
}
class MyJframe2 extends JFrame{
public void init(){
this.setBounds(10,10,200,300);
this.setVisible(true);
JLabel label = new JLabel("欢迎");
this.add(label);
label.setHorizontalAlignment(SwingConstants.CENTER);
Container container = this.getContentPane();
container.setBackground(Color.blue);
}
}
public class JframeDemo02 {
public static void main(String[] args) {
new MyJframe2().init();
}
}
class MyJframe2 extends JFrame{
public void init(){
this.setBounds(10,10,200,300);
this.setVisible(true);
JLabel label = new JLabel("欢迎");
this.add(label);
label.setHorizontalAlignment(SwingConstants.CENTER);
Container container = this.getContentPane();
container.setBackground(Color.blue);
}
}