保留在Java中屏幕的边缘 [英] Reserving the edge of the screen in Java

查看:128
本文介绍了保留在Java中屏幕的边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让一个窗口(如的java.awt.Frame javax.swing.JFrame中的 java.awt.Dialog中的 javax.swing.JDialog中的等)保留屏幕边缘,像一个码头,任务栏,Trillian的,或者微软的OneNote可以吗?我的目标是如果可能的话,只使用标准的JDK库。

How can I make a window (such as a java.awt.Frame, javax.swing.JFrame, java.awt.Dialog, javax.swing.JDialog, etc.) reserve the edge of the screen, like a dock, taskbar, Trillian, or Microsoft OneNote can? I aim to only use standard JDK libraries if possible.

推荐答案

此行​​为是非常具体的Windows操作系统,因此没有办法在标准JDK或AWT / Swing的做到这一点,因为这些需要在多个不同的操作系统一致地工作。

This behaviour is very specific to the Windows operating system, and as such there is no way to do this in the standard JDK or with AWT/Swing, since these need to work consistently across a number of different operating systems.

最接近相当于你想要的是得到当前屏幕的界限,移动/调整你的窗口,以适应反冲洗一面,虽然这现在有桌面或其他窗口上的任何影响。

The closest equivalent to what you want is to get the current screen's boundaries and move/resize your window to fit flush against one side, although this will now have any effect on the desktop or other windows.

您可能会得到你想要的最接近的是使用 JNIWrapper和WinPack 改变了天然窗口行为。他们的文件没有显示有关桌面工具栏任何东西,但。你可能将不得不使用自己的JNI来直接访问特定的COM功能,然后找出如何做到这一点在C ++中,但如果你不知道C ++,这可能是你的项目的范围。

The closest thing you will probably get to what you want is by using JNIWrapper and WinPack to alter the native window behaviour. Their documentation doesn't show anything about desktop toolbars, though. You would probably have to use their JNI to access the specific COM functions directly and then find out how to do it in C++, but if you don't know C++, that's probably out of the scope of your project.

附录:

如果你想使用特定的操作系统和桌面管理器的原生功能,您将需要用的原始的C ++库连接挂接到GNOME,KDE的Mac OS等搜索对于公司的Java JNI和窗口系统要与集成,以找到可以使用的包。例如,对于侏儒,请参见这里

If you want to make use of the native features for specific operating systems and desktop managers, you will need to connect with a native C++ library to hook into Gnome, KDE, Mac OS etc. Search for 'Java JNI' and the windowing system you want to integrate with to find packages you can use. For instance, for Gnome, see here.

如果你想支持多种操作系统,请确保您创建一个通用的接口让你可以与相应的JNIs取决于连接实现对哪一个是在运行时可用,并允许回退,如果他们都不是可用的。

If you want to support multiple operating systems, make sure you create a common interface so you can make implementations that connect with the respective JNIs depending on which one is available at runtime, and allow fallback if none of them are available.

PS。如果你想在你的应用程序弹出通知,Mac OS和Linux的各种支持建立这样的低吼,可以节省您的时间。

PS. If you want popup notifications in your app, Mac OS and various Linux builds support Growl so that can save you some time.

这篇关于保留在Java中屏幕的边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆