public ClosingWindow() {
        initComponents();
        if (SystemTray.isSupported()) {
            tray = SystemTray.getSystemTray();
            //<editor-fold defaultstate="collapsed" desc="Menu">
            PopupMenu menu = new PopupMenu();
            MenuItem exitMenuItem = new MenuItem("Exit");
            exitMenuItem.addActionListener((ActionEvent e) -> {
                System.exit(0);
            });
            menu.add(exitMenuItem);
            MenuItem aboutMenuItem = new MenuItem("About");
            aboutMenuItem.addActionListener((ActionEvent e) -> {
                setVisible(true);
                setExtendedState(JFrame.NORMAL);
            });
            menu.add(aboutMenuItem);
            //</editor-fold>
            trayIcon = new TrayIcon(image, jLabelTitle.getText(), menu);
            trayIcon.setImageAutoSize(true);
        } else {
            System.out.println("system tray not supported");
        }
        //<editor-fold defaultstate="collapsed" desc="WindowStateListener">
        addWindowStateListener((WindowEvent e) -> {
            if (e.getNewState() == ICONIFIED) {
                try {
                    tray.add(trayIcon);
                    setVisible(false);
                } catch (AWTException ex) {
                    System.out.println("unable to add to tray");
                }
            }
            if (e.getNewState() == 7) {
                try {
                    tray.add(trayIcon);
                    setVisible(false);
                } catch (AWTException ex) {
                    System.out.println("unable to add to system tray");
                }
            }
            if (e.getNewState() == MAXIMIZED_BOTH) {
                tray.remove(trayIcon);
                setVisible(true);
            }
            if (e.getNewState() == NORMAL) {
                tray.remove(trayIcon);
                setVisible(true);
            }
        });
        //</editor-fold>
        setIconImage(image);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        try {
            tray.add(trayIcon);
            setVisible(false);
        } catch (AWTException ex) {
            System.out.println("unable to add to tray");
        }
    }