2021-05-27
作者:互联网
标签居中
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); } }
标签:27,container,MyJframe2,05,label,init,2021,JLabel,public 来源: https://blog.csdn.net/jishuxiaobai321/article/details/117318903