Example usage for javax.swing JOptionPane setInitialSelectionValue

List of usage examples for javax.swing JOptionPane setInitialSelectionValue

Introduction

In this page you can find the example usage for javax.swing JOptionPane setInitialSelectionValue.

Prototype

@BeanProperty(description = "The option pane's initial selection value object.")
public void setInitialSelectionValue(Object newValue) 

Source Link

Document

Sets the input value that is initially displayed as selected to the user.

Usage

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;
}