List of usage examples for javax.swing JWindow setVisible
public void setVisible(boolean b)
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Shutsdown by ensuring the Appender gets a chance to close. *///from w w w . jav a 2 s. co m public boolean shutdown() { if (getApplicationPreferenceModel().isConfirmExit()) { if (JOptionPane.showConfirmDialog(LogUI.this, "Are you sure you want to exit Chainsaw?", "Confirm Exit", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) != JOptionPane.YES_OPTION) { return false; } } final JWindow progressWindow = new JWindow(); final ProgressPanel panel = new ProgressPanel(1, 3, "Shutting down"); progressWindow.getContentPane().add(panel); progressWindow.pack(); Point p = new Point(getLocation()); p.move((int) getSize().getWidth() >> 1, (int) getSize().getHeight() >> 1); progressWindow.setLocation(p); progressWindow.setVisible(true); Runnable runnable = new Runnable() { public void run() { try { int progress = 1; final int delay = 25; handler.close(); panel.setProgress(progress++); Thread.sleep(delay); pluginRegistry.stopAllPlugins(); panel.setProgress(progress++); Thread.sleep(delay); panel.setProgress(progress++); Thread.sleep(delay); } catch (Exception e) { e.printStackTrace(); } fireShutdownEvent(); performShutdownAction(); progressWindow.setVisible(false); } }; if (OSXIntegration.IS_OSX) { /** * or OSX we do it in the current thread because otherwise returning * will exit the process before it's had a chance to save things * */ runnable.run(); } else { new Thread(runnable).start(); } return true; }
From source file:org.geopublishing.atlasViewer.swing.AtlasViewerGUI.java
/** * Called via SingleInstanceListener / SingleInstanceService. Shows a * splashscreen and bring the existing instance to the front. */// w w w .ja 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 w w . j a v a 2s . c o m*/ * * @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./*from w w w . ja v 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(); }/* ww w . j ava2s .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(); }