I want to make a simple program where the user puts a number in JSpinner
and, when clicking a button, it will appear in another JSpinner
, the value of the first added by 2.
However, I can not make the sum between the value indicated in JSpinner
and 2, because the value of JSpinner
is not considered int
. How do I do?
Here is a sample code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Object w = jSpinner2.getValue();
jSpinner1.setValue(w+2); //Aqui acontece o erro
//JSpinner1 é o valor final.
//JSpi nner2 é o valor indicado pelo usuario.
}