private static int getReturnValue(JOptionPane optionPane) { Object value = optionPane.getValue(); if (value != null && optionPane.getOptions() != null){ value = Arrays.binarySearch(optionPane.getOptions(), value); } return (value != null) ? (Integer) value : JOptionPane.CLOSED_OPTION; }
private static int getReturnValue(JOptionPane optionPane) { Object value = optionPane.getValue(); if (value != null && optionPane.getOptions() != null){ value = Arrays.binarySearch(optionPane.getOptions(), value); } return (value != null) ? (Integer) value : JOptionPane.CLOSED_OPTION; }
private static int getReturnValueAsInteger(JOptionPane optionPane) { Object value = optionPane.getValue(); if(value == null) { return JOptionPane.CLOSED_OPTION; } Object[] options = optionPane.getOptions(); if(options == null) { if(value instanceof Integer) { return (Integer) value; } else { return JOptionPane.CLOSED_OPTION; } } for(int i = 0; i < options.length; i++) { Object valueAtIndex = options[i]; if(value.equals(valueAtIndex)) { return i; } } return JOptionPane.CLOSED_OPTION; }
@RunsInEDT static @Nonnull Object[] optionsOf(final @Nonnull JOptionPane optionPane) { Object[] result = execute(() -> optionPane.getOptions()); return checkNotNull(result); }
option = JOptionPane.CLOSED_OPTION; } else { if (pane.getOptions() == null) { if (value instanceof Integer) { option = ((Integer) value).intValue(); Object[] options = pane.getOptions(); for (int i = 0, n = options.length; i < n; i++) { if (options[i].equals(value)) {
public static int showDialog( JOptionPane op, Component parent, String title ) { final JDialog dlg; final Object value; final int result; dlg = op.createDialog( parent, title ); showDialog( dlg ); value = op.getValue(); if( value == null ) { result = JOptionPane.CLOSED_OPTION; } else { final Object[] options = op.getOptions(); if( options == null ) { if( value instanceof Integer ) { result = ((Integer) value).intValue(); } else { result = JOptionPane.CLOSED_OPTION; } } else { int i; for( i = 0; i < options.length; i++ ) { if( options[ i ].equals( value )) break; } result = i < options.length ? i : JOptionPane.CLOSED_OPTION; } } return result; }
protected Object[] getButtons() { if (optionPane != null) { Object[] suppliedOptions = optionPane.getOptions();