Help with incrementing numbers in a GUI
I have a GUI that I want to display a number (in a JTextArea) incremented by one and decreased by one when I click on the corresponding button. It will start from 0. So clicking the increase button twice will print 1 on the next line then 2 on the next line in the area. I already have the GUI set up.
My question is how I would go about having my program read the latest line and increment that by one.
I currently have
but that one works from 0 to 1, clicking the button returns an error, I believe because it is trying to read both of the lines. (Note: I need to keep the numbers in the field and cannot erase them when I increment)
int value = (Integer.parseInt(jtaArea.getText()) + 1);
jtaArea.append("\n" + Integer.toString(value));
Thanks in advance for any help.