简体   繁体   English

如何在Intellij Idea中创建像Quick Doc这样的弹出提示窗口?

[英]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. 我正在开发一个简单的swing应用程序,我想提供一些可以帮助用户的应用程序。 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? 您知道在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 以下是其外观的示例 在此处输入图片说明

PS. PS。 I have updated the picture. 我已经更新了图片。

As I said in the comment use javax.swing.PopupFactory to show popup for any component (which is probably not pointed by the mouse) 正如我在评论中所说的,使用javax.swing.PopupFactory来显示任何组件的弹出窗口(鼠标可能没有指出)

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. component是必须为其显示弹出窗口的小部件。

You can also use the javax.swing.Timer to hide this popup automatically. 您也可以使用javax.swing.Timer自动隐藏此弹出窗口。

Tooltips are used in Swing to give the hover-over text that you are looking for. 在Swing中使用工具提示来提供您要查找的悬停文本。 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 这是一个非常有用的指南,可以更深入地说明该主题http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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