用Java在窗口外面绘图?
是否可以在 Java 中简单地使用 paint()
(或使用其他函数)到屏幕?就像在屏幕本身的某些坐标上绘制其他所有内容一样,而不是在某些窗口内。
如果没有,是否可以制作一个占据整个屏幕的隐形窗口并使用其玻璃板来做到这一点?这样做会引起并发症吗? (比如无法点击其他应用程序)
还有其他办法吗?
谢谢。
编辑:顺便说一句,我并不想用它来全屏显示。
Is it possible to simply paint()
(or use some other function) to the screen in Java? As in draw over everything else on some coordinates of the screen itself, not inside some window.
If not, is it possible to make an invisible window that takes up the entire screen and use its glass pane to do it? Would complications arise from doing this? (Such as not being able to click on other applications)
Are there any other ways?
Thanks.
Edit: I'm not trying to do full screen with this, by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您在 Java 中
paint()
时,您仅在所paint()
对象的大小和位置范围内进行绘制。如果您想要进行全屏操作,可以参考相关教程:
http://download.oracle.com/javase/tutorial/extra/fullscreen/index.html
When you
paint()
in Java, you're painting only within the confines of the size and location of what is beingpaint()
ed.If you're looking to do full screen stuff, there are tutorials for that:
http://download.oracle.com/javase/tutorial/extra/fullscreen/index.html
理论上,您可以创建一个透明的未修饰的最大化 JFrame。这将允许您在桌面上“绘画”。问题很明显:如果应用程序停留在该窗口后面,它将不会收到任何鼠标事件。
几个月前,我做了一个邪恶的作弊,直接在 Windows 资源管理器的桌面上绘图:将一些 .NET 编码与 JNI 和 Sun 的内部类混合 - 这很超现实,但很有效。
In theory, you can create an transparent undecorated maximized JFrame. This will allow you to "paint" over the desktop. Problems are obvious: if an application stays behind this window, it will not receive any mouse events.
Months ago, I made an evil cheat to draw directly on Windows Explorer's Desktop: mixing some .NET coding with JNI and Sun's internal classes - that's surreal, but works.