List of usage examples for javax.swing JWindow setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Displays Splash Screen//w w w. j a va2 s .co m * * @return Splash Screen Reference */ public static JWindow showSplash() { JWindow splash = new JWindow(); splash.setSize(400, 250); splash.setLayout(null); JLabel status = new JLabel("Developed by Yohan Liyanage, 2008"); JLabelAppender.setLabel(status); status.setFont(new Font("sansserif", Font.PLAIN, 10)); status.setSize(350, 30); status.setLocation(10, 220); splash.add(status); JLabel lbl = new JLabel( new ImageIcon(ClassLoader.getSystemResource("META-INF/resources/nebula-startup.png"))); lbl.setSize(400, 250); lbl.setLocation(0, 0); splash.add(lbl); splash.setVisible(true); splash.setLocationRelativeTo(null); return splash; }
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 w w.j a v a 2s . co 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(); }