I have some JTextfield
s which change based on certain events, for example if a box is ticked, the content of the text field changes from 0
to 35
.
I am trying to add the values of the text fields together but can't seem to do it.
int f1 = 35;
int f2 = 18;
apple.setText("" + f1);
pear.setText("" + f2);
Here's what I have so far
int result = Integer.parseInt(apple.getText() + Integer.parseInt(pear.getText());
total.setText("" + result);
The result gives me 3518
when I need it to add f1
and f2
together