Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

help in displaying textfield data in a textarea

c9395649-e17c-4fbb-ab77-b01b8c03a5caJul 10 2019 — edited Jul 10 2019

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

Comments

Post Details

Added on Jul 10 2019
1 comment
167 views