import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class firstJLabel {
public static void main(String args[]) {
JFrame frame = new JFrame("welcome");//实例化窗口对象
JLabel label = new JLabel("welcome",JLabel.CENTER);//居中
/**
* Italic:斜体
* Bold:加粗
*/
Font font = new Font("Serief",Font.ITALIC+Font.BOLD,30);//字体样式
label.setFont(font);
label.setForeground(Color.ORANGE); //设置字体的颜色
frame.add(label);
Dimension dimension = new Dimension(); //实例化对象
dimension.setSize(300,300);//设置窗口的大小
frame.setSize(dimension);
frame.setBackground(Color.blue); //设置背景颜色
Point point = new Point(300,200); //设置窗口的位置
frame.setLocation(point);
frame.setVisible(true);
}
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class firstJLabel {
public static void main(String args[]) {
JFrame frame = new JFrame("welcome");//实例化窗口对象
JLabel label = new JLabel("welcome",JLabel.CENTER);//居中
/**
* Italic:斜体
* Bold:加粗
*/
Font font = new Font("Serief",Font.ITALIC+Font.BOLD,30);//字体样式
label.setFont(font);
label.setForeground(Color.ORANGE); //设置字体的颜色
frame.add(label);
Dimension dimension = new Dimension(); //实例化对象
dimension.setSize(300,300);//设置窗口的大小
frame.setSize(dimension);
frame.setBackground(Color.blue); //设置背景颜色
Point point = new Point(300,200); //设置窗口的位置
frame.setLocation(point);
frame.setVisible(true);
}
}
ps:这仅仅是个人学习时候所做的笔记,仅供参考