Create HTML 3.2 formatted text tooltip in Java
Description
The following code shows how to create HTML 3.2 formatted text tooltip.
Example
// w w w .j av a2 s . com
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolTip;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton b = new JButton("Hello, World");
frame.add(b,"Center");
b.setToolTipText("<html>asdf<b>bold</b></html>");
frame.setSize(300, 200);
frame.setVisible(true);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »