Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSplitPane set resizable false

Tags:

java

border

swing

How to make JSplitPane to resizable false? I didn't want to resize the JSplitPane, I used it for the border of this pane. Is there any other way to create same border structure to split a panel vertically into two parts.

like image 301
Tapas Bose Avatar asked Aug 15 '11 13:08

Tapas Bose


4 Answers

For preventing users to resize the panes you can also set the divider size to zero.

splitPane.setDividerSize(0);
like image 53
sers Avatar answered Nov 17 '22 13:11

sers


splitPane.setEnabled( false );
like image 22
camickr Avatar answered Nov 17 '22 12:11

camickr


You can override the JSplitPane methodes 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 ;
    }
};
like image 7
oliholz Avatar answered Nov 17 '22 13:11

oliholz


Consider for using Compound Borders with EtchedBorder

like image 3
mKorbel Avatar answered Nov 17 '22 13:11

mKorbel