使 Java 应用程序对用户不可见
我正在尝试找出一种方法使 Java 应用程序对用户不可见。
基本上只是想删除 这个
<- Image
如何做到这一点?
public class TransparentWindow extends JFrame {
public TransparentWindow() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
setExtendedState(Frame.MAXIMIZED_BOTH);
setResizable(false);
setUndecorated(true);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
setAlwaysOnTop(true);
System.setProperty("sun.java2d.noddraw", "true");
WindowUtils.setWindowTransparent(this, true);
WindowUtils.setWindowAlpha(this, 0.6f);
}
public static void main(String[] args) {
new TransparentWindow().setVisible(true);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我似乎已经找到了答案,只需将
setVisible(false);
行放入注释中,您就会看到实际的程序,据我所知,取消注释该行以查看没有留下任何痕迹看到 Java 程序正在某处运行,直到您不手动将图标添加到系统托盘中。此外,如何从任务管理器中删除您的应用程序,这个问题仍然存在,尽管您可以删除所述图标,正如您在问题中指出的那样。这是我运行该程序时的桌面快照,请参阅任务栏
I just seems to have found the answer, just put the line
setVisible(false);
into comments and you will see the actual program, UNCOMMENT the line to see no trace is left, as far as I can see, that the Java Program is running somewhere, until you won't add the icon to your system tray, manually. Moreover how to remove your Application from Task Manager that question still remains, though you can remove the said icon, as pointed by you in your question.Here is a snapshot of my desktop on running this program, see the taskbar
从
JWindow
扩展而不是JFrame
。 (我没有在 Windows 7 上测试这个,因为我现在没有坐在 Windows 机器前。它适用于 XP,也适用于 Unity,这让我感到惊讶。)Extend from
JWindow
insted ofJFrame
. (I did not test this on Windows 7 as I don't sit in front of a Windows box right now. It worked for XP and works for Unity, which surprised me.)据我所知,没有办法删除任务栏图标。
As far as I know, there is no way to remove the task bar icon.