Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Creating HTML 3 2 formatted text tooltip

import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JToolTip; public class ToolTipHTML {   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);   } }