Example usage for javax.swing JOptionPane setInputValue

List of usage examples for javax.swing JOptionPane setInputValue

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The option pane's input value object.")
public void setInputValue(Object newValue) 

Source Link

Document

Sets the input value that was selected or input by the user.

Usage

From source file:JSliderOnJOptionPane.java

static JSlider getSlider(final JOptionPane optionPane) {
    JSlider slider = new JSlider();
    slider.setMajorTickSpacing(10);//from  ww w  .  ja  va  2  s . c  o  m
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JSlider theSlider = (JSlider) changeEvent.getSource();
            if (!theSlider.getValueIsAdjusting()) {
                optionPane.setInputValue(new Integer(theSlider.getValue()));
            }
        }
    };
    slider.addChangeListener(changeListener);
    return slider;
}

From source file:MessagePopup.java

public static JSlider getSlider(final JOptionPane optionPane) {
    JSlider slider = new JSlider();
    slider.setMajorTickSpacing(10);//from  w w  w . j a  va  2s .  com
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JSlider theSlider = (JSlider) changeEvent.getSource();
            if (!theSlider.getValueIsAdjusting()) {
                optionPane.setInputValue(new Integer(theSlider.getValue()));
            }
        }
    };
    slider.addChangeListener(changeListener);
    return slider;
}