I need to put a JSpinner
in a JOptionPane
. Here is what I've tried:
public void actionPerformed(ActionEvent event) {
SpinnerNumberModel Model = new SpinnerNumberModel(0.05, 0.00, 1.00, 0.01);
JSpinner spinner1 = new JSpinner(Model);
int option2 = JOptionPane.showOptionDialog(null, spinner1, "Input seuille", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
if (option2 == JOptionPane.CANCEL_OPTION) {
// user hit cancel
m = 0.05;
} else if (option2 == JOptionPane.OK_OPTION) {
// user entered a number
m = Double.parseDouble(spinner1.getValue().toString());
}
}
I need to get value fromjSpinner but it s not working