On Thursday, 25 November 2004 at 00:11:24 UTC, Larry Coon wrote:
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.
Had exactly you problem, found this link which worked without any fiddling, just add the textArea to a scrollPane, then your scrollPane to your splitPane -
https://stackoverflow.com/questions/33198303/resizing-jtextarea-while-using-linewrap/33200995#
33200995
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)