I'm using JXMultiSplitPane
(from SwingX 1.6.2) to implement a three-pane horizontal interface. In the center pane is a JTabbedPane
with two tabs: one with a JTextArea
(in a JScrollPane
, of course) used for entering Markdown code and the other a JEditorPane
(again, in a scroll pane) for displaying a rendered HTML preview. When the user switches to the preview pane, the text in the editor is processed and displayed in the preview pane.
My problem is that if I enter text in the editor with long lines, and then switch to the preview, the center pane will expand. Sometimes it's just by a little bit, other times it'll take up more room than is actually on the screen. But if I move one of the resize handles manually, everything will snap back in place.
I've found only two ways to deal with this before it happens:
- Manually resize one of the panes before entering any text.
- Give the center pane a weight of 1 in the MultiSplitLayout model.
I can't use the second one since it will expand the center pane to take up almost the whole window by default.
Is there a way to fix this?
Update
After a little more testing, even technique (2) doesn't keep the size constant; switching between the two tabs changes the size of the center pane slightly.
I now believe that the problem is partly with the tabbed pane. The JTextArea
and the JEditorPane
do not have the same size and that JTabbedPane
is resizing when I switch between them (since I'm resetting the JEditorPane
text every time. This wouldn't be a problem except that JXMultiSplitPane
will keep automatically resizing the center pane until the user forces a specific size by resizing manually.
So I should be able to fix the issue by making the size of the JTabbedPane
fixed, but still able to be resized by the handle bars. Any tips on doing that?