Sign in to follow this  

[java] Scrolling Map Using Swing

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings, everyone! I've started to get back into game coding again, after taking something of a hiatus. One thing I'm working on now is getting a scrolling map to work using the Swing framework. So I was wondering if anyone has made one already and/or any suggestions that anyone might have about making one. For example, I think I should use a JViewport for the scrolling "window", but I could be wrong. Also, what type of JComponent should I use to draw the base map? Two types that stand out to me are JLabel and JPanel, but there might be a better way. Anyways, I look forward to the responses. :) - Rob

Share this post


Link to post
Share on other sites
Are you trying to implement 2D scrolling, or do you simply want to draw a large picture at a smaller screen area?

If the first case, you'll do it using Java2D, for example. Good old algorithm that calculates offset of the center and draws the Image using the Graphic2D instance of the component you're drawing at.

If the latter, you will simply want to add a JLabel centered on a JPanel, nested with a JScrollPane.

Son Of Cain

Share this post


Link to post
Share on other sites

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this