Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #5554
| Newsgroups | comp.lang.java.gui |
|---|---|
| Date | 2020-09-05 11:00 -0700 |
| References | <41A5232C.70F7@nospam_cox.net> |
| Message-ID | <1e02c3f7-4cf1-4603-8f95-7a180d622a82n@googlegroups.com> (permalink) |
| Subject | Re: JSplitPane resize woes |
| From | David Hilton <davidhilton68@gmail.com> |
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
Back to comp.lang.java.gui | Previous | Next | Find similar
Re: JSplitPane resize woes David Hilton <davidhilton68@gmail.com> - 2020-09-05 11:00 -0700
csiph-web