I've been trying for hours to get a simple scrolling panel. Let's say I'm trying to display a large image on a panel (too large to be seen all at once) and therefor want to be able to move the panel displaying this image around using setLocation() prompted by some method we'll call scroll(). I am aware of scroll panels that require the mouse to move the bars on the side, but I do not want this. I want it to move based off of a keyboard input/method call. How do I fix this? Here's a basic version of what I'm doing:
Frame f = new JFrame();
Panel p = new JPanel();
f.setSize(2000,2000);
p.setLocation(X, Y);
f.getContentPane().add( mainPanel);
f.repaint();
This will display the JPanel at the same location, no matter what X and Y are. If I set the layout to null it doesn't display at all. Please help me