I'm working right now on a project, and I can't find a solution for my problem.
So here is my problem: I have a JFrame, then I add a container JPanel, and I add 2 other JPanel to this container panel , first panel (InputPanel) is for user input, second panel (Board) for displaying the specified algorithm based on the user input.
But the displayed algorithm is too large, so I thought I will add a JScrollPane to the DisplayPanel, but it didn't worked like I thought it would have. Here is a picture, the red rectangle is the area what changed after I added the JScollPane: 
Notice that at my Board class I override the paintComponent(Graphics g) to draw the algorithm.
My code in the main frame:
container = new JPanel();
container.setLayout(new BorderLayout());
board = new Board();
container.add(board, BorderLayout.CENTER);
inputPanel = new InputPanel(board);
container.add(inputPanel, BorderLayout.SOUTH);
pane = new JScrollPane(board);
pane.setViewportView(board);
pane.setPreferredSize(new Dimension(700, 0));
container.add(pane, BorderLayout.WEST);
add(container);
My initial plan was to add a horizontal scrollpane to the Board panel. Can somebody post an example code, or point out for my problem pls?