• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JTextArea  RSS feed

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The arguments in the parentheses set the size of the JTextArea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!