Swing JSplitPane problem

2019-07-17 10:28发布

How to Split Component vertically into different parts? Is It possible in Swing? I want to assign different ScrollBar to each part ?

2条回答
我只想做你的唯一
2楼-- · 2019-07-17 10:42

Try using JSplitPane. Then put a JScrollPane into each side.

If you want more than one split, you'd have to nest the split panes. Or use a multi-splitpane like this: MultiSplitPane

查看更多
我只想做你的唯一
3楼-- · 2019-07-17 10:58

you should use the JSplitPane

if you need each part to be on a diffrent scroller - just put them on to diffrent scroller pane.

JPanel topPanel = new JPanel();
            JScrollPane topScrollPane = new JScrollPane(topPanel);

            JPanel buttomPanel = new JPanel();
            JScrollPane buttomScrollPane = new JScrollPane(buttomPanel);

            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topScrollPane, buttomScrollPane);
查看更多
登录 后发表回答