aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to perform mouse listener for an open street map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to perform mouse listener for an open street map" Watch "how to perform mouse listener for an open street map" New topic
Author

how to perform mouse listener for an open street map

partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3379
    
    9
Can you show us what you have tried?
partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31


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
Bartender

Joined: Sep 20, 2010
Posts: 3379
    
    9
Where is the code that has your JLabels?
partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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
Bartender

Joined: Sep 20, 2010
Posts: 3379
    
    9
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?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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
Bartender

Joined: Sep 20, 2010
Posts: 3379
    
    9
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

Joined: Mar 13, 2011
Posts: 31
Yaaa! i did it. i used JSON and with the help of it i can able to perform the action.... Thanks for your guidance........
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to perform mouse listener for an open street map
 
Similar Threads
Href in Jtable(or similar action)
Mouse click event
some event in swing which is similar to mouse events, sensed throu touch screen
pop up window for OSM
is it possible to give info window in Open Street Maps in Java swing application