final JButton okay = new JButton("Ok"); okay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane pane = getOptionPane((JComponent)e.getSource()); // set the value of the option pane pane.setValue(JOptionPane.OK_OPTION); } });
@Override public void actionPerformed(ActionEvent event) { optionPane.setValue(1); } });
public void actionPerformed(ActionEvent e) { jOptionPane.setValue(buttonLabels[0]); } });
public void windowClosing(WindowEvent we) { optionPane.setValue(JOptionPane.NO_OPTION); } });
@Override public void componentShown (ComponentEvent ce) { // reset value to ensure closing works properly pane.setValue(JOptionPane.UNINITIALIZED_VALUE); } });
public void componentShown(ComponentEvent ce) { // reset value to ensure closing works properly pane.setValue(JOptionPane.UNINITIALIZED_VALUE); } });
public void windowClosing(WindowEvent we) { // // Instead of directly closing the window, // we're going to change the JOptionPane's // value property. // optionPane.setValue(new Integer( JOptionPane.CLOSED_OPTION)); } });
public void windowClosing(WindowEvent we) { jOptionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); } });
public void windowClosing(WindowEvent we) { /* * Instead of directly closing the window, * we're going to change the JOptionPane's * value property. */ optionPane.setValue(new Integer( JOptionPane.CLOSED_OPTION)); } });
public void windowClosing(WindowEvent we) { jOptionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); } });
/** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed( final ActionEvent aEvent ) { final JOptionPane optionPane = ( JOptionPane )aEvent.getSource(); optionPane.setValue( Integer.valueOf( JOptionPane.CLOSED_OPTION ) ); } }
/** {@inheritDoc} */ @Override public void mouseClicked(final MouseEvent me) { if (me.getClickCount() == 2 && this.optionPane != null && !this.disableSelection) { this.optionPane.setValue(Integer.valueOf(JOptionPane.OK_OPTION)); } }
@Override public void actionPerformed(ActionEvent e) { JOptionPane pane = getOptionPane((JComponent)e.getSource()); pane.setValue(JOptionPane.CANCEL_OPTION); } });
private void closeDialog(boolean okay) { for (Container parent = getParent(); parent != null; parent = parent.getParent()) { if (parent instanceof JOptionPane) { ((JOptionPane)parent).setValue(okay ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION); } else if (parent instanceof JDialog) { ((JDialog)parent).setVisible(false); break; } } }
JOptionPane optionPane= new JOptionPane("message", JOptionPane.OK_CANCEL_OPTION); final JDialog dialog = optionPane.createDialog(null, "Input"); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { optionPane.setValue(JOptionPane.CANCEL_OPTION); } }); if (JOptionPane.CANCEL_OPTION!= ((Integer) optionPane.getValue()).intValue()) throw new myCancellationException();
@Override public void actionPerformed(ActionEvent e) { final Component source = (Component) e.getSource(); JOptionPane pane = (JOptionPane) SwingUtilities.getAncestorOfClass(JOptionPane.class, source); pane.setValue(source); } }
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { dialog.setVisible(false); pane.setValue(JOptionPane.OK_OPTION); dialog.dispose(); } } });
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); } } };
@Override public void actionPerformed(ActionEvent e) { JOptionPane pane = getOptionPane((JComponent)e.getSource()); pane.setValue(JOptionPane.OK_OPTION); doOpen(panel.getChosenRegistry(), panel.getChosenFamily(), panel.getChosenComponent(), panel.getChosenComponentVersion()); } });