List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
/** * /*from ww w. j a v a 2 s. 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:self.philbrown.javaQuery.$.java
/** * Show an alert/*from w ww. j a v a2s . c om*/ * @param context used to display the alert window * @param title the title of the alert window. Use {@code null} to show no title * @param text the alert message * @see #alert(String) */ public static void alert(String title, String text) { JDialog alert = new JDialog(); if (title != null) alert.setTitle(title); if (text != null) alert.add(new JLabel(text, JLabel.CENTER)); alert.setVisible(true); }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
private JDialog createAddChildDialog() { final JDialog dlg = new JDialog(); dlg.setModal(true);/*from w ww.j ava 2 s .co m*/ // Content 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:net.jradius.client.gui.JRadiusSimulator.java
/** * This method initializes addAttributeButton * /*ww w. j a va 2s . c om*/ * @return javax.swing.JButton */ private JButton getAddAttributeButton() { if (addAttributeButton == null) { addAttributeButton = new JButton(); addAttributeButton.setText("Add Attribute"); addAttributeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { JDialog dialog = getAddAttributeDialog(); dialog.setModal(true); dialog.setVisible(true); } }); } return addAttributeButton; }
From source file:idontwant2see.IDontWant2See.java
public ActionMenu getButtonAction() { final ContextMenuAction baseAction = new ContextMenuAction(mLocalizer.msg("name", "I don't want to see!"), createImageIcon("apps", "idontwant2see", 16)); final ContextMenuAction openExclusionList = new ContextMenuAction( mLocalizer.msg("editExclusionList", "Edit exclusion list"), createImageIcon("apps", "idontwant2see", 16)); openExclusionList.putValue(Plugin.BIG_ICON, createImageIcon("apps", "idontwant2see", 22)); openExclusionList.setActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final Window w = UiUtilities.getLastModalChildOf(getParentFrame()); JDialog temDlg = null; if (w instanceof JDialog) { temDlg = new JDialog((JDialog) w, true); } else { temDlg = new JDialog((JFrame) w, true); }//from w w w. j a v a 2 s. c o m final JDialog exclusionListDlg = temDlg; exclusionListDlg.setTitle(mLocalizer.msg("name", "I don't want to see!") + " - " + mLocalizer.msg("editExclusionList", "Edit exclusion list")); UiUtilities.registerForClosing(new WindowClosingIf() { public void close() { exclusionListDlg.dispose(); } public JRootPane getRootPane() { return exclusionListDlg.getRootPane(); } }); final ExclusionTablePanel exclusionPanel = new ExclusionTablePanel(mSettings); final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { exclusionPanel.saveSettings(mSettings); exclusionListDlg.dispose(); } }); final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); cancel.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { exclusionListDlg.dispose(); } }); final FormLayout layout = new FormLayout("0dlu:grow,default,3dlu,default", "fill:500px:grow,2dlu,default,5dlu,default"); layout.setColumnGroups(new int[][] { { 2, 4 } }); final CellConstraints cc = new CellConstraints(); final PanelBuilder pb = new PanelBuilder(layout, (JPanel) exclusionListDlg.getContentPane()); pb.setDefaultDialogBorder(); pb.add(exclusionPanel, cc.xyw(1, 1, 4)); pb.addSeparator("", cc.xyw(1, 3, 4)); pb.add(ok, cc.xy(2, 5)); pb.add(cancel, cc.xy(4, 5)); layoutWindow("exclusionListDlg", exclusionListDlg, new Dimension(600, 450)); exclusionListDlg.setVisible(true); } }); final ContextMenuAction undo = new ContextMenuAction( mLocalizer.msg("undoLastExclusion", "Undo last exclusion"), createImageIcon("actions", "edit-undo", 16)); undo.putValue(Plugin.BIG_ICON, createImageIcon("actions", "edit-undo", 22)); undo.setActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { String lastEnteredExclusionString = mSettings.getLastEnteredExclusionString(); if (lastEnteredExclusionString.length() > 0) { for (int i = mSettings.getSearchList().size() - 1; i >= 0; i--) { if (mSettings.getSearchList().get(i).getSearchText().equals(lastEnteredExclusionString)) { mSettings.getSearchList().remove(i); } } mSettings.setLastEnteredExclusionString(""); updateFilter(true); } } }); return new ActionMenu(baseAction, new Action[] { openExclusionList, undo }); }
From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java
@Override public void showExceptionDialog(Throwable throwable, @Nullable String caption, @Nullable String message) { Preconditions.checkNotNullArgument(throwable); JXErrorPane errorPane = new JXErrorPaneExt(); errorPane.setErrorInfo(createErrorInfo(caption, message, throwable)); final TopLevelFrame mainFrame = App.getInstance().getMainFrame(); JDialog dialog = JXErrorPane.createDialog(mainFrame, errorPane); dialog.setMinimumSize(new Dimension(600, (int) dialog.getMinimumSize().getHeight())); final DialogWindow lastDialogWindow = getLastDialogWindow(); dialog.addWindowListener(new WindowAdapter() { @Override//from w w w . j a v a2s .c o m public void windowClosed(WindowEvent e) { if (lastDialogWindow != null) { lastDialogWindow.enableWindow(); } else { mainFrame.activate(); } } }); dialog.setModal(false); if (lastDialogWindow != null) { lastDialogWindow.disableWindow(null); } else { mainFrame.deactivate(null); } dialog.setVisible(true); }
From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java
/** * Shows the future event list.//from w w w .ja va2 s . c o m * * @since 0.3.0 */ public void viewFutureEventList() { final JDialog dialog = new JDialog(); dialog.setTitle("Future event list"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Id", "Time", "Priority", "Type", "To module", "Custom object"); Object[][] data = new Object[1][tableHeader.length]; DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); JTable table = new AdvancedJTable(model); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); PriorityQueue<SimEvent> futureEventList = simKernel.getSimCore().getFutureEventList().getPendingEvents(); if (!futureEventList.isEmpty()) { int numEvents = futureEventList.size(); SimEvent[] futureEventList_array = futureEventList.toArray(new SimEvent[numEvents]); Arrays.sort(futureEventList_array, futureEventList.comparator()); data = new Object[numEvents][tableHeader.length]; for (int eventId = 0; eventId < numEvents; eventId++) { // List<SimAction> actions = futureEventList_array[eventId].getEventActionList(); Object customObject = futureEventList_array[eventId].getEventObject(); data[eventId][0] = eventId; data[eventId][1] = StringUtils .secondsToYearsDaysHoursMinutesSeconds(futureEventList_array[eventId].getEventTime()); data[eventId][2] = futureEventList_array[eventId].getEventPriority(); data[eventId][3] = futureEventList_array[eventId].getEventType(); data[eventId][4] = futureEventList_array[eventId].getEventDestinationModule().toString(); data[eventId][5] = customObject == null ? "none" : customObject; } } model.setDataVector(data, tableHeader); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); table.setDefaultRenderer(Double.class, new CellRenderers.NumberCellRenderer()); dialog.setVisible(true); }
From source file:jatoo.proxy.dialog.ProxyDialog.java
/** * Shows the dialog relative to the specified owner. *///w w w. j av a 2s . com 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:com.paniclauncher.data.Settings.java
public void reloadLauncherData() { log("Updating Launcher Data"); final JDialog dialog = new JDialog(this.parent, ModalityType.APPLICATION_MODAL); dialog.setSize(300, 100);/*w w w. j a v a2 s.c om*/ dialog.setTitle("Updating Launcher"); dialog.setLocationRelativeTo(App.settings.getParent()); dialog.setLayout(new FlowLayout()); dialog.setResizable(false); dialog.add(new JLabel("Updating Launcher... Please Wait")); Thread updateThread = new Thread() { public void run() { checkForUpdatedFiles(); // Download all updated files reloadNewsPanel(); // Reload news panel loadPacks(); // Load the Packs available in the Launcher loadUsers(); // Load the Testers and Allowed Players for the packs reloadPacksPanel(); // Reload packs panel loadAddons(); // Load the Addons available in the Launcher loadInstances(); // Load the users installed Instances reloadInstancesPanel(); // Reload instances panel dialog.setVisible(false); // Remove the dialog dialog.dispose(); // Dispose the dialog }; }; updateThread.start(); dialog.setVisible(true); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
public void chooseLanguage() { final JDialog driver = new JDialog(mainframe, "Language", true); driver.setLayout(new GridBagLayout()); final String[] choices = translator.getLanguageList(); final JComboBox<String> language_options = new JComboBox<String>(choices); final JButton save = new JButton(">>>"); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.gridwidth = 2;/*from ww w . ja v a 2 s. co m*/ c.gridx = 0; c.gridy = 0; driver.add(language_options, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = 0; driver.add(save, c); ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); // TODO prevent "close" icon. Must press save to continue! if (subject == save) { translator.currentLanguage = choices[language_options.getSelectedIndex()]; translator.saveConfig(); driver.dispose(); } } }; save.addActionListener(driveButtons); driver.pack(); driver.setVisible(true); }