List of usage examples for javax.swing JWindow getContentPane
public Container getContentPane()
Container
which is the contentPane
for this window. 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);/* w w w.ja va2 s .c om*/ 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 .j a v a 2 s. c o m*/ 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:Main.java
public static void main(String[] arg) throws Exception { Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); Robot robot = new Robot(); BufferedImage image = robot//from ww w. ja v a2s . c o m .createScreenCapture(new Rectangle(0, 0, (int) screenDim.getWidth(), (int) screenDim.getHeight())); JWindow window = new JWindow(new JFrame()); window.getContentPane().setLayout(new BorderLayout()); window.getContentPane().add(BorderLayout.CENTER, new JLabel(new ImageIcon(image))); window.pack(); window.setVisible(true); }
From source file:Main.java
License:asdf
public static void main(String[] argv) throws Exception { JWindow window = new JWindow(); JButton component = new JButton("asdf"); // Add component to the window window.getContentPane().add(component, BorderLayout.CENTER); // Set initial size window.setSize(300, 300);//from w w w.j a va2 s.c o m // Show the window window.setVisible(true); }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Shutsdown by ensuring the Appender gets a chance to close. */// w w w . jav a2s . c o 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 ww . j a v a 2 s . c om @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.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 a2s . com*/ 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(); }