2

I have a problem which I am currently trying to wrap my head around, and any advice or nods in a good direction would be greatly appreciated.

  1. I want to display a Google Map within my Java Swing project, (the map will be a URL specified within an HTML document I think).

  2. I also want to be able to communicate and interact with the map using JavaScript, injected via buttons in java swing, etc. So for example, I could have java buttons 'Satellite', 'Hybrid', and 'Earth' next to the map, and clicking them would perform the corresponding javascript action on the map. JavaScript methods would probably already be created within the HTML file (such as 'switchToSatelliteMap'), it would just be a matter of calling them within Java.

Thanks in advance for any help whatsoever,

tre.

tre
  • 235
  • 1
  • 2
  • 8

2 Answers2

0

I don't know whether this answers your question at all, but I think you will find these links helpful:

  1. http://today.java.net/article/2007/10/24/building-maps-your-swing-application-jxmapviewer
  2. http://swinglabs.org/downloads.jsp
  3. GoogleEarth inside Java Swing
  4. Is there a Swing component for Google Maps?
  5. http://code.google.com/p/gameplan/source/browse/trunk/src/org/crazydays/gameplan/map/swing/JMapFrame.java?spec=svn62&r=62

I am more of a SWT fan, so I would have used a browser control as it allows me to execute javascript on the browser component. But again its a design choice.

Hope this will help.

Community
  • 1
  • 1
Favonius
  • 13,959
  • 3
  • 55
  • 95
0

I am not entirely clear on the scope of your issue, but you may find it helpful to attach MouseListener interfaces to your swing buttons

http://download.oracle.com/javase/7/docs/api/java/awt/event/MouseListener.html

http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html

Implementing the mouseClicked method to run the required java script.

Additionally you could use a MouseAdapter if all you need is the mouseClicked functionality.

D-zer0
  • 63
  • 6