2

我试图找出一种方法使 Java 应用程序对用户不可见。

基本上只是试图删除这个

任务栏图标<- 图片

如何才能做到这一点?

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

3 回答 3

5

我似乎找到了答案,只需将该行setVisible(false);放入注释中,您将看到实际的程序,取消注释该行以查看没有留下任何痕迹,据我所知,Java 程序正在某处运行,直到您不会手动将图标添加到系统托盘。此外,如何从任务管理器中删除您的应用程序该问题仍然存在,尽管您可以删除上述图标,正如您在问题中指出的那样。

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

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

应用程序

于 2012-02-21T08:35:59.330 回答
4

JWindowinsted扩展JFrame。(我没有在 Windows 7 上对此进行测试,因为我现在没有坐在 Windows 机器前。它适用于 XP 并且适用于 Unity,这让我感到惊讶。)

于 2012-02-21T06:23:37.727 回答
3

据我所知,没有办法删除任务栏图标。

于 2012-02-21T05:46:30.537 回答