Forum Stats

  • 3,840,394 Users
  • 2,262,599 Discussions


help in displaying textfield data in a textarea

edited Jul 10, 2019 8:04PM in Java Programming

hello nice to be on this forum. i am learning Java and i am building an application. i am using netbeans as my IDE. i have a text area ,  text fields  and a button to generate a receipt in the text area when clicked( fill the data  in the text field in the text area so i can print as a receipt. Iwant to to write a code that when the button is clicked, the data in the text field is displayed in the text area and if another data is entered and clicked it will be displayed in the next row. this is the code i have used: textarea.setText("****************************************************************************\n");       String fun,fun2;       fun = textfield.getText();       fun2 = textfield.getText();     textarea.setText(textarea.getText()+fun + "\n" +fun+"\n");     textarea.setText(textarea.getText()+"Item        Dimension              Quantity            Price " ); this code works when a button is click  but when i enter new information it overrides the existing which is not what i want i need help please