Pattern not coming in different lines

Like in the video, I have made a string “ans” and added the “\n” after every row but still when when it gets printed in the text field, the rows are not being printed in separate lines.

Here is my code:

String symbol = txtChar.getText();

//Get the no. of rows entered by user

    int n = Integer.parseInt(txtRows.getText());
    String ans = "";
    for(int row = 1; row <= n; row++){
        for(int col = 1; col <= row; col++){
            ans = ans + symbol;
        }
        ans = ans + "\n";
    }
    txtPattern.setText(ans);

hey @CCCB0035
I am getting the correct pattern from your code.code is fine

But in my Netbeans IDE, it is showing the output in the same line. Is there a way so that I can send you the screenshot… I am not able to copy paste the screenshot here.