List of usage examples for javax.swing JDialog setModal
public void setModal(boolean modal)
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
/** * /*from ww w .j av a 2s . c o m*/ * @param parent * @param title * @param message * @return <code>true</code> if project should also be physically deleted, * <code>false</code> is project should be deleted but all files should be left alone, * <code>null</code> if user cancelled the dialog/project should not be deleted */ public static Boolean showDeleteProjectDialog(IAssemblyProject project) { final JDialog dialog = new JDialog((Window) null, "Delete project " + project.getName()); dialog.setModal(true); final JTextArea message = createMultiLineLabel( "Do you really want to delete project '" + project.getName() + " ?"); final JCheckBox checkbox = new JCheckBox("Delete project files"); final DialogResult[] outcome = { DialogResult.CANCEL }; final JButton yesButton = new JButton("Yes"); yesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { outcome[0] = DialogResult.YES; dialog.dispose(); } }); final JButton noButton = new JButton("No"); noButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { outcome[0] = DialogResult.NO; dialog.dispose(); } }); final JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { outcome[0] = DialogResult.CANCEL; dialog.dispose(); } }); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(yesButton); buttonPanel.add(noButton); buttonPanel.add(cancelButton); final JPanel messagePanel = new JPanel(); messagePanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; cnstrs.gridheight = 1; messagePanel.add(message, cnstrs); cnstrs = constraints(0, 1, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; messagePanel.add(checkbox, cnstrs); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right panel.add(messagePanel, cnstrs); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right panel.add(buttonPanel, cnstrs); dialog.getContentPane().add(panel); dialog.pack(); dialog.setVisible(true); if (outcome[0] != DialogResult.YES) { return null; } return checkbox.isSelected(); }
From source file:org.simbrain.plot.piechart.PieChartGui.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Add")) { this.getWorkspaceComponent().getModel().addDataSource(); } else if (e.getActionCommand().equalsIgnoreCase("dialog")) { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(getWorkspaceComponent().getModel())); JDialog dialog = editor.getDialog(); dialog.setModal(true); dialog.pack();/*ww w. j a va 2 s . c o m*/ dialog.setLocationRelativeTo(null); dialog.setVisible(true); } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { this.getWorkspaceComponent().getModel().removeDataSource(); } }
From source file:org.simbrain.plot.barchart.BarChartGui.java
/** @see ActionListener */ public void actionPerformed(final ActionEvent arg0) { if (arg0.getActionCommand().equalsIgnoreCase("dialog")) { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(getWorkspaceComponent().getModel())); JDialog dialog = editor.getDialog(); dialog.setModal(true); dialog.pack();//from ww w .ja va 2s. com dialog.setLocationRelativeTo(null); dialog.setVisible(true); } else if (arg0.getActionCommand().equalsIgnoreCase("Delete")) { this.getWorkspaceComponent().getModel().removeColumn(); } else if (arg0.getActionCommand().equalsIgnoreCase("Add")) { this.getWorkspaceComponent().getModel().addColumn(); } }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Show properties dialog./*from w w w . ja va 2 s . c o m*/ */ public void showPropertiesDialog() { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(model)); JDialog dialog = editor.getDialog(); dialog.setModal(true); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); }
From source file:com.aw.swing.mvp.JDialogView.java
public void show() { if (pst.isEmbeddedView()) { return;/*from w w w. jav a 2 s . c o m*/ } TimeObserver time = new TimeObserver("Show Dialog"); time.empezar(); JDialog dlg = (JDialog) parentContainer; time.terminar(); if (dialogFixture == null) { dlg.setModal(true); dlg.setVisible(true); } }
From source file:eu.asterics.mw.services.AstericsErrorHandling.java
/** * This method is used by the components to report an error. It logs the error in "warning" logger * and sets the status of the ARE to "ERROR" to denote that an error has occurred * @param component the component instance that reports the error * @param errorMsg the error message// ww w.j a v a 2 s. co m */ public void reportError(IRuntimeComponentInstance component, final String errorMsg) { if (component != null) { String componentID = DeploymentManager.instance .getIRuntimeComponentInstanceIDFromIRuntimeComponentInstance(component); if (componentID != null) { //System.out.println("componentID: "+componentID); logger.warning(componentID + ": " + errorMsg); setStatusObject(AREStatus.ERROR.toString(), componentID, errorMsg); } } AREProperties props = AREProperties.instance; if (props.checkProperty("showErrorDialogs", "1")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ErrorLogPane.appendLog(errorMsg); DeploymentManager.instance.setStatus(AREStatus.ERROR); AstericsErrorHandling.this.notifyAREEventListeners("onAreError", errorMsg); JOptionPane op = new JOptionPane(errorMsg, JOptionPane.WARNING_MESSAGE); JDialog dialog = op.createDialog("AsTeRICS Runtime Environment:"); dialog.setAlwaysOnTop(true); dialog.setModal(false); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } }); } }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
private JDialog createAddChildDialog() { final JDialog dlg = new JDialog(); dlg.setModal(true); // Content//from ww w . j a va 2 s. c o m final JPanel content = new JPanel(); content.setLayout(new BorderLayout()); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // child name AlignmentGridPanel pathPanel = new AlignmentGridPanel(); final JTextField childNameText = new JTextField(); final RSyntaxTextArea childDataArea = new RSyntaxTextArea(); final JMenuBar bar = new JMenuBar(); final JMenu menu = new JMenu("Syntax Highlight"); bar.add(menu); setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_XML); setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_JAVA); setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE); pathPanel.addLine(new Component[] { new JLabel("Select:"), bar }); pathPanel.addLine(new Component[] { new JLabel("Name: "), childNameText }); pathPanel.addLine(new Component[] { new JLabel("Data: ") }); content.add(pathPanel, BorderLayout.NORTH); content.add(new RTextScrollPane(childDataArea), BorderLayout.CENTER); childDataArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE); // Buttons. final CButtonPane btnPanel = new CButtonPane(CButtonPane.TAIL); final JButton btnOk = new JButton("Ok"); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String name = childNameText.getText(); String data = childDataArea.getText(); if ((name == null || name.isEmpty()) || (data == null || data.isEmpty())) { JOptionPane.showMessageDialog(null, "Name or Data is empty", "Error", JOptionPane.ERROR_MESSAGE); return; } childName = name; childText = data; dlg.setVisible(false); dlg.dispose(); } }); final JButton btnCancel = new JButton("Cancel"); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { childName = ""; childText = ""; dlg.setVisible(false); dlg.dispose(); } }); btnPanel.add(btnCancel); btnPanel.add(btnOk); btnPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); Container con = dlg.getContentPane(); con.setLayout(new BorderLayout()); con.add(content, BorderLayout.CENTER); con.add(btnPanel, BorderLayout.SOUTH); return dlg; }
From source file:com.haulmont.cuba.desktop.exception.DefaultExceptionHandler.java
@Override public boolean handle(Thread thread, Throwable exception) { JXErrorPane errorPane = new JXErrorPaneExt(); errorPane.setErrorInfo(createErrorInfo(exception)); JDialog dialog = JXErrorPane.createDialog(App.getInstance().getMainFrame(), errorPane); dialog.setMinimumSize(new Dimension(600, (int) dialog.getMinimumSize().getHeight())); final DialogWindow lastDialogWindow = getLastDialogWindow(); dialog.addWindowListener(new WindowAdapter() { @Override//from w w w . jav a 2 s . c om public void windowClosed(WindowEvent e) { if (lastDialogWindow != null) lastDialogWindow.enableWindow(); else App.getInstance().getMainFrame().activate(); } }); dialog.setModal(false); if (lastDialogWindow != null) lastDialogWindow.disableWindow(null); else App.getInstance().getMainFrame().deactivate(null); dialog.setVisible(true); return true; }
From source file:com.eviware.soapui.support.SoapUIVersionUpdate.java
public void showNewVersionDownloadDialog() { JPanel versionUpdatePanel = new JPanel(new BorderLayout()); JDialog dialog = new JDialog(); versionUpdatePanel.add(UISupport.buildDescription("New Version of SoapUI is Available", "", null), BorderLayout.NORTH);/*from w w w . j a v a2 s .c o m*/ JEditorPane text = createReleaseNotesPane(); JScrollPane scb = new JScrollPane(text); versionUpdatePanel.add(scb, BorderLayout.CENTER); JPanel toolbar = buildToolbar(dialog); versionUpdatePanel.add(toolbar, BorderLayout.SOUTH); dialog.setTitle("New Version Update"); dialog.setModal(true); dialog.getContentPane().add(versionUpdatePanel); dialog.setSize(new Dimension(500, 640)); UISupport.centerDialog(dialog, SoapUI.getFrame()); dialog.setVisible(true); }
From source file:net.sf.nmedit.nomad.core.Nomad.java
public void export() { Document doc = getDocumentManager().getSelection(); if (!(doc instanceof Transferable)) return;// w ww . ja v a 2 s. com Transferable transferable = (Transferable) doc; String title = doc.getTitle(); if (title == null) title = "Export"; else title = "Export '" + title + "'"; JComboBox src = new JComboBox(transferable.getTransferDataFlavors()); src.setRenderer(new DefaultListCellRenderer() { /** * */ private static final long serialVersionUID = -4553255745845039428L; public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String text; if (value instanceof DataFlavor) { DataFlavor flavor = (DataFlavor) value; String mimeType = flavor.getMimeType(); String humanRep = flavor.getHumanPresentableName(); String charset = flavor.getParameter("charset"); if (mimeType == null) text = "?"; else { text = mimeType; int ix = text.indexOf(';'); if (ix >= 0) text = text.substring(0, ix).trim(); } if (charset != null) text += "; charset=" + charset; if (humanRep != null) text += " (" + humanRep + ")"; } else { text = String.valueOf(value); } return super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); } }); JComboBox dst = new JComboBox(new Object[] { "File", "Clipboard" }); Object[] msg = { "Source:", doc.getTitle(), "Export as:", src, "Export to:", dst }; Object[] options = { "Ok", "Cancel" }; JOptionPane op = new JOptionPane(msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options); JDialog dialog = op.createDialog(getWindow(), title); dialog.setModal(true); dialog.setVisible(true); boolean ok = "Ok".equals(op.getValue()); DataFlavor flavor = (DataFlavor) src.getSelectedItem(); dialog.dispose(); if (!ok) return; if (flavor == null) return; if ("Clipboard".equals(dst.getSelectedItem())) { Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(new SelectedTransfer(flavor, transferable), null); } else { export(transferable, flavor); } }