List of usage examples for javax.swing JWindow JWindow
public JWindow()
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Shutsdown by ensuring the Appender gets a chance to close. *//*www . j a v a2s. com*/ 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.gtdfree.GTDFree.java
private void flashMessage(String string, Point location) { if (flasher == null) { flasher = new JWindow(); flasher.addMouseListener(new MouseAdapter() { @Override//ww w .j av a 2 s . c om public void mouseClicked(MouseEvent e) { flasher.setVisible(false); } }); flasher.setContentPane(flasherText = new JLabel()); flasherText.setBorder(new Border() { Insets insets = new Insets(5, 11, 5, 11); @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { // } @Override public boolean isBorderOpaque() { return false; } @Override public Insets getBorderInsets(Component c) { return insets; } }); flasherText.setBackground(new Color(0xf3f3ad)); flasherText.setOpaque(true); } flasher.setVisible(false); flasherText.setText(string); flasher.pack(); flasher.setLocation(location.x - flasher.getWidth() / 2, location.y - flasher.getHeight()); if (flasher.getLocation().x < 0) { flasher.setLocation(0, flasher.getLocation().y); } if (flasher.getLocation().y < 0) { flasher.setLocation(flasher.getLocation().x, 0); } Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (flasher.getLocation().x + flasher.getWidth() > d.getWidth()) { flasher.setLocation((int) (d.getWidth() - flasher.getWidth()), flasher.getLocation().y); } if (flasher.getLocation().y + flasher.getHeight() > d.getHeight()) { flasher.setLocation(flasher.getLocation().x, (int) (d.getHeight() - flasher.getHeight())); } flasher.setVisible(true); new Thread() { @Override public synchronized void run() { try { wait(3000); } catch (InterruptedException e) { Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$ } flasher.setVisible(false); } }.start(); }
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 w ww .j a va 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(); }
From source file:org.pmedv.core.app.SplashScreen.java
/** * Show the splash screen./*w w w.j av a2 s. co m*/ */ public void splash() { window = new JWindow(); // TODO : What was this for? // AWTUtilities.setWindowOpaque(window, false); if (image == null) { image = loadImage(imageResourcePath); if (image == null) { return; } } MediaTracker mediaTracker = new MediaTracker(window); mediaTracker.addImage(image, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException e) { log.error("Interrupted while waiting for splash image to load."); } int width = image.getWidth(null); int height = image.getHeight(null); BufferedImage bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = (Graphics2D) bimg.createGraphics(); g2d.drawImage(image, 0, 0, null); g2d.setColor(Color.BLACK); g2d.setFont(new Font("Arial", Font.BOLD, 10)); InputStream is = getClass().getClassLoader().getResourceAsStream("application.properties"); Properties properties = new Properties(); try { properties.load(is); } catch (IOException e1) { properties.setProperty("version", "not set"); } String version = properties.getProperty("version"); File f = new File("build.number"); properties = new Properties(); try { properties.load(new FileReader(f)); } catch (IOException e1) { properties.setProperty("build.number", "00"); } String buildNumber = properties.getProperty("build.number"); g2d.drawString("Version " + version + "." + buildNumber, 400, 305); JLabel panelImage = new JLabel(new ImageIcon(bimg)); window.getContentPane().add(panelImage); window.getContentPane().add(progressBar, BorderLayout.SOUTH); window.pack(); WindowUtils.center(window); window.setVisible(true); }
From source file:uk.ac.babraham.BamQC.Graphs.ScatterGraph.java
private void initialise(double[] data, double[] xCategories, String[] toolTipLabels, String xLabel, String yLabel, String graphTitle) { this.data = data; this.xCategories = xCategories; this.toolTipLabels = toolTipLabels; this.xLabel = xLabel; this.yLabel = yLabel; this.graphTitle = graphTitle; // calculate minX-maxX, minY-maxY and xInterval-yInterval double[] minmax = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; calculateMinMax(this.data, minmax); minY = minmax[0];// w w w .ja v a 2 s .c o m maxY = minmax[1] + minmax[1] * 0.1; // let's give some extra 10% space yInterval = findOptimalYInterval(maxY); minmax = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; calculateMinMax(this.xCategories, minmax); minX = minmax[0]; maxX = minmax[1] + minmax[1] * 0.1; // let's give some extra 10% space xInterval = findOptimalYInterval(maxX); // TOOL TIPS management label.setHorizontalAlignment(JLabel.CENTER); label.setOpaque(true); label.setBackground(Color.WHITE); label.setBorder(UIManager.getBorder("ToolTip.border")); if (!GraphicsEnvironment.isHeadless()) { toolTip = new JWindow(); toolTip.add(label); // Tool tips tipster = new Tipster(this); addMouseMotionListener(tipster); } setOpaque(true); }