Example usage for javax.swing JWindow getRootPane

List of usage examples for javax.swing JWindow getRootPane

Introduction

In this page you can find the example usage for javax.swing JWindow getRootPane.

Prototype

@BeanProperty(bound = false, hidden = true, description = "the RootPane object for this window.")
public JRootPane getRootPane() 

Source Link

Document

Returns the rootPane object for this window.

Usage

From source file:org.geopublishing.atlasViewer.swing.AtlasViewerGUI.java

/**
 * Called via SingleInstanceListener / SingleInstanceService. Shows a
 * splashscreen and bring the existing instance to the front.
 *///from ww  w  .  java  2  s.c o  m
@Override
public void newActivation(String[] arg0) {
    LOGGER.info(
            "A second instance of AtlasViewer has been started.. The single instance if requesting focus now...");

    /*
     * Showing the Spalshscreen for one secong
     */
    try {
        final URL splashscreenUrl = atlasConfig.getResource(AtlasConfig.SPLASHSCREEN_RESOURCE_NAME);
        if (splashscreenUrl != null) {
            JWindow splashWindow = new JWindow(atlasJFrame);
            JPanel panel = new JPanel(new BorderLayout());
            ImageIcon icon = new ImageIcon(splashscreenUrl);
            panel.add(new JLabel(icon), BorderLayout.CENTER);
            panel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            splashWindow.getContentPane().add(panel);
            splashWindow.getRootPane().setOpaque(true);
            splashWindow.pack();
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            splashWindow.setLocation((int) (d.getWidth() - splashWindow.getWidth()) / 2,
                    (int) (d.getHeight() - splashWindow.getHeight()) / 2);
            splashWindow.setVisible(true);
            Thread.sleep(1500);
            splashWindow.dispose();
            splashWindow = null;
        }
    } catch (Exception e) {
        LOGGER.warn("Singleinstance.newActivation had problems while showing the splashscreen:", e);
    }

    if (getJFrame() != null) {
        if (!getJFrame().isShowing())
            getJFrame().setVisible(true);

        /* In case that it has been iconified */
        getJFrame().setExtendedState(Frame.NORMAL);

        getJFrame().requestFocus();
        getJFrame().toFront();
    }
}