Questions tagged [jtextarea]

A JTextArea is a multi-line area that displays plain text.

A JTextArea is a multi-line area that displays plain text.
It is intended to be a lightweight Java Swing component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so.

2035 questions
68
votes
8 answers

How to set AUTO-SCROLLING of JTextArea in Java GUI?

I have embedded a JTextArea on a JScrollPane and am using that JTextArea for output. I want that whenever the ouput goes beyond the size of the JTextArea, the JTextArea scrolls automatically so that user don't have to do manual scroll down to see…
Amit
  • 33,847
  • 91
  • 226
  • 299
39
votes
8 answers

Java - checking if parseInt throws exception

I'm wondering how to do something only if Integer.parseInt(whatever) doesn't fail. More specifically I have a jTextArea of user specified values seperated by line breaks. I want to check each line to see if can be converted to an int. Figured…
Mike Haye
  • 793
  • 3
  • 12
  • 22
38
votes
7 answers

How to change text color in the JTextArea?

I need to know how to do this: Let's say: I have a code in the JTextArea like this: LOAD R1, 1 DEC R1 STORE M, R1 ADD R4, R1,8 I wanted to change the color of LOAD, DEC, STORE and ADD to color BLUE R1, R4 to color green M to RED numbers to…
Celine
  • 475
  • 1
  • 7
  • 7
36
votes
6 answers

How to wrap text in a JTextArea

I have a JTextArea in Java. When I place a large amount of text in it, the text area provides horizontal scrolling. How can I make my text area wrap instead?
Carlo
  • 1,147
  • 3
  • 15
  • 23
35
votes
4 answers

JTextArea: how to wrap text by words, not characters?

I want to avoid an output like this: Here is some text t hat is being wrappe d by characters, sp litting words in ha lf I am using a JTextArea, with setLineWrap(true). How can I make it wrap words, though? (Is there a way to make it only wrap when…
Cherie
  • 365
  • 1
  • 3
  • 5
35
votes
1 answer

Centering Text in a JTextArea or JTextPane - Horizontal Text Alignment

Is there a way to create horizontally centered text for a JTextArea like with a JTextField? setHorizontalAlignment(JTextField.CENTER); Is there a way I can accomplish the same thing with a multi-line text area? I can't find a method for it with…
Awaken
  • 1,243
  • 2
  • 14
  • 26
33
votes
4 answers

Add scroll into text area

How can I add the scroll bar to my text area. I have tried with this code but it's not working. middlePanel=new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Display Area")); // create the middle panel components display =…
Ravi
  • 401
  • 2
  • 8
  • 12
29
votes
3 answers

Add a new line to the end of a JtextArea

I have a text area with some text in it and I want to add some lines to it again, (the first lines + the other lines that I want to add) but it doesn't work. The way I'm doing it right now erases the old text and shows just the new lines.
Johanna
  • 27,036
  • 42
  • 89
  • 117
28
votes
4 answers

How to clear JTextArea?

I'm trying to clear the JTextArea. Currently, I'm using jtextarea.setText(null); What is the difference if I use jtextarea.setText("");
Lord Rixuel
  • 1,173
  • 6
  • 24
  • 43
22
votes
8 answers

Making a JScrollPane automatically scroll all the way down

I am trying to implement a JScrollPane with a JTextArea. The JTextArea is being appended to, and I want the JScrollPane to keep scrolling down as more text is added. How can this be achieved?
Krigath
  • 321
  • 1
  • 2
  • 6
21
votes
5 answers

Text-mouseover popups over a Swing JTextArea?

Is there anything out there that allows you to show a small text popup window (like a tooltip) over individual words or letters in a Swing JTextArea? (Or a JTextArea alternative with similar functionality.) What I need should behave like a tooltip,…
Manius
  • 3,594
  • 3
  • 34
  • 44
16
votes
5 answers

How to redirect console content to a textArea in Java?

I'm trying to get the content of console in a textArea in java. For example if we have this code, class FirstApp { public static void main (String[] args){ System.out.println("Hello World"); } } and I want to output the "Hello…
user618111
  • 439
  • 5
  • 15
  • 27
15
votes
2 answers

Automatically scroll to the bottom of a text area

I have a text area with scroll bar. At regular intervals, I am adding new lines of text to it. I would like the text area to automatically scroll to the bottom-most entry (the newest one) whenever a new line is added. How can I accomplish…
itro
  • 7,006
  • 27
  • 78
  • 121
15
votes
6 answers

JTextArea default font very small in Windows

I'm using platform look-and-fell and on Linux my JTextArea is pretty readable But on Windows it uses "Monospaced 9" and the text is very small. Why and what is the best way to fix that? Why default Windows look-and-fell uses such small font in…
Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305
15
votes
2 answers

How to use html tags in JTextArea

When I try to change color of a JTextArea using textArea.setText(" Hi ") , the text is shown is basically the whole text written inside setText method. But similar things work for JLabel, JButton etc. How…
user1508381
1
2 3
99 100