使Java应用程序对用户不可见

编程入门 行业动态 更新时间:2024-10-13 12:24:27
本文介绍了使Java应用程序对用户不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正试图找出一种让用户看不到Java应用程序的方法。

I'm trying to figure out a way to make a Java application invisible to the user.

基本上只是想删除这个

< - 图片

<- 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); } }

推荐答案

我似乎已经找到了答案,只需将行 setVisible(false); 放入注释中,您将看到实际的程序,UNCOMMENT该行看不到任何痕迹,据我所知,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.

import javax.swing.*; public class TransparentWindow extends JFrame { public TransparentWindow() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { setExtendedState(JFrame.MAXIMIZED_BOTH); setResizable(false); setUndecorated(true); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true); setOpacity(0.8f); setSize(200, 200); //System.setProperty("sun.java2d.noddraw", "true"); //WindowUtils.setWindowTransparent(this, true); //WindowUtils.setWindowAlpha(this, 0.6f); setVisible(true); setVisible(false); JOptionPane.showMessageDialog(this, "It is working!", "Guess : ", JOptionPane.INFORMATION_MESSAGE); } public static void main(String[] args) { TransparentWindow tw = new TransparentWindow(); } }

以下是运行此程序时桌面的快照,请参阅任务栏

Here is a snapshot of my desktop on running this program, see the taskbar

更多推荐

使Java应用程序对用户不可见

本文发布于:2023-11-24 00:21:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   用户   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!