Im not sure why, but the slider only goes to the left and even locks the new position. It uses a modificated version of the NestedJSplitPane tutorial with JTree and JEditorPane. My guess is, that the JEditorPane causes the problem...
public frameMenu(){
JEditorPane htmlPane;
JTree parkSelect;
JTree triggerSelect;
URL helpURL;
DefaultMutableTreeNode left = new DefaultMutableTreeNode("Tree Left");
DefaultMutableTreeNode triggerTree = new DefaultMutableTreeNode("Tree Down");
//nNode.createNodes();
int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;
int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;
boolean continuousLayout = true;
parkSelect = new JTree(left);
parkSelect.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
htmlPane = new JEditorPane();
htmlPane.setEditable(true);
triggerSelect = new JTree(triggerTree);
triggerSelect.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, htmlPane, triggerSelect);
splitPane1.setOneTouchExpandable(true);
splitPane1.setDividerSize(2);
splitPane1.setDividerLocation(0.5);
JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, parkSelect, splitPane1);
splitPane2.setOneTouchExpandable(true);
splitPane2.setDividerLocation(0.4);
splitPane2.setDividerSize(2);
JFrame frame = new JFrame("Trigger Editor");
frame.setSize(600, 400);
frame.add(splitPane2);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
This is more of an snipped, but the problem is the same. Im not sure, how much code i could put in one post.
The up and down split can be slided without problems, but left and right causes problems.
the slider only goes to the left and even locks the new position
A JSplitPane
respects the minimums size of a component.
My guess is, that the JEditorPane causes the problem...
Correct, the minimum size of the JEditorPane appears to be equal to its preferred size.
You will need to override the getMinimumSize()
method of you JEditorPane
to return a more reasonable value for your requirments:
htmlPane = new JEditorPane()
{
@Override
public Dimension getMinimumSize()
{
Dimension d = super.getMinimumSize();
d.width = 100;
return d;
}
};