Scrolling Backgrounds

I'm attempting to program a game that will require a scrolling background, but I'm not 100% sure what classes to use. I was looking into JViewport -- it certainly sounds like what I want, but like I said I'm not totally sure. Any information would be greatly appreciated.
[288 byte] By [L337H8R] at [2007-9-30 12:27:42]
# 1

use a rectangle to tell what's visible. Make it the dimensions of the screen. You subtract it's x and y coordinates from the coordinates of images you want to draw, and you can tell if something's on the screen if the object's bounds interesects your screen rectangle. You don't need any Swing ****

Malohkan at 2007-7-4 15:57:35 > top of Java-index,Other Topics,Java Game Development...
# 2
Really? No Swing? How would you get the Image(s) to show up?
L337H8R at 2007-7-4 15:57:35 > top of Java-index,Other Topics,Java Game Development...
# 3

I have a background image that I paint over each frame that I create withVolatileImage offImage = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleVolatileImage(width, height);

and in my game I create a Graphics2D object withg2d = (Graphics2D)offImage.getGraphics();

and I do all my drawing onto g2d. When I want offImage painted to the screen, I callgetGraphics().drawImage(offImage, 0, 0, null);

voila, no Swing :) All you need for getGraphics() to work is to be working in an Applet or a Frame.

Malohkan at 2007-7-4 15:57:35 > top of Java-index,Other Topics,Java Game Development...
# 4
Hmmm...well, I'm thinking of putting a command panel on one side so I don't want the whole screen taken up. I'm sure your method can be extended to support such additions...thank you for the information.
L337H8R at 2007-7-4 15:57:35 > top of Java-index,Other Topics,Java Game Development...
# 5

for simple games when I do that I just say if this item is in the right panel, add on the x coordinate of the panel to anything I draw for it, so's to keep up with the placement of all my items on the panel.

For more complicated games, I'd make a separate class for the panel. When I call it's render() method I'd have it draw onto a BufferedImage of the dimenions of the panel, and then plop that on my screen. So all the panel's knowledge of pixel placement is relative to the panel, but you can handle the offset of the panel itself by choosing where you place that BufferedImage on the screen.

Malohkan at 2007-7-4 15:57:35 > top of Java-index,Other Topics,Java Game Development...