Java中如何创建多行工具提示?
package org.nhooo.example.swing;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
import java.awt.FlowLayout;
public class MultilineToolTip {
public static void main(String[] args) {
JFrame frame = new JFrame("Tool Tip Demo");
frame.setSize(200, 200);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JLabel label = new JLabel("Hover on me!");
//使用html为我们的SwingJLabel组件设置工具提示
//格式化的字符串,以便我们可以创建多行工具提示。
label.setToolTipText(
"<html>Lorem Ipsum is simply dummy text of the printing and<br/>" +
"typesetting industry. Lorem Ipsum has been the industry's <br/>" +
"standard dummy text ever since the 1500s, when an unknown<br/>" +
"printer took a galley of type and scrambled it to make a<br/>" +
"type specimen book.</html>");
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
frame.getContentPane().add(label);
frame.setVisible(true);
}
}
热门推荐
10 祝福语赠言给老师简短
11 参加儿子大学祝福语简短
12 班级集体生日祝福语简短
13 思念丈夫祝福语简短的话
14 祝福语签名简短大全女生
15 祝寿时祝福语简短精辟
16 父亲祝福语大全简短语
17 六一互换礼物祝福语简短
18 最真的新春祝福语简短