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.
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 is System.LineSeparator
to solve this issue.
(see the Oracle documentation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With