Java JComponent set tooltip text

Description

Java JComponent set tooltip text


import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main extends JFrame {

  public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComponent comp = new JLabel("Test label");
    comp.setToolTipText("Some tooltip text for component");

    getContentPane().add(comp);/*from  w w w.  j av a2s .  com*/
    pack();

    setVisible(true);
  }

  public static void main(String arg[]) {
    new Main();
  }
}



PreviousNext

Related