I have a JTextField and need to have 3 lines in it, such as these:
HI
MY name
is mehdi
How can I set the text in a JTextField? I tried \n, but it didn’t work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1 : JTextField does not support multiline. what you want is a JTextArea
2 : Newlines aren’t the same on all systems, you might have to use
"\r\n"if you are running Windows. Since Java 7, there isSystem.LineSeparatorto solve this issue.(see the Oracle documentation)