user225269
user225269

Reputation: 10913

new line in java

Java newbie here, I'm having trouble setting a new line in this code:

String FnameTextboxText   = FnameTextbox.getText();
          String LastnameTextboxText   = LastnameTextbox.getText();
            String CourseTextboxText   = CourseTextbox.getText();
                Summary.setText("Firstname:" + " " + FnameTextboxText + "\nLastname:" + " " + LastnameTextboxText + "\nCourse:" + " " + CourseTextboxText);

Also tried something like: "\n" + "Lastname" But its no good. Do you have any idea on how to make new lines. So that it'll look like this;

    Firstname: x 
   Lastname: y 
    Course: Z

Using netbeans 6.8. On windows.

Upvotes: 0

Views: 9443

Answers (2)

HungPV
HungPV

Reputation: 489

First, use TextArea Second, test using \r or \n or \r\n Sometimes, people use \n to make new line and sometimes, like me, use \r\n to make new line

Upvotes: 0

zs2020
zs2020

Reputation: 54514

I guess you need to use TextArea.

Upvotes: 2

Related Questions