I've reduced my problem to a short, self-contained example,
below. I have a JFrame that has a JSplitPane, that has a
JTree (left) and JTextArea (right). I can't get resize
behavior to work correctly. I've tried many combinations of
setting minimum size & preferred size on each/all of the
components, but nothing did what I wanted. Here's a minimal
example:
import java.awt.*;
import javax.swing.*;
public class SplitPaneDemo extends JFrame {
public SplitPaneDemo() {
super("Split Pane Demo");
Container container = getContentPane();
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(new JTree());
JTextArea textArea = new JTextArea();
splitPane.setRightComponent(textArea);
textArea.setLineWrap(true);
container.add(splitPane, BorderLayout.CENTER); setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(500, 500);
setVisible(true);
}
public static void main(String[] args) {
new SplitPaneDemo();
}
}
If I dont setLineWrap(true) then I can move the JSplitPane's
separator bar correctly. As it is here, I can move it left,
but not right. It seems like the JTextArea is resizable
bigger, but not smaller, when LineWrap is true.
My actual program is a lot more involved (the right hand side
is a JTextArea in a JPanel (along with other components) on
a JTabbedField on the right hand side of the JSplitPane), but
I'm obviously missing something basic. What's the CORRECT
way to get the above working correctly?
Thanks.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 62:38:11 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,627 |