How would I get the text of a JLabel (with an icon) explaining what the label is by hovering over the label?

本小妞迷上赌 提交于 2019-12-01 21:41:19

You would need to set the text of the tooltip by calling: setToolTipText()

More about tooltips in the tutorial: http://download.oracle.com/javase/tutorial/uiswing/components/tooltip.html

If you want to retrieve the Tooltip then you should use something like this:

JLabel label;
...//initialize label, etc
String text = label.getToolTipText();

In case you are asking how to set the Tooltip then you should do the opposite:

JLabel label;
...//initialize label, etc
label.setToolTipText("this is the description of the label");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!