[Solved] How do I make my java program run in the background? [closed]


Look ma, no windows here, just us teddies…

enter image description here

public class TestTrayIcon01 {

    public static void main(String[] args) {
        new TestTrayIcon01();
    }

    public TestTrayIcon01() {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    TrayIcon icon = new TrayIcon(ImageIO.read(getClass().getResource("/SmallTeddy.png")));
                    SystemTray tray = SystemTray.getSystemTray();
                    tray.add(icon);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                JDialog dialog = new JDialog();
                dialog.setSize(100, 100);
                dialog.setVisible(true);
            }
        });
    }

}

JDialog and JWindow (under Windows) will not display a “icon” on the task bar. I’m pretty sure under Mac it’s next to near impossible NOT to have a dock icon…

4

solved How do I make my java program run in the background? [closed]