JScrollPane « JSplitPane « Java Swing Q&A





1. Swing JSplitPane problem    stackoverflow.com

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

2. JSplitPane with JScrollPane    coderanch.com

import java.awt.*; import javax.swing.*; public class SplitScrolling { public static void main(String[] args) { JPanel bluePanel = new JPanel(); bluePanel.setBackground(Color.blue); bluePanel.setPreferredSize(new Dimension(400,400)); JPanel yellowPanel = new JPanel(); yellowPanel.setBackground(Color.yellow); yellowPanel.setPreferredSize(new Dimension(400,400)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(bluePanel), new JScrollPane(yellowPanel)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(splitPane); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); splitPane.setDividerLocation(0.5); } }