English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I implement break line in setText? It seems that everytime a set a text on the textfiled it always tops the second one.......... What should I use?? this is the code on where I want to put it.

textarea.setText(com1+"")


All have been instantiated and declared properly. com1 is an integer........

Im using both java.awt and javax.swing.........

2007-08-21 00:48:46 · 2 answers · asked by Bob 3 in Computers & Internet Programming & Design

2 answers

To break a line in a jTextField, use the "\n" character to create a new line: textarea.setText("line 1\nline 2");
That will hard code a line break, but that isn't always what you want. Sometimes you'd like the line breaks to move depending on the size of the container, and there you should use setLineWrap(true) and setWrapStyleWord(true).

2007-08-21 01:14:29 · answer #1 · answered by Dr.Mr.Ed 5 · 1 0

So what you are trying to achieve is
textarea.setText(textarea.getText() + com1)

Oh, in fact that will do it.

2007-08-21 08:02:04 · answer #2 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers