List of usage examples for javax.swing JDialog setDefaultCloseOperation
@BeanProperty(preferred = true, enumerationValues = { "WindowConstants.DO_NOTHING_ON_CLOSE", "WindowConstants.HIDE_ON_CLOSE", "WindowConstants.DISPOSE_ON_CLOSE" }, description = "The dialog's default close operation.") public void setDefaultCloseOperation(int operation)
From source file:coreferenceresolver.gui.MarkupGUI.java
public MarkupGUI() throws IOException { highlightPainters = new ArrayList<>(); for (int i = 0; i < COLORS.length; ++i) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( COLORS[i]);// w w w. j a va2 s . c om highlightPainters.add(highlightPainter); } defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new BorderLayout()); this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); //create menu items JMenuItem importMenuItem = new JMenuItem("Import"); JMenuItem exportMenuItem = new JMenuItem("Export"); fileMenu.add(importMenuItem); fileMenu.add(exportMenuItem); menuBar.add(fileMenu); this.setJMenuBar(menuBar); ScrollablePanel mainPanel = new ScrollablePanel(); mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //IMPORT BUTTON importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // MarkupGUI.reviewElements.clear(); // MarkupGUI.markupReviews.clear(); JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose your markup file"); markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException, BadLocationException { readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath()); for (int i = 0; i < markupReviews.size(); ++i) { mainPanel.add(newReviewPanel(markupReviews.get(i), i)); } return null; } protected void done() { MarkupGUI.this.revalidate(); d.dispose(); } }; worker.execute(); d.setVisible(true); } else { return; } } }); //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose where your markup file saved"); markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException { for (Review review : markupReviews) { generateNPsRef(review); } int i = 0; for (ReviewElement reviewElement : reviewElements) { int j = 0; for (Element element : reviewElement.elements) { String newType = element.typeSpinner.getValue().toString(); if (newType.equals("Object")) { markupReviews.get(i).getNounPhrases().get(j).setType(0); } else if (newType.equals("Attribute")) { markupReviews.get(i).getNounPhrases().get(j).setType(3); } else if (newType.equals("Other")) { markupReviews.get(i).getNounPhrases().get(j).setType(1); } else if (newType.equals("Candidate")) { markupReviews.get(i).getNounPhrases().get(j).setType(2); } ++j; } ++i; } initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "markup.out.txt"); return null; } protected void done() { d.dispose(); try { Desktop.getDesktop() .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath())); } catch (IOException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }; worker.execute(); d.setVisible(true); } else { return; } } }); JScrollPane scrollMainPane = new JScrollPane(mainPanel); scrollMainPane.getVerticalScrollBar().setUnitIncrement(16); scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); scrollMainPane.setSize(this.getWidth(), this.getHeight()); this.setResizable(false); this.add(scrollMainPane, BorderLayout.CENTER); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.pack(); }
From source file:fll.subjective.SubjectiveFrame.java
/** * Show differences.//from w w w. j a v a2 s. c o m */ private void showDifferencesDialog(final Collection<SubjectiveScoreDifference> diffs) { final SubjectiveDiffTableModel model = new SubjectiveDiffTableModel(diffs); final JTable table = new JTable(model); table.setGridColor(Color.BLACK); table.addMouseListener(new MouseAdapter() { public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 2) { final JTable target = (JTable) e.getSource(); final int row = target.getSelectedRow(); final SubjectiveScoreDifference diff = model.getDiffForRow(row); // find correct table final String category = diff.getCategory(); final JTable scoreTable = getTableForTitle(category); final int tabIndex = getTabIndexForCategory(category); getTabbedPane().setSelectedIndex(tabIndex); // get correct row and column final SubjectiveTableModel model = (SubjectiveTableModel) scoreTable.getModel(); final int scoreRow = model.getRowForTeamAndJudge(diff.getTeamNumber(), diff.getJudge()); final int scoreCol = model.getColForSubcategory(diff.getSubcategory()); if (scoreRow == -1 || scoreCol == -1) { throw new FLLRuntimeException( "Internal error: Cannot find correct row and column for score difference: " + diff); } scoreTable.changeSelection(scoreRow, scoreCol, false, false); } } }); final JDialog dialog = new JDialog(this, false); final Container cpane = dialog.getContentPane(); cpane.setLayout(new BorderLayout()); final JScrollPane tableScroller = new JScrollPane(table); cpane.add(tableScroller, BorderLayout.CENTER); dialog.pack(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * Displays the chart in a blocking JDialog. * //from w ww .j a va 2s. c om * @param width the width of the chart * @param height the height of the chart * @return the window that was created */ public JDialog showDialog(int width, int height) { JDialog frame = new JDialog(); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(getChartPanel(), BorderLayout.CENTER); frame.setPreferredSize(new Dimension(width, height)); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle("MOEA Framework Plot"); frame.setModalityType(ModalityType.APPLICATION_MODAL); frame.setVisible(true); return frame; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
@SuppressWarnings("unchecked") protected void changeLookAndFeel() { final JDialog dialog = new JDialog(mainFrame, "Design ndern"); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); Collection<TwoObjectsX<String, String>> lookAndFeels = FunctionsX.asList( new TwoObjectsX<String, String>("Metal", UIManager.getCrossPlatformLookAndFeelClassName()), new TwoObjectsX<String, String>("Betriebssystem Standard", UIManager.getSystemLookAndFeelClassName()), new TwoObjectsX<String, String>("Nimbus", NimbusLookAndFeel.class.getName())); dialog.setLayout(new GridLayout(0, 1)); ButtonGroup b = new ButtonGroup(); for (final TwoObjectsX<String, String> lookAndFeel : lookAndFeels) { JRadioButton rb = new JRadioButton(lookAndFeel.getObjectA()); if (iliasProperties.getLookAndFeel().equals(lookAndFeel.getObjectB())) { rb.setSelected(true);// www . j av a 2 s.co m } rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { UIManager.setLookAndFeel(lookAndFeel.getObjectB()); iliasProperties.setLookAndFeel(lookAndFeel.getObjectB()); saveProperties(iliasProperties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { showError("Fehler beim ndern des Designs", e1); } SwingUtilities.updateComponentTreeUI(mainFrame); SwingUtilities.updateComponentTreeUI(dialog); } }); b.add(rb); dialog.add(rb); } dialog.pack(); dialog.setLocationRelativeTo(mainFrame); dialog.setVisible(true); }
From source file:net.mariottini.swing.JFontChooser.java
/** * Show a "Choose Font" dialog with the specified title and modality. * /*from ww w .j ava 2 s.co m*/ * @param parent * the parent component, or null to use a default root frame as parent. * @param title * the title for the dialog. * @param modal * true to show a modal dialog, false to show a non-modal dialog (in this case the * function will return immediately after making visible the dialog). * @return <code>APPROVE_OPTION</code> if the user chose a font, <code>CANCEL_OPTION</code> if the * user canceled the operation. <code>CANCEL_OPTION</code> is always returned for a * non-modal dialog, use an ActionListener to be notified when the user approves/cancels * the dialog. * @see #APPROVE_OPTION * @see #CANCEL_OPTION * @see #addActionListener */ public int showDialog(Component parent, String title, boolean modal) { final int[] result = new int[] { CANCEL_OPTION }; while (parent != null && !(parent instanceof Window)) { parent = parent.getParent(); } final JDialog d; if (parent instanceof Frame) { d = new JDialog((Frame) parent, title, modal); } else if (parent instanceof Dialog) { d = new JDialog((Dialog) parent, title, modal); } else { d = new JDialog(); d.setTitle(title); d.setModal(modal); } final ActionListener[] listener = new ActionListener[1]; listener[0] = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(APPROVE_SELECTION)) { result[0] = APPROVE_OPTION; } removeActionListener(listener[0]); d.setContentPane(new JPanel()); d.setVisible(false); d.dispose(); } }; addActionListener(listener[0]); d.setComponentOrientation(getComponentOrientation()); d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); d.getContentPane().add(this, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(parent); d.setVisible(true); return result[0]; }
From source file:edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.java
/** * @param workerArg// w ww .ja va 2 s .c o m * @param title (already localized) * @return a modal dialog showing the progress */ public JDialog initProgress(final SwingWorker<?, ?> workerArg, final String title) { this.worker = workerArg; if (workerArg != null) { JDialog dialog = new JDialog((Dialog) null, true); titleLbl = new JLabel(title); progressBar = new JProgressBar(0, 100); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,p,4px,p,f:p:g")); pb.add(titleLbl, cc.xy(1, 2)); pb.add(progressBar, cc.xy(1, 4)); pb.setDefaultDialogBorder(); dialog.setContentPane(pb.getPanel()); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.pack(); dialog.setSize(500, 150); workerArg.addPropertyChangeListener(new SwingWorkerCompletionWaiter(dialog)); return dialog; } return null; }
From source file:jatoo.proxy.dialog.ProxyDialog.java
/** * Shows the dialog relative to the specified owner. *///from ww w . j av a 2s. c om public static synchronized void show(Component owner) { JDialog dialogTmp; if (owner == null) { dialogTmp = new JDialog(); } else { dialogTmp = new JDialog(SwingUtilities.getWindowAncestor(owner)); } final JDialog dialog = dialogTmp; // // the panel final ProxyDialogPanel dialogPanel = PROXY_DIALOG_PANEL_FACTORY.createDialogPanel(); try { Proxy proxy = new Proxy(); proxy.load(); dialogPanel.setProxyEnabled(proxy.isEnabled()); dialogPanel.setHost(proxy.getHost()); dialogPanel.setPort(proxy.getPort()); dialogPanel.setProxyRequiringAuthentication(proxy.isRequiringAuthentication()); dialogPanel.setUsername(proxy.getUsername()); dialogPanel.setPassword(proxy.getPassword()); } catch (FileNotFoundException e) { // do nothing, maybe is the first time and the file is missing } catch (Exception e) { logger.error("Failed to load the properties.", e); } // // buttons JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { if (dialogPanel.isProxyEnabled()) { if (dialogPanel.isProxyRequiringAuthentication()) { ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort(), dialogPanel.getUsername(), dialogPanel.getPassword()); } else { ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort()); } } else { ProxyUtils.removeProxy(); } dialog.dispose(); } catch (Exception e) { JOptionPane.showMessageDialog(dialog, "Failed to set the proxy:\n" + e.toString()); return; } try { Proxy proxy = new Proxy(); proxy.setEnabled(dialogPanel.isProxyEnabled()); proxy.setUsername(dialogPanel.getUsername()); proxy.setPassword(dialogPanel.getPassword()); proxy.setRequiringAuthentication(dialogPanel.isProxyRequiringAuthentication()); proxy.setHost(dialogPanel.getHost()); proxy.setPort(dialogPanel.getPort()); proxy.store(); } catch (Exception e) { logger.error("Failed to save the properties.", e); } } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // // layout dialog dialogPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel buttonsGroup = new JPanel(new GridLayout(1, 2, 5, 5)); buttonsGroup.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonsGroup.add(okButton); buttonsGroup.add(cancelButton); JPanel buttonsPanel = new JPanel(new BorderLayout()); buttonsPanel.add(buttonsGroup, BorderLayout.LINE_END); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(dialogPanel, BorderLayout.CENTER); contentPane.add(buttonsPanel, BorderLayout.PAGE_END); // // setup dialog dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setTitle("Proxy Settings"); dialog.setContentPane(contentPane); dialog.pack(); dialog.setLocationRelativeTo(dialog.getOwner()); dialog.setModal(true); // // and show dialog.setVisible(true); }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemMemoryUsageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemMemoryUsageActionPerformed JDialog dialog = new JDialog((JFrame) null, "Memory Usage"); JPanel_MemoryUsage panel = new JPanel_MemoryUsage("./"); dialog.getContentPane().add(panel);//w w w . ja v a 2s . c om dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setSize(550, 350); dialog.addWindowListener(panel); dialog.setLocationRelativeTo(this); dialog.setVisible(true); }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConfigActionPerformed JDialog ConfigDialog = new JDialog(this, "Configuration file: ", true); if (jplProgConfPanel == null) { jplProgConfPanel = new JPanelProgConfiguration(ConfigDialog, JEPlusConfig.getDefaultInstance()); }//from w w w .j a v a2 s. c o m jplProgConfPanel.setHostWindow(ConfigDialog); ConfigDialog.getContentPane().add(jplProgConfPanel); ConfigDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); ConfigDialog.setTitle(ConfigDialog.getTitle() + jplProgConfPanel.getConfigFile()); ConfigDialog.pack(); ConfigDialog.setSize(900, 650); ConfigDialog.setLocationRelativeTo(this); ConfigDialog.setVisible(true); }
From source file:ffx.ui.MainPanel.java
/** * <p>//from w w w. ja v a2 s . c o m * initialize</p> */ public void initialize() { if (init) { return; } init = true; String dir = System.getProperty("user.dir", FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath()); setCWD(new File(dir)); locale = new FFXLocale("en", "US"); JDialog splashScreen = null; ClassLoader loader = getClass().getClassLoader(); if (!GraphicsEnvironment.isHeadless()) { // Splash Screen JFrame.setDefaultLookAndFeelDecorated(true); splashScreen = new JDialog(frame, false); ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png")); JLabel ffxLabel = new JLabel(logo); ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); Container contentpane = splashScreen.getContentPane(); contentpane.setLayout(new BorderLayout()); contentpane.add(ffxLabel, BorderLayout.CENTER); splashScreen.setUndecorated(true); splashScreen.pack(); Dimension screenDimension = getToolkit().getScreenSize(); Dimension splashDimension = splashScreen.getSize(); splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2, (screenDimension.height - splashDimension.height) / 2); splashScreen.setResizable(false); splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); splashScreen.setVisible(true); // Make all pop-up Menus Heavyweight so they play nicely with Java3D JPopupMenu.setDefaultLightWeightPopupEnabled(false); } // Create the Root Node dataRoot = new MSRoot(); Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); statusLabel = new JLabel(" "); JLabel stepLabel = new JLabel(" "); stepLabel.setHorizontalAlignment(JLabel.RIGHT); JLabel energyLabel = new JLabel(" "); energyLabel.setHorizontalAlignment(JLabel.RIGHT); JPanel statusPanel = new JPanel(new GridLayout(1, 3)); statusPanel.setBorder(bb); statusPanel.add(statusLabel); statusPanel.add(stepLabel); statusPanel.add(energyLabel); if (!GraphicsEnvironment.isHeadless()) { GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D(); template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template3D); graphicsCanvas = new GraphicsCanvas(gc, this); graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel); } // Initialize various Panels hierarchy = new Hierarchy(this); hierarchy.setStatus(statusLabel, stepLabel, energyLabel); keywordPanel = new KeywordPanel(this); modelingPanel = new ModelingPanel(this); JPanel treePane = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); treePane.add(scrollPane, BorderLayout.CENTER); tabbedPane = new JTabbedPane(); ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png")); ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png")); ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png")); tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel); tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel); tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel); tabbedPane.addChangeListener(this); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane); /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, graphicsPanel); */ splitPane.setResizeWeight(0.25); splitPane.setOneTouchExpandable(true); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); if (!GraphicsEnvironment.isHeadless()) { mainMenu = new MainMenu(this); add(mainMenu.getToolBar(), BorderLayout.NORTH); getModelingShell(); loadPrefs(); SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this)); splashScreen.dispose(); } }