开发者

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

开发者 https://www.devze.com 2023-03-10 01:37 出处:网络
I want to see the text of JLabel when I hover over the label. The text explains what the lab开发者_JAVA百科el does in detail.You would need to set the text of the tooltip by calling: setToolTipText()

I want to see the text of JLabel when I hover over the label. The text explains what the lab开发者_JAVA百科el does in detail.


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");
0

精彩评论

暂无评论...
验证码 换一张
取 消