Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Inserting a map in Java Desktop Application

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Inserting a map in Java Desktop Application

    I am doing a Java Desktop application and I wish to implement a map that can be zoom in and zoom out, and also get coordinate of a location. What I need is just a very small area map.

    I tried to google and found this link.
    http://today.java.net/pub/a/today/20...mapviewer.html

    However, my program give me an error state that the image tile is failed to load from the server.

    I tried to find other way to implement a map but most of it implement using javascript.
    Can anyone tell me how to insert a map in Java desktop application. the application will be used offline after this.Thanks!


  2. #2
    Junior Member
    Join Date
    Nov 2012
    Posts
    9
    My Mood
    Cold
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Inserting a map in Java Desktop Application

    This is my take in this. forgive me if its wrong.

    1. Declare Image Icon objects, initialize them to take a image path parameter
    2.Declare and initialize Image objects to get the image of the preloaded ImageIcon objects .getImage() ;
    3. Add an anonymous key lister or a key lister class and override the methods of the KeyAdapter.
    4. with in overrode key methods set the preloaded ImageIcons to be a new ImageIcon and pass in a different image path as the parmameter.

    note: Each of the preloaded imageIcons should be a path to an image that is cropped or larger to create the illusion of zooming on key press.
    You must call repaint() during each key press to repaint the graphics of the application.

    Alterantivley: You could create a method that takes an Image as a parameter and handle the changing image path based on the parameter passed in.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Inserting a map in Java Desktop Application

    A problem you may have is that a map is more than just an image, especially if you want to zoom in and out without degrading the quality of what the user sees. In my opinion, this may be better accomplished with use of vector graphics rather than the typical Java raster graphics since the former would scale well. I will add the caveat that I myself have never done this and so cannot say that I've tested any of this. Also if you could search some more and find and use a well crafted ready-made solution, you'll of course be a step ahead of the game.

    Also regarding Steven Bishop's advice, he has some useful recommendations, but I would strongly recommend that you avoid using KeyListeners or KeyAdapters with Swing applications. Much better would be to use AbstractActions tied to key bindings as well as button, menu, and even mouse events.

  4. #4
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Inserting a map in Java Desktop Application

    Quote Originally Posted by curmudgeon View Post
    A problem you may have is that a map is more than just an image, especially if you want to zoom in and out without degrading the quality of what the user sees. In my opinion, this may be better accomplished with use of vector graphics rather than the typical Java raster graphics since the former would scale well. I will add the caveat that I myself have never done this and so cannot say that I've tested any of this. Also if you could search some more and find and use a well crafted ready-made solution, you'll of course be a step ahead of the game.

    Also regarding Steven Bishop's advice, he has some useful recommendations, but I would strongly recommend that you avoid using KeyListeners or KeyAdapters with Swing applications. Much better would be to use AbstractActions tied to key bindings as well as button, menu, and even mouse events.
    yes, You got my point, it is not just an image.I am trying to search a well crafted ready-made solution. I believe there must be some way in doing this. Currently I am trying Geotools. Anyone has experiences in using this? I am still a beginner.

    thanks for your reply

Similar Threads

  1. Creating a Java Desktop Application in NetBeans
    By cslx99 in forum Java Theory & Questions
    Replies: 5
    Last Post: December 2nd, 2012, 12:25 AM
  2. NetBeans Desktop Application in Java
    By knightmetal in forum Java IDEs
    Replies: 5
    Last Post: November 9th, 2011, 05:47 AM
  3. Updatable Java Desktop Application
    By Onur in forum Java Theory & Questions
    Replies: 3
    Last Post: September 18th, 2011, 03:15 PM
  4. Replies: 0
    Last Post: December 3rd, 2009, 03:43 PM

Tags for this Thread