Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

dynamically set JTextArea dimensions

Posted on 2006-04-10
1
Medium Priority
?
700 Views
Last Modified: 2008-03-04
Any pointers or examples in setting a JTextArea to the same width as a JPanel, but specifing a height?

And if the JFrame that contains the JPanel is extended (dragged bigger|smaller), resize the JTextArea to fit.
0
Comment
Question by:ellandrd
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 16422085
try something like:

JPanel panel = new JPanel(new BorderLayout());
JTextArea ta = new JTextArea();
JScrollPane sp = new JScrollPane(ta);
sp.setPreferredSize(new Dimension(Integer.MAX_VALUE, desiredHeight));
sp.setMaximumSize(new Dimension(Integer.MAX_VALUE, desiredHeight));
panel.add(BorderLayout.NORTH, sp);

you can get rid of the scroll pane if you don't want one. in which case set the preferred size of the ta
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question