JSplitPane sets mutable false

How to make JSplitPane mutable false ? I did not want to resize JSplitPane , I used it for the border of this panel. Is there any other way to create the same border structure in order to split the panel vertically into two parts.

+9
source share
6 answers

You can override the JSplitPane getDividerLocation() and getLastDividerLocation and return a constant value.

 JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT){ private final int location = 100; { setDividerLocation( location ); } @Override public int getDividerLocation() { return location ; } @Override public int getLastDividerLocation() { return location ; } }; 
+7
source
 splitPane.setEnabled( false ); 
+24
source

Consider using Compound Borders with EtchedBorder.

+3
source

To prevent users from resizing panels, you can also set the separator size to zero.

 splitPane.setDividerSize(0); 
+2
source
 final double pos = split.getDividers().get(0).getPosition(); split.getDividers().get(0).positionProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { split.getDividers().get(0).setPosition(pos); } }); 
+1
source

As noted in the comments to @camickr's answer, disabling the entire split panel can disable the interactive behavior of the contained components (for example, when you hover over them, they will not display their interactive cursors).

instead, if BasicSplitPaneUI is used, you can disable the delimiter from the user interface

  public void setResizable(boolean resizable) { BasicSplitPaneUIui = (BasicSplitPaneUI) this.getUI(); ui.getDivider().setEnabled(resizable); } 
0
source