chuz696
chuz696

Reputation: 13

Is there a way to show a popup like a "cloud" when you passed your mouse over a textfield in Java?

I'm looking for a way to display a baloon tip when i mouse-over a textfield in Java, for example to guide the user in the way to put some specific data: ID: 0-0000-000 or something like that...

Is there a way to do that, other than jOptionPane?

Upvotes: 1

Views: 167

Answers (2)

Rahul
Rahul

Reputation: 45060

You can use the JtextField#setToolTipText(tipText) method for that(note that JTextField extends JTextComponent which extends JComponent).

String toolTip = "Welcome";
myTextField.setToolTipText(toolTip);

Have a look at the javadocs for detailed explanation on using ToolTips.

Upvotes: 3

K Mehta
K Mehta

Reputation: 10553

I'm guessing you're looking for a way to add a tooltip? Try this:

// A textfield with tooltip that provides help text
JTextField textfield = new JTextField();
textfield.setToolTipText("<your help string here>");

Upvotes: 4

Related Questions