Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea" Watch "JTextArea" New topic


Santosh Tripathi

Joined: Jul 27, 2001
Posts: 9
Dear Friends,
I have a problem with JTextArea.I've defined the JTextArea constructor with 2rows and 2 cols.Now when i enter text into it and press enter key again and again, then instead of an appreance of a scrollbar the area of the JtextArea keep increasing, this results in the shrinking of other JtextField/JTextarea.
Can we Fix this area Of the JTextArea anyhow/or is there any other way to solve this problem?
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Have you defined a scroll pane to put the text area into? If not, try somethign like this:
//Create a new JScrollPane
JScrollPane scrollPane = new JScrollPane();
//Add the JTextArea to the JScrollPane
//Add the JScrollPane to the main content pane for the frame
Hope this helps!
cheers, Ben.

SCJP 1.4,
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: JTextArea
It's not a secret anymore!