List of usage examples for javax.swing JOptionPane setInitialSelectionValue
@BeanProperty(description = "The option pane's initial selection value object.") public void setInitialSelectionValue(Object newValue)
From source file:eu.delving.sip.base.VisualFeedback.java
public static String askQuestion(JDesktopPane desktop, String question, Object initialSelectionValue) { final JOptionPane pane = new JOptionPane(question, QUESTION_MESSAGE, OK_CANCEL_OPTION, null, null, null); pane.putClientProperty(new Object(), Boolean.TRUE); pane.setWantsInput(true);//from w w w. j a va 2 s .co m pane.setInitialSelectionValue(initialSelectionValue); JDialog frame = pane.createDialog(desktop, "Question"); pane.selectInitialValue(); frame.setVisible(true); acquireFocus(); Object value = pane.getInputValue(); return value == UNINITIALIZED_VALUE ? null : (String) value; }