Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea

 
Santosh Tripathi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic