Coding child
Coding child

Reputation: 155

How to create popup hint window like Quick Doc in Intellij Idea?

I am developing a simple swing application and I would like to have something which can help user with it. As example a little popup window will appear over "Start" button when user runs app first time and say "Hey, click here to start playing with me!"

Do you know the way to create something like quick doc in Intellij Idea? Could you please put me on the right way to sources, examples, source codes or anything else which could be useful? Below is example of how it can look like enter image description here

PS. I have updated the picture.

Upvotes: 3

Views: 1281

Answers (2)

Sergiy Medvynskyy
Sergiy Medvynskyy

Reputation: 11327

As I said in the comment use javax.swing.PopupFactory to show popup for any component (which is probably not pointed by the mouse)

Popup p = PopupFactory.getSharedInstance().getPopup(component, new JLabel("It's a hint!"), 5, 5);
p.show();

component is the widget for which the popup must be shown.

You can also use the javax.swing.Timer to hide this popup automatically.

Upvotes: 4

jluckin
jluckin

Reputation: 662

Tooltips are used in Swing to give the hover-over text that you are looking for. It is very easy to use a tooltip, all you have to do is set the tooltip text on your button

btnStart.setToolTipText("Hey, click here to start playing with me!");

Here is a pretty useful guide that explains the topic in more depth http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html

Upvotes: 0

Related Questions