• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to perform mouse listener for an open street map

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello...! i have a problem and i could not able to overcome it. I have two JPanels- one where some JLabels are placed and in another open street map is placed. Now i need to perform mouse listener for the JLables. If i clicked a JLabel then it must take me to that particular location of open street map. i am trying for more than a week but still cannot able to find any solution. please give me some suggestion.i have found one link but it does not work for me.....

http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html

If anyone come forward and give some suggestion then i would be very thankful to him/her. Please share your knowledge with me.......

Thanks.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us what you have tried?
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have used seperate classes. i returned the JPanel(mapContainer) and used in another JPanel(panel) class which contains a JPanel(labelPanel) with JLabels, using GridBagLayout. Now i need to use mouse listener from labelPanel, but i could not able to do it. please guide me......
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the code that has your JLabels?
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir, i don't know the proper code thats why i have not shown previously. Here it is.....

i tried the code.

Now i found the error in getInstance method giving errors---
Bound mismatch: The generic method getInstance(Class<T>) of type Application is not applicable for the arguments (Class<MapPanel>). The inferred type MapPanel is not a valid substitute for the bounded parameter <T extends Application>

and also in getContext() giving errors---
The method getContext() is undefined for the type MapPanel


Now i don't know how to do. please guide me as i don't know much about it. the second error i know that it is due to not defining the method getContext() in MapPanel. But i don't know what to put in that method.......... please show me a way. i am completely lost and cannot find any way to come out. please help me..... as i left only 10days to complete my work. i am searching in google but in vain. still trying.
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are using MapPanel.class as the argument to the Application.getInstance() method. The Application.getInstance() requires an argument of type Class<T extends Application>.

You you would need to call Application.getInstance(X.class), where X is Application or a subclass thereof. I don't know which are valid, because I don't have the API here. This should solve both your errors.

As for your JLabels, I don't know what problems you are experiencing, so I can't help you until you describe what it is you're getting stuck on. You know how to use MouseListeners, right?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solving the first error will fix the second one as well.

The first error message is quite clear. The generic type is bound to be Application or a subtype of it. You are now providing MapPanel.class which obviously does not extend Application. Change MapPanel.class to your Application subclass's Class object.
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to say that but i could not able to use mouse listener for open street map. i tried a lot. If possible please give me an example explaining this.......... i cannot find any way.... if you can please come forward and take me to the right track..... please guide me......please....
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

partha phukan wrote:Sorry to say that but i could not able to use mouse listener for open street map. i tried a lot.



Show us what you have tried. Don't hesitate to post wrong code, we can't see what the problem is if you don't.
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yaaa! i did it. i used JSON and with the help of it i can able to perform the action.... Thanks for your guidance........
 
reply
    Bookmark Topic Watch Topic
  • New Topic