Making a map program
Hey everyone, I've been trying to create a simple map program using different methods, but they have all fallen short.
What I'm trying to create is a map program in which an image is loaded and on top of this image buttons are placed on specified areas, so that when a user clicks these buttons, a pop-up box will be displayed with information about that area/building. I would like the image along with the overlaying buttons to be in a JScrollpane and I will be adding click and drag support so the scroll bars aren't the only way to navigate around the map. I'll be adding this scrollpane to a JFrame which will also have a panel that holds controls.
I've tried using a JLayeredPane to hold a panel with the image, and then add the buttons over it, but I can't seem to get the buttons to draw correctly. I've also tried using the OverlayLayout, but without much success.
I was wondering if anyone could point out a better technique of developing an application like this. Should I be using Java2D instead of the methods I've tried?
I don't think that you need to go to the trouble of using JLayeredPane or OverlayLayout as the image can be simply a JPanel's background image painted in a paintComponent override. I think layered panes are useful when dragging images or components on top of another, such as in a chess or checkers game, but your images are static and so this is not required.
Originally Posted by cchase88
Also, I would solve one issue at a time in isolation of the others though rather than trying to solve the whole thing in one big huge program.