简体   繁体   中英

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:

在此处输入图片说明

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?

You can use setToolTipText

Example:

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

Refer here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM