Java中 Label中的属性

1:设置字段

Font fon =new Font("宋体", Font.BOLD, 20);

2:创建一个标签

JLabel labone= new JLabel("操作指南");

3:设置它的字体

labone.setFont(fon);

4:设置标签的大小

labone.setBounds(0,0,200,60);

5:设置标签字体的颜色

labone.setForeground(Color.red);

6:设置标准的ICON

ImageIcon image = new ImageIcon("images\\sok0.png");

labone.setIcon(image);

//设置字体的水平方向 与设置内容的垂直方向

  labtwo.setHorizontalAlignment(SwingConstants.LEFT);
  labtwo.setVerticalTextPosition(SwingConstants.BOTTOM);

 

 

 

 

热爱工作,热爱生活,热爱文学