Example usage for java.awt Frame MAXIMIZED_BOTH

List of usage examples for java.awt Frame MAXIMIZED_BOTH

Introduction

In this page you can find the example usage for java.awt Frame MAXIMIZED_BOTH.

Prototype

int MAXIMIZED_BOTH

To view the source code for java.awt Frame MAXIMIZED_BOTH.

Click Source Link

Document

This state bit mask indicates that frame is fully maximized (that is both horizontally and vertically).

Usage

From source file:net.sf.jabref.gui.JabRefFrame.java

/**
 * Tears down all things started by JabRef
 * <p>//from  www .jav a  2  s . c om
 * FIXME: Currently some threads remain and therefore hinder JabRef to be closed properly
 *
 * @param filenames the filenames of all currently opened files - used for storing them if prefs openLastEdited is set to true
 */
private void tearDownJabRef(List<String> filenames) {
    JabRefExecutorService.INSTANCE.shutdownEverything();

    dispose();

    if (getCurrentBasePanel() != null) {
        getCurrentBasePanel().saveDividerLocation();
    }

    //prefs.putBoolean(JabRefPreferences.WINDOW_MAXIMISED, (getExtendedState()&MAXIMIZED_BOTH)>0);
    prefs.putBoolean(JabRefPreferences.WINDOW_MAXIMISED, getExtendedState() == Frame.MAXIMIZED_BOTH);

    prefs.putBoolean(JabRefPreferences.TOOLBAR_VISIBLE, tlb.isVisible());
    // Store divider location for side pane:
    int width = splitPane.getDividerLocation();
    if (width > 0) {
        prefs.putInt(JabRefPreferences.SIDE_PANE_WIDTH, width);
    }
    if (prefs.getBoolean(JabRefPreferences.OPEN_LAST_EDITED)) {
        // Here we store the names of all current files. If
        // there is no current file, we remove any
        // previously stored filename.
        if (filenames.isEmpty()) {
            prefs.remove(JabRefPreferences.LAST_EDITED);
        } else {
            prefs.putStringList(JabRefPreferences.LAST_EDITED, filenames);
            File focusedDatabase = getCurrentBasePanel().getBibDatabaseContext().getDatabaseFile();
            new LastFocusedTabPreferences(prefs).setLastFocusedTab(focusedDatabase);
        }

    }

    fileHistory.storeHistory();
    prefs.customExports.store(Globals.prefs);
    prefs.customImports.store();
    CustomEntryTypesManager.saveCustomEntryTypes(prefs);

    // Clear autosave files:
    // TODO: Is this really needed since clearAutoSave() is called in stopAutoSaveManager() a few rows below?
    Globals.getAutoSaveManager().ifPresent(manager -> manager.clearAutoSaves());

    prefs.flush();

    // dispose all windows, even if they are not displayed anymore
    for (Window window : Window.getWindows()) {
        window.dispose();
    }

    // shutdown any timers that are may be active
    Globals.stopAutoSaveManager();
}

From source file:velocitekProStartAnalyzer.MainWindow.java

private static boolean isMaximized(int state) {
    return (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH;
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * Checks to see if cache has changed before exiting.
 *
 *//*  w w  w  .j  a v  a  2  s. c  om*/
public boolean doExit(boolean doAppExit) {
    boolean okToShutdown = true;
    try {
        if (AttachmentUtils.getAttachmentManager() != null) {
            AttachmentUtils.getAttachmentManager().cleanup();
        }

        okToShutdown = SubPaneMgr.getInstance().aboutToShutdown();
        if (okToShutdown) {
            UsageTracker.save();

            try {
                DataProviderSessionIFace session = null;
                SpecifyUser currentUser = AppContextMgr.getInstance().getClassObject(SpecifyUser.class);
                if (currentUser != null) {
                    session = DataProviderFactory.getInstance().createSession();

                    SpecifyUser user = session.getData(SpecifyUser.class, "id", currentUser.getId(),
                            DataProviderSessionIFace.CompareType.Equals);
                    user.setIsLoggedIn(false);
                    user.setLoginDisciplineName(null);
                    user.setLoginCollectionName(null);
                    user.setLoginOutTime(new Timestamp(System.currentTimeMillis()));

                    try {
                        session.beginTransaction();
                        session.saveOrUpdate(user);
                        session.commit();

                    } catch (Exception ex) {
                        log.error(ex);

                    } finally {
                        if (session != null) {
                            session.close();
                        }
                    }
                }

            } catch (Exception ex) {
                log.error(ex);
            }

            // Returns false if it isn't doing a backup.
            // passing true tells it to send an App exit command
            if (!BackupServiceFactory.getInstance().checkForBackUp(true)) {

                log.info("Application shutdown"); //$NON-NLS-1$

                if (topFrame != null) {
                    Rectangle r = topFrame.getBounds();
                    AppPreferences.getLocalPrefs().putInt("APP.X", r.x);
                    AppPreferences.getLocalPrefs().putInt("APP.Y", r.y);
                    AppPreferences.getLocalPrefs().putInt("APP.W", r.width);
                    AppPreferences.getLocalPrefs().putInt("APP.H", r.height);
                    if (UIHelper.isMacOS()) {
                        AppPreferences.getLocalPrefs().putBoolean("APP.MAXIMIZED",
                                topFrame.getExtendedState() == Frame.MAXIMIZED_BOTH);
                    }
                }

                AppPreferences.getLocalPrefs().flush();

                // save the long term cache mapping info
                try {
                    UIRegistry.getLongTermFileCache().saveCacheMapping();
                    log.info("Successfully saved long term cache mapping"); //$NON-NLS-1$
                } catch (IOException ioe) {
                    log.warn("Error while saving long term cache mapping.", ioe); //$NON-NLS-1$
                }

                // clear the contents of the short term cache
                log.info("Clearing the short term cache"); //$NON-NLS-1$
                UIRegistry.getShortTermFileCache().clear();

                // save the forms cache mapping info
                try {
                    UIRegistry.getFormsCache().saveCacheMapping();
                    log.info("Successfully saved forms cache mapping"); //$NON-NLS-1$
                } catch (IOException ioe) {
                    log.warn("Error while saving forms cache mapping.", ioe); //$NON-NLS-1$
                }

                if (topFrame != null) {
                    topFrame.setVisible(false);
                }
                QueryExecutor.getInstance().shutdown();

            } else {
                okToShutdown = false;
            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();

    } finally {
        if (okToShutdown && doAppExit) {
            Boolean canSendStats = false;
            if (AppContextMgr.getInstance().hasContext()) {
                canSendStats = AppPreferences.getRemote().getBoolean(sendStatsPrefName, true); //$NON-NLS-1$
            }

            if (canSendStats) {
                Boolean canSendISAStats = AppPreferences.getRemote().getBoolean(sendISAStatsPrefName, true); //$NON-NLS-1$
                StatsTrackerTask statsTrackerTask = (StatsTrackerTask) TaskMgr
                        .getTask(StatsTrackerTask.STATS_TRACKER);
                if (statsTrackerTask != null) {
                    UIRegistry.getTopWindow().setVisible(false);
                    statsTrackerTask.setSendSecondaryStatsAllowed(canSendISAStats);
                    statsTrackerTask.sendStats(false, false, true); // don't exit, show progress and send done event

                    return false;
                }

            } else {
                // Fake like we sent stats, needs to  to be placed into the event queue 
                // so any other events can be processed.
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Thread.sleep(500); // wait half second before sending 'faked' done event.
                        } catch (Exception ex) {
                        }
                        CommandDispatcher
                                .dispatch(new CommandAction(BaseTask.APP_CMD_TYPE, STATS_SEND_DONE, null));
                    }
                });
            }
        }
    }
    return okToShutdown;
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * Bring up the PPApp demo by showing the frame (only applicable if coming up
 * as an application, not an applet);/*from   www.j a  va 2s.  c o m*/
 */
public void showApp() {
    JFrame f = getFrame();
    f.setTitle(getTitle());
    f.getContentPane().add(this, BorderLayout.CENTER);
    f.pack();

    f.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doExit(true);
        }
    });

    UIHelper.centerWindow(f);
    Rectangle r = f.getBounds();
    int x = AppPreferences.getLocalPrefs().getInt("APP.X", r.x);
    int y = AppPreferences.getLocalPrefs().getInt("APP.Y", r.y);
    int w = AppPreferences.getLocalPrefs().getInt("APP.W", r.width);
    int h = AppPreferences.getLocalPrefs().getInt("APP.H", r.height);
    boolean isMacAndMaxed = UIHelper.isMacOS()
            && AppPreferences.getLocalPrefs().getBoolean("APP.MAXIMIZED", true);
    if (isMacAndMaxed) {
        f.setExtendedState(Frame.MAXIMIZED_BOTH);
    } else {
        UIHelper.positionAndFitToScreen(f, x, y, w, h);
    }
    f.setVisible(true);
}

From source file:v800_trainer.JCicloTronic.java

/**
 * @param args the command line arguments
 *///from ww w .  j ava 2  s .co  m
public static void main(String args[]) {
    //     new JCicloTronic ().show ();

    if (args.length != 0 && args[0].equalsIgnoreCase("nodebug")) {
        debug = false;
    } else {
        debug = true;
    }
    JCicloTronic Frame = new JCicloTronic();
    Frame.setVisible(true);

    int x = 0, y = 0;
    try {
        y = Integer.parseInt(Frame.Properties.getProperty("Screenheight",
                new Double(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50).toString()));
        x = Integer.parseInt(Frame.Properties.getProperty("Screenwidth",
                new Double(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50).toString()));
    } catch (Exception e) {
    }
    ;

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double width = screenSize.getWidth();
    double height = screenSize.getHeight();
    if (x > (int) width) {
        x = (int) width;
    }
    if (y > (int) height) {
        y = (int) height;
    }
    if (x > width - 200 || y > height - 200) {
        Frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        Frame.setPreferredSize(new Dimension((int) width - 200, (int) height - 200));
    } else
        Frame.setSize(x, y);

    Frame.ChangeModel();

    //  Frame.repaint();

}