-
JTextArea
Hey guys I had a question about JTextArea. I'm making a simple program to be a restaurant menu and when I click on a button it displays the name and the price of the item in the text area and when I click a different button it'll replace the previous line and it doesn't keep on going to the next line. Is there a certain command that I need to add or anything for it to do that?
-
did you try using setText()? You can design the button to set the text to be empty, and then add the item to the text area.
-
.append
Actually I found out what the problem was haha the problem was actually setText because everytime I was going to write to the text area i was using .setText and what I didn't know was that setText itself erases what was there originally and then replaces it with whatever. The solution was to use .append and that just goes onto the next line and doesn't erase what was there