0
I want to make a simple program where the user puts a number on a JSpinner
and, at the click of a button, will appear in another JSpinner
, the value of the first summed by 2.
However, I cannot sum the value indicated in JSpinner
and 2, because the value of JSpinner
is not considered int
. How do I do?
Here’s a sample of the 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.
}
Have you tried parsing for int?
– user28595
Sorry I’m new in java, could you explain to me what is a parse int?
– Guilherme Figueira