Search code examples
javabuttonnetbeans-8

Java: Show label when cursor hovered in a button


I'm currently working on a project in Java Netbeans but I don't know how to add label in a button when hovered. It will look like this:

enter image description here

So when I hovered my cursor on a button it will show a label. Sorry if I can't show any code because I don't have any idea on how to implement it. Any ideas?


Solution

  • You can use setToolTipText

    Example:

    JButton button = new JButton("Click Me");
    button.setToolTipText("Click this button to make something happen.");
    

    Refer here