Example usage for javax.swing JOptionPane setRootFrame

List of usage examples for javax.swing JOptionPane setRootFrame

Introduction

In this page you can find the example usage for javax.swing JOptionPane setRootFrame.

Prototype

public static void setRootFrame(Frame newRootFrame) 

Source Link

Document

Sets the frame to use for class methods in which a frame is not provided.

Usage

From source file:org.argouml.application.Main.java

/**
 * Do a part of the initialization that is very much GUI-stuff.
 *
 * @param splash the splash screeen/*  www.j av  a2 s. c o m*/
 */
private static ProjectBrowser initializeGUI(SplashScreen splash) {
    // make the projectbrowser
    JPanel todoPane = new ToDoPane();
    ProjectBrowser pb = ProjectBrowser.makeInstance(splash, true, todoPane);

    JOptionPane.setRootFrame(pb);

    pb.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    // Set the screen layout to what the user left it before, or
    // to reasonable defaults.
    Rectangle scrSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

    int configFrameWidth = Configuration.getInteger(Argo.KEY_SCREEN_WIDTH, scrSize.width);
    int w = Math.min(configFrameWidth, scrSize.width);
    if (w == 0) {
        w = 600;
    }

    int configFrameHeight = Configuration.getInteger(Argo.KEY_SCREEN_HEIGHT, scrSize.height);
    int h = Math.min(configFrameHeight, scrSize.height);
    if (h == 0) {
        h = 400;
    }

    int x = Configuration.getInteger(Argo.KEY_SCREEN_LEFT_X, 0);
    int y = Configuration.getInteger(Argo.KEY_SCREEN_TOP_Y, 0);
    pb.setLocation(x, y);
    pb.setSize(w, h);
    pb.setExtendedState(
            Configuration.getBoolean(Argo.KEY_SCREEN_MAXIMIZED, false) ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);

    UIManager.put("Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "ENTER", "pressed",
            "released ENTER", "released", "SPACE", "pressed", "released SPACE", "released" }));
    return pb;
}

From source file:org.springframework.richclient.application.splash.AbstractSplashScreen.java

/**
 * Creates and displays an undecorated, centered splash screen containing
 * the component provided by {@link #createContentPane()}. If this instance
 * has been provided with a {@link MessageSource}, it will be used to
 * retrieve the splash screen's frame title under the key
 * {@value #SPLASH_TITLE_KEY}.//from  w  w  w .j a v a  2s.  co  m
 */
public final void splash() {
    frame = shadowBorder ? new ShadowBorderFrame() : new JFrame();
    if (isRootFrame())
        JOptionPane.setRootFrame(frame);

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.setUndecorated(true);

    frame.setTitle(loadFrameTitle());
    frame.setIconImage(loadFrameIcon());

    Component content = createContentPane();
    if (content != null) {
        frame.getContentPane().add(content);
    }
    frame.pack();
    WindowUtils.centerOnScreen(frame);
    frame.setVisible(true);
}