Search code examples
javaswingjscrollpanejsplitpane

Swing JSplitPane problem


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


Solution

  • 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);