问题
I want to see the text of JLabel when I hover over the label. The text explains what the label does in detail.
回答1:
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
回答2:
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");
来源:https://stackoverflow.com/questions/6209514/how-would-i-get-the-text-of-a-jlabel-with-an-icon-explaining-what-the-label-is