aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Problem with JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Problem with JTextArea" Watch "Problem with JTextArea" New topic
Author

Problem with JTextArea

Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
I have a small problem with JTextArea, and I believe I know what causes it, but not sure how to correct it. When I call one in a frame it appears to just enough size to let the text I place in it show, but if now text then it appears very small. I think that has something to do with the FlowLayout, which I know is the defualt for the JFrame, and I know how to change it but to what, becuase I want to display multiple textarea/fields on one JFrame, like a form or something. Any help will be greatly appreciated
Thank you
Jesse
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / AWT / SWT / JFace forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
are you creating the textArea like this
new JTextArea()

or like this (as an e.g.)
new JTextArea(10,10)

Post your (compilable) code and explain what you think should happen
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
FlowLayout will respect the preferred size of the JTextArea. Ways to specify the size include setting the number of rows and columns, setting its preferred size, or, for fluid resizing behavior, adding it to the center section of a container with BorderLayout or adding it to a container with GridBagLayout (with appropriately set constraints of course). The default layout manager for JFrame is BorderLayout. FlowLayout is the default for JPanel and JApplet.
Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
My code is just new JTextArea(), nothing in the paraenthesis at all, what does the code in the paraenthesis do?
Thanks
Jesse
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1328
The arguments in the parentheses set the size of the JTextArea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JTextArea
 
Similar Threads
Frame problem "Java"?
Contents of JFrame not maximizing
JTextArea Scroll Focus
JTextArea
Problem in JFrame