CAMD_3441
CAMD_3441

Reputation: 3154

Resizing a JTextArea within a jScrollPane?

I'm using Java 6, and I have a Dialog that uses Group layout with two panels side by side each with their own jTextArea. And each jTextArea is set within a jScrollPane.

The image below shows the two panels side by side. In a certain situation I want to hide the right panel, and have the left panel and its text area fill up the width of the screen.

enter image description here

So I used the setPreferredSize method on both the left panel and text area, and it resizes the Panel fine but it doesn't resize the JTextArea, it only updates the width of the scroll pane, and you see a scroll bar appear.

enter image description here

I saw another post that says to remove the JTextArea from the ScrollPane and resizing should work, but is there a way to keep them associated and still resize the JTextArea?

Upvotes: 0

Views: 177

Answers (1)

Arslan Farooq
Arslan Farooq

Reputation: 21

use setPreferredSize method on jscrollpane instead of textfield

Upvotes: 1

Related Questions