import javax.swing.JButton;
import javax.swing.JFrame;
public class test{
public static void main(String[] args) {
JFrame frame = new JFrame("ToolTip Test");
frame.setSize(280, 180);
frame.setLayout(null);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Test");
button.setBounds(100, 50, 60, 40);
frame.add(button);
String str = "<html>first line<br>second line<br>third line</html>"; //换行显示
button.setToolTipText(str);
frame.setVisible(true);
}
}