Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); desktopWidth = screenSize.width; desktopHeight = screenSize.height; addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { int x = getWidth(); int y = getHeight(); if (x == desktopWidth && y == desktopHeight) { if (maximized) { demaximize(); } else { maximize(); } } else { if (!maximized) { lastFrameSize = getSize(); lastFrameLocation = getLocation(); } super.componentResized(e); } }  public void componentMoved(ComponentEvent e) { if (!maximized) { lastFrameLocation = getLocation(); } super.componentMoved(e); } });
    private void init() throws Exception {        String titel = "AppleJuice Client";        IconManager im = IconManager.getInstance();        Image image = im.getIcon("applejuice").getImage();        setTitle(titel);        String osName = System.getProperty("os.name");        plugins = new HashSet();        setIconImage(image);        menuItemOptionen.setIcon(im.getIcon("optionen"));        menuItemUeber.setIcon(im.getIcon("info"));        menuItemCoreBeenden.setIcon(im.getIcon("skull"));        setJMenuBar(createMenuBar());        if (PropertiesManager.getOptionsManager().isThemesSupported()) {            SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this);        }        String path = System.getProperty("user.dir") + File.separator +            "language" +            File.separator;        path += PropertiesManager.getOptionsManager().getSprache() + ".xml";        registerPane = new RegisterPanel(this);        LanguageSelector.getInstance(path);        addWindowListener(            new WindowAdapter() {            public void windowClosing(WindowEvent evt) {                closeDialog(evt);            }        });        if (osName.toLowerCase().indexOf("win") != -1) {            try {                if (!WindowsTrayIcon.isRunning(titel)) {                    useTrayIcon = true;                    WindowsTrayIcon.initTrayIcon(titel);                    trayIcon = new WindowsTrayIcon(image, 16, 16);                    trayIcon.setVisible(true);                    trayIcon.setToolTipText(titel);                    trayIcon.addMouseListener(new MouseAdapter() {                        public void mousePressed(MouseEvent evt) {                            if (!isVisible()) {                                popupShowHideMenuItem.setText(zeigen);                                popupShowHideMenuItem.setIcon(zeigenIcon);                            }                            else {                                popupShowHideMenuItem.setText(verstecken);                                popupShowHideMenuItem.setIcon(versteckenIcon);                            }                            if ( (evt.getModifiers() & MouseEvent.BUTTON1_MASK) !=                                0 &&                                evt.getClickCount() == 2) {                                if (!isVisible()) {                                    setVisible(true);                                }                                else {                                    setVisible(false);                                }                            }                        }                    });                    SwingTrayPopup popup = makeSwingPopup();                    popup.setTrayIcon(trayIcon);                }            }            catch (UnsatisfiedLinkError error) {                LanguageSelector languageSelector = LanguageSelector.                    getInstance();                String fehlerTitel = ZeichenErsetzer.korrigiereUmlaute(                    languageSelector.getFirstAttrbuteByTagName(new String[] {                    "mainform", "caption"}));                String fehlerNachricht = ZeichenErsetzer.korrigiereUmlaute(                    languageSelector.getFirstAttrbuteByTagName(new String[] {                    "javagui", "startup",                    "trayfehler"}));                JOptionPane.showMessageDialog(this, fehlerNachricht,                                              fehlerTitel,                                              JOptionPane.ERROR_MESSAGE);            }        }        getContentPane().setLayout(new BorderLayout());        registerPane.addChangeListener(new ChangeListener() {            public void stateChanged(ChangeEvent e) {                RegisterI register = (RegisterI) registerPane.                    getSelectedComponent();                register.registerSelected();            }        });        getContentPane().add(registerPane, BorderLayout.CENTER);        JPanel panel = new JPanel(new GridBagLayout());        for (int i = 0; i < statusbar.length; i++) {            statusbar[i] = new JLabel("            ");            statusbar[i].setHorizontalAlignment(JLabel.RIGHT);            statusbar[i].setBorder(new BevelBorder(BevelBorder.LOWERED));            statusbar[i].setFont(new java.awt.Font("SansSerif", 0, 11));        }        memory.setIcon(IconManager.getInstance().getIcon("mmonitor"));        memory.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent ae) {                if (memoryMonitorDialog == null) {                    memoryMonitorDialog = new MemoryMonitorDialog(                        AppleJuiceDialog.this);                    Point loc = memory.getLocationOnScreen();                    loc.setLocation(loc.getX() - memoryMonitorDialog.getWidth(),                                    loc.getY() - memoryMonitorDialog.getHeight());                    memoryMonitorDialog.setLocation(loc);                }                if (!memoryMonitorDialog.isVisible()) {                    memoryMonitorDialog.show();                }            }        });        sound.addActionListener(new ActionListener() {            {                if (PropertiesManager.getOptionsManager().isSoundEnabled()) {                    sound.setIcon(IconManager.getInstance().getIcon("soundon"));                }                else {                    sound.setIcon(IconManager.getInstance().getIcon("soundoff"));                }            }            public void actionPerformed(ActionEvent ae) {                OptionsManager om = PropertiesManager.getOptionsManager();                om.enableSound(!om.isSoundEnabled());                if (om.isSoundEnabled()) {                    sound.setIcon(IconManager.getInstance().getIcon("soundon"));                }                else {                    sound.setIcon(IconManager.getInstance().getIcon("soundoff"));                }            }        });        GridBagConstraints constraints = new GridBagConstraints();        constraints.anchor = GridBagConstraints.NORTH;        constraints.fill = GridBagConstraints.BOTH;        constraints.gridx = 0;        constraints.gridy = 0;        panel.add(statusbar[0], constraints);        constraints.gridx = 1;        constraints.weightx = 1;        panel.add(statusbar[1], constraints);        constraints.weightx = 0;        constraints.gridx = 2;        panel.add(statusbar[2], constraints);        constraints.gridx = 3;        panel.add(statusbar[3], constraints);        constraints.gridx = 4;        panel.add(statusbar[4], constraints);        constraints.gridx = 5;        panel.add(statusbar[5], constraints);        constraints.gridx = 6;        panel.add(memory, constraints);        constraints.gridx = 7;        panel.add(sound, constraints);        getContentPane().add(panel, BorderLayout.SOUTH);        //Tooltipps einstellen        ToolTipManager.sharedInstance().setInitialDelay(1);        ToolTipManager.sharedInstance().setDismissDelay(50000);        fireLanguageChanged();        ApplejuiceFassade dm = ApplejuiceFassade.getInstance();        dm.addDataUpdateListener(this,                                 DataUpdateListener.INFORMATION_CHANGED);        dm.startXMLCheck();    }