import javax.swing.*;
import java.awt.*;
public class JFramemy01 {
public static void main(String[] args) {
new MyJframe2().init();
}
}
class MyJframe2 extends JFrame{
public void init(){
this.setBounds(100,100,200,300);
this.setVisible(true);
JLabel label=new JLabel("!!!!!!");
this.add(label);
//获得容器
Container container=this.getContentPane();
container.setBackground(Color.cyan);
}
}
import javax.swing.*;
import java.awt.*;
public class JFramemy02 {
public static void main(String[] args) {
new MyJframe3().init();
}
}
class MyJframe3 extends JFrame{
public void init(){
this.setBounds(100,100,200,300);
this.setVisible(true);
JLabel label=new JLabel("!!!!!!");
this.add(label);
//center
label.setHorizontalAlignment(SwingConstants.CENTER);
//获得容器
Container container=this.getContentPane();
container.setBackground(Color.cyan);
}
}