The moose likes Swing / AWT / SWT / JFace and the fly likes Fixing size of components in JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Fixing size of components in JFrame" Watch "Fixing size of components in JFrame" New topic
Author

Fixing size of components in JFrame

abhi narkar
Greenhorn

Joined: Nov 24, 2010
Posts: 3
I am trying to create a JFrame having a label and JTextArea. The problem is I want to restrict the size of JTextArea to say 3 rows and 20 columns, even if my JFrame is stretched to various sizes. The setSize method doesnt seem to be working in this case. Can anything be done so that JTextArea's size be restricted whatever the size of frame?
Michael Dunn
Rancher

Joined: Jun 09, 2003
Posts: 4041
put the JTextArea/JScrollPane into a JPanel (with suitable layoutManager).
give the scrollPane a preferredSize, then add the panel to the frame.
the panel will take up any additional space from resizing
abhi narkar
Greenhorn

Joined: Nov 24, 2010
Posts: 3
Thanks. It worked.
 
 
subject: Fixing size of components in JFrame
 
Threads others viewed
JTextArea size increase as size of font increase
Need Help resizing my JScrollPane
Problem in JFrame
Problem with JTextArea
Cut and Paste, what is the difference with ContentPane and a Panel?
developer file tools