Java-如何为 JFrame 设置 setToolTipText
我想将鼠标移动到使用 g2D.drawRenderedImag 绘制在 JFrame 上的图像上,并在鼠标光标旁边的工具提示文本中显示该像素的 x、y.即:
I would like to move the mouse over an image which was plotted on a JFrame using g2D.drawRenderedImag and display the x, y of that pixel at the tooltip text right next to mouse cursor. i.e:
Graphics2D g2D = (Graphics2D)g;
g2D.drawRenderedImage...
我知道如何读取 x,y 但不知道如何为 JFrame 设置 setToolTipText.你们能帮帮我吗?我的意思是我不能这样做JFrame.setToolTipText !!!!
I know how to read the x,y but don't know how to set setToolTipText for a JFrame. Can you guys help me please? I mean I can not do like this JFrame.setToolTipText !!!!
推荐答案
由于JFrame
没有继承自JComponent
,所以它没有setToolTipText代码>方法.尝试从
JFrame
获取 JLayeredPan
e 并调用它的工具提示方法:
Since JFrame
doesn't inherit from JComponent
, it doesn't have setToolTipText
method. Try getting JLayeredPan
e from JFrame
and invoke it's tooltip method:
getLayeredPane().setToolTipText("text");
相关文章