JLabel label =new JLabel();
//设置标签文本
label.setText("标签组件");
// 设置文本水平居中
label.setHorizontalTextPosition(SwingConstants.CENTER);
// 设置文本上下居中
label.setVerticalTextPosition(SwingConstants.CENTER);
//设置字体
label.setFont(new Font("微软雅黑",Font.BOLD|Font.ITALIC,20));
//设置字体颜色
label.setForeground(Color.GREEN);
// 设置图片
//label.setIcon(new ImageIcon(HelloWorld.class.getResource("/images/book.png")));
//设置鼠标放置在标签上显示不同的鼠标形状
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
//设置悬浮文本小框
label.setToolTipText("这是一个Tip");