List of usage examples for javax.swing JWindow dispose
public void dispose()
From source file:SimpleSplashScreen.java
public static void main(String[] arg) { JWindow jwin = new JWindow(); jwin.getContentPane().add(new JLabel("Loading ZIP/JAR Manager...", SwingConstants.CENTER)); jwin.setBounds(200, 200, 200, 100);//from www . j a v a2s .c o m jwin.setVisible(true); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } jwin.setVisible(false); jwin.dispose(); }
From source file:Main.java
public static void main(String args[]) { JWindow window = new JWindow(); window.getContentPane().add(new JLabel("Loading", SwingConstants.CENTER)); window.setBounds(500, 150, 300, 200); window.setVisible(true);//from w w w. java 2 s .c om try { Thread.sleep(5000); } catch (InterruptedException e) { } window.setVisible(false); JFrame frame = new JFrame(); frame.add(new JLabel("Welcome Swing application...")); frame.setVisible(true); frame.setSize(300, 200); window.dispose(); }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed final Component currentComponent = this.tabPane.getSelectedComponent(); if (!(currentComponent instanceof Container)) { LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent); return;/*from ww w .ja v a 2 s . c o m*/ } final GraphicsConfiguration gconfig = this.getGraphicsConfiguration(); if (gconfig != null) { final GraphicsDevice device = gconfig.getDevice(); if (device.isFullScreenSupported()) { if (device.getFullScreenWindow() == null) { final JLabel label = new JLabel("Opened in full screen"); final int tabIndex = this.tabPane.getSelectedIndex(); this.tabPane.setComponentAt(tabIndex, label); final JWindow window = new JWindow(Main.getApplicationFrame()); window.setAlwaysOnTop(true); window.setContentPane((Container) currentComponent); endFullScreenIfActive(); final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_F11)) { endFullScreenIfActive(); return true; } return false; } }; if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() { @Override public void run() { try { window.dispose(); } finally { tabPane.setComponentAt(tabIndex, currentComponent); device.setFullScreenWindow(null); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } })) { try { KeyboardFocusManager.getCurrentKeyboardFocusManager() .addKeyEventDispatcher(fullScreenEscCatcher); device.setFullScreenWindow(window); } catch (Exception ex) { LOGGER.error("Can't turn on full screen", ex); endFullScreenIfActive(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } else { LOGGER.error("Unexpected state, processor is not null!"); } } else { LOGGER.warn("Attempt to full screen device which already in full screen!"); } } else { LOGGER.warn("Device doesn's support full screen"); DialogProviderManager.getInstance().getDialogProvider() .msgWarn("The Device doesn't support full-screen mode!"); } } else { LOGGER.warn("Can't find graphics config for the frame"); } }
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 w ww .j a v a 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(); } }
From source file:org.nebulaframework.ui.swing.cluster.ClusterManagerStarter.java
/** * Starts execution of a ClusterManager instance on the * system.//from w ww . jav a 2s . com * * @param args Command Line Arguments */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JWindow splash = ClusterMainUI.showSplash(); try { Grid.startClusterManager(); } catch (Exception e) { splash.setVisible(false); log.error("Exception while starting", e); JOptionPane.showMessageDialog(null, "Unable to start ClusterManager due to Exception." + "\nSee StackTrace (log) for details", "Nebula Cluster", JOptionPane.ERROR_MESSAGE); System.exit(1); } ClusterMainUI ui = ClusterMainUI.create(); ui.setVisible(true); splash.setVisible(false); splash.dispose(); log.info("[UI] Initialized"); }
From source file:org.nebulaframework.ui.swing.node.GridNodeStarter.java
/** * Starts execution of a ClusterManager instance on the * system.// w w w .j av a 2 s . c o m * <p> * Note that it is possible to start a GridNode * with optional {@code -silent} argument, which is * suitable for setting up GridNodes to start up * along with the O/S. * * @param args Command Line Arguments */ public static void main(String[] args) { //Log4JConfiguration.configure(); // Process Arugments processArgs(args); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JWindow splash = null; if (!silentMode) { splash = NodeMainUI.showSplash(); } try { Grid.startGridNode(); } catch (DiscoveryFailureException ex) { log.warn("Discovery Failed"); } catch (Exception e) { log.error("Exception while starting", e); e.printStackTrace(); if (!silentMode) { splash.setVisible(false); JOptionPane.showMessageDialog(null, "Unable to start GridNode due to Exception." + "\nSee StackTrace (log) for details", "Nebula Grid", JOptionPane.ERROR_MESSAGE); } System.exit(1); } NodeMainUI ui = NodeMainUI.create(); // Show if not Silent Mode if (!silentMode) { splash.setVisible(false); splash.dispose(); ui.setVisible(true); } log.info("[UI] Initialized"); if (!Grid.isNode()) { log.warn("[GridNode] Not connected to Cluster"); } }
From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java
@Override public void execute(ActionEvent e) { final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); // No file selected before, popup a dialog and query the user which file to open. if (file == null) { String path = System.getProperty("user.home"); if (AppContext.getLastSelectedFolder() != null) { path = AppContext.getLastSelectedFolder(); }/*from www.j a v a 2 s . c o m*/ JFileChooser fc = new JFileChooser(path); fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name")); fc.setFileFilter(new FefaultFileFilter()); int result = fc.showOpenDialog(win); if (result == JFileChooser.APPROVE_OPTION) { if (fc.getSelectedFile() == null) return; file = fc.getSelectedFile(); AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath()); } else { return; } } final JWindow topWindow = new JWindow(); topWindow.setSize(390, 50); topWindow.setLayout(new BorderLayout()); topWindow.setBackground(Color.WHITE); final JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(10, 10, 10, 10))); content.setBackground(Color.WHITE); final JLabel infoLabel = new JLabel( resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName()); infoLabel.setVerticalAlignment(SwingConstants.CENTER); content.add(infoLabel, BorderLayout.SOUTH); final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content); busyPanel.setBusy(true); topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER); topWindow.setLocationRelativeTo(null); topWindow.add(busyPanel, BorderLayout.CENTER); final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() { @Override protected Boolean doInBackground() { topWindow.setVisible(true); doOpen(); return Boolean.valueOf(true); } @Override protected void done() { topWindow.setVisible(false); topWindow.dispose(); for (Runnable r : postConfigurators) { SwingUtilities.invokeLater(r); } } }; worker.execute(); }