Jump to content
  • Advertisement
Sign in to follow this  
RobAU78

[java] Scrolling Map Using Swing

This topic is 4563 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!