- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add tooltip to JLabel in Java?
Tooltip is visible whenever you will place the mouse cursor on the label. Use the setToolTipText() method to add tooltip to JLabel −
label.setToolTipText("This is a demo tooltip");
The following is an example to add tooltip to JLabel −
Example
import java.awt.Color; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("Demo Label!"); label.setFont(new Font("Verdana", Font.PLAIN, 14)); label.setToolTipText("This is a demo tooltip"); Border border = BorderFactory.createLineBorder(Color.ORANGE); label.setBorder(border); frame.add(label); frame.setSize(500,300); frame.setVisible(true); } }
Output
- Related Articles
- How to add line border to JLabel in Java?
- How to add a tooltip to a component in Java?
- How to change JLabel font in Java
- How to change JLabel size in Java?
- How to disable a JLabel in Java?
- How to add a tooltip to a div using JavaScript?
- How to align JLabel text vertically top in Java?
- How to set tooltip text for JCheckBox in Java?
- How to change JLabel background and foreground color in Java?
- JavaFX example to add a tooltip to a radio button
- How to change text font for JLabel with HTML in Java?
- How to set location of JLabel in a JFrame with Java?
- How to create a JLabel with an image icon in Java?
- Add arrow in tooltip with CSS
- How to create JLabel to hold multiline of text using HTML in Java?

Advertisements