I have a class that extends JComponent called Canvas. Even when it's bigger than my JScrollPane's JViewport, the knobs will not appear on the scroll bars and I cannot scroll down on the Canvas. The code for my scroll pane is here:
final JFrame frame = new JFrame("SketchPad");
frame.setLayout(new BorderLayout());
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
JViewport vp = scrollPane.getViewport();
vp.setLayout(null);
vp.setBackground(Color.BLUE);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
canvas = new Canvas();
canvas.setBounds(0, 0, w, h);
vp.add(canvas);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Am I doing something wrong with the JScrollPane, or is it something else?