import javax.swing.*;
import java.awt.*;
/**
* @author 许泽鑫
* @data 2019/11/8 - 17:28
*/
public class Demo3 extends JFrame {
public Demo3() {
setBounds(700, 400, 400, 300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c = getContentPane();
setVisible(true);
JLabel l = new JLabel("这是一个标签");
c.add(l);
l.setText("更改标签内容");
System.out.println(l.getText());
l.setFont(new Font("微软雅黑", Font.BOLD, 15));
l.setForeground(Color.red);//更改前景色,更改字体颜色
}
public static void main(String[] args) {
new Demo3();
}
}
标签的使用
最新推荐文章于 2023-08-20 20:27:32 发布