Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Set tooltip for button

import javax.swing.JButton; import javax.swing.JFrame; public class JButtonWithTooltip extends JFrame {   public JButtonWithTooltip() {     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     JButton b = new JButton("Test");     b.setToolTipText("Help text for the button");     getContentPane().add(b, "Center");     pack();   }   public static void main(String[] args) {     new JButtonWithTooltip().setVisible(true);   } }