jQuery in Action, 2nd edition*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea" Watch "JTextArea" New topic
Author

JTextArea

Santosh Tripathi
Greenhorn

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?
Thanx
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Hi,
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
scrollPane.setViewportView(my_troublesome_text_area);
//Add the JScrollPane to the main content pane for the frame
mainContentPane.add(scrollPane);
Hope this helps!
cheers, Ben.


SCJP 1.4, www.gsi3d.org.uk
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

"santosh8"
your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea
 
Similar Threads
JtextArea problem
maximum allowed character in JTextArea
Fixing a JScrollPane to the bottom
Problem in changing the font
JTextField/JTextArea