dialog.dispose(); Object selectedValue = pane.getValue();
private void miProxy1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_miProxy1ActionPerformed ProxyPanel prp = new ProxyPanel(System.getProperty("http.proxyHost"), System.getProperty("http.proxyPort")); final JOptionPane optionPane = new JOptionPane(prp, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION, null, new String[] { "OK", "Cancel" }, "OK"); final JDialog dialog = new JDialog((Frame) null, "", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); if ("OK".equals(optionPane.getValue())) { System.setProperty("http.proxyHost", prp.getProxyHost()); System.setProperty("http.proxyPort", prp.getProxyPort()); } }// GEN-LAST:event_miProxy1ActionPerformed
dialog.dispose(); Object selectedValue = pane.getValue();
private void miProxy1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_miProxy1ActionPerformed ProxyPanel prp = new ProxyPanel(System.getProperty("http.proxyHost"), System.getProperty("http.proxyPort")); final JOptionPane optionPane = new JOptionPane(prp, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION, null, new String[] { "OK", "Cancel" }, "OK"); final JDialog dialog = new JDialog((Frame) null, "", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); if ("OK".equals(optionPane.getValue())) { System.setProperty("http.proxyHost", prp.getProxyHost()); System.setProperty("http.proxyPort", prp.getProxyPort()); } }// GEN-LAST:event_miProxy1ActionPerformed
dialog.dispose(); Object selectedValue = pane.getValue();
dialog.dispose(); Object selectedValue = pane.getValue();
@Override protected PasswordAuthentication getPasswordAuthentication() { PasswordPanel passP = new PasswordPanel(); final JOptionPane optionPane = new JOptionPane(passP, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new String[] { "OK", "Cancel" }, "OK"); final JDialog dialog = new JDialog((Frame) null, "", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); if ("OK".equals(optionPane.getValue())) { return new PasswordAuthentication(passP.getUser(), passP.getPassword()); } return null; } });
dialog.setVisible(true); if (!"Accept".equals(optionPane.getValue())) { System.out.println("License not accepted. Installation of component cannot proceed."); return false;
@Override protected PasswordAuthentication getPasswordAuthentication() { PasswordPanel passP = new PasswordPanel(); final JOptionPane optionPane = new JOptionPane(passP, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new String[] { "OK", "Cancel" }, "OK"); final JDialog dialog = new JDialog((Frame) null, "", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); if ("OK".equals(optionPane.getValue())) { return new PasswordAuthentication(passP.getUser(), passP.getPassword()); } return null; } });
dialog.setVisible(true); if (!"Accept".equals(optionPane.getValue())) { System.out.println("License not accepted. Installation of component cannot proceed."); return false;
&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue();
public String getDecisionValue() { return jOptionPane.getValue().toString(); } }
public void propertyChange( PropertyChangeEvent e ) { if ( pane.getValue() instanceof Integer ) { pane.removePropertyChangeListener( this ); preferenceDialog.dispose(); } }
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) { JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, optionType); JDialog dialog = pane.createDialog(parentComponent, title); dialog.setLocationByPlatform(true); dialog.setVisible(true); if (pane.getValue() instanceof Integer) return ((Integer) pane.getValue()).intValue(); return -1; }
JOptionPane pane = new JOptionPane("Message", JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog = pane.createDialog("TITLE"); dialog.setLocation(0, 0); dialog.setVisible(true); // dialog box shown here dialog.dispose(); Object selection = pane.getValue();
public static String getChoice(final Component owner, final List<String> list, final String question, final String title) { final String[] array = list.toArray(new String[list.size()]); final JOptionPane pane = new JOptionPane(question, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, array); pane.createDialog(owner, title).setVisible(true); return (String) pane.getValue(); }
JOptionPane optionPane = new JOptionPane("File haven't save yet." + " \n Are you want to save the file?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); JDialog dialog = optionPane.createDialog("Confirm Dialog"); Set<AWTKeyStroke> focusTraversalKeys = new HashSet<AWTKeyStroke>(dialog.getFocusTraversalKeys(0)); focusTraversalKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.VK_UNDEFINED)); dialog.setFocusTraversalKeys(0, focusTraversalKeys); dialog.setVisible(true); dialog.dispose(); int option = (Integer) optionPane.getValue();
public void propertyChange(PropertyChangeEvent e) { String value = (String) pane.getValue(); if (Res.getString("cancel").equals(value)) { pane.removePropertyChangeListener(this); dlg.dispose(); } else if (Res.getString("save").equals(value)) { pane.removePropertyChangeListener(this); dlg.dispose(); saveVCard(); } } };
public void propertyChange(PropertyChangeEvent e) { String value = (String) pane.getValue(); if (Res.getString("close").equals(value)) { pane.removePropertyChangeListener(this); dlg.dispose(); } else if (Res.getString("close").equals(value)) { pane.setValue(JOptionPane.UNINITIALIZED_VALUE); } } };