Java- How to set setToolTipText for JFrame(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 获取 JLayeredPane 并调用它的工具提示方法:
Since JFrame doesn't inherit from JComponent, it doesn't have setToolTipText method. Try getting JLayeredPane from JFrame and invoke it's tooltip method:
getLayeredPane().setToolTipText("text");
这篇关于Java-如何为 JFrame 设置 setToolTipText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java-如何为 JFrame 设置 setToolTipText
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
