changeset 7:64334b3d9236

Use AppletContext when available to open URL.
author Mikhail Kryshen <mikhail@kryshen.net>
date Mon, 16 Jul 2012 07:16:44 +0400
parents 9d940c7ee4c0
children cf757c4466b8
files src/net/kryshen/charamega/ui.mirah
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/net/kryshen/charamega/ui.mirah	Mon Jul 16 06:30:28 2012 +0400
+++ b/src/net/kryshen/charamega/ui.mirah	Mon Jul 16 07:16:44 2012 +0400
@@ -262,7 +262,14 @@
 
   def processMouseEvent(event)
     if event.getID == MouseEvent.MOUSE_CLICKED
-      Desktop.getDesktop.browse @uri
+      # How to reference java.applet.Applet without importing?
+      root = SwingUtilities.getAncestorOfClass(JApplet.class, self)
+      if root
+        JApplet(root).getAppletContext.showDocument @uri.toURL
+      else
+        # Should work for applets too, but at least with IcedTea it does not.
+        Desktop.getDesktop.browse @uri
+      end
     end
 
     super