checkin from browser
authorcg
Thu, 23 Dec 1999 18:07:52 +0000
changeset 644 0294a6ed677e
parent 643 2b7092ad9fa1
child 645 263dae17fe9e
checkin from browser
JavaEmbeddedFrameView.st
examples/JavaAppletDemo1.st
--- a/JavaEmbeddedFrameView.st	Thu Dec 23 18:07:26 1999 +0000
+++ b/JavaEmbeddedFrameView.st	Thu Dec 23 18:07:52 1999 +0000
@@ -462,10 +462,14 @@
 !JavaEmbeddedFrameView methodsFor:'private'!
 
 setupAppletFrameIn:anAppletContextOrNil
+     ^ self setupAppletFrameIn:anAppletContextOrNil initializeJava:true.
+!
+
+setupAppletFrameIn:anAppletContextOrNil initializeJava:initializeJava
      |appletContext
      jEmbeddedAppletFrameClass jDerivedAppletFrameClass
      toolkit peer attribs id
-     jCodeBaseURL jDocumentURL jArchiveURL|
+     jCodeBaseURL jDocumentURL jArchiveURL u fn|
 
     embeddedAppletFrame notNil ifTrue:[
         "/ already setup
@@ -476,11 +480,29 @@
         ^ self
     ].
 
-    Java startupJavaSystem.
+    initializeJava ifTrue:[
+        Java startupJavaSystem.
+    ].
 
-    jCodeBaseURL := Java as_URL:codeBaseURL.
+    "/ if its a relative file-URL, make it relative under
+    "/ java...
+    u := URL fromString:codeBaseURL.
+    u method = 'file' ifTrue:[
+        fn := Smalltalk getSystemFileName:u file.
+        fn isNil ifTrue:[
+            fn := Smalltalk getPackageFileName:('stx/libjava/' , u file).
+        ]
+    ].
+    fn notNil ifTrue:[
+        fn := 'file:' , fn asFilename pathName
+    ] ifFalse:[
+        fn := codeBaseURL
+    ].
+    jCodeBaseURL := Java as_URL:fn.
     documentURL notNil ifTrue:[
         jDocumentURL := Java as_URL:documentURL.
+    ] ifFalse:[
+        jDocumentURL := Java as_URL:fn
     ].
     archiveURL notNil ifTrue:[
         jArchiveURL := Java as_URL:archiveURL.
@@ -498,136 +520,10 @@
     attribs := Dictionary new.
     width notNil ifTrue:[attribs at:'width' put:width printString].
     height notNil ifTrue:[attribs at:'height' put:height printString].
-    codeURL notNil ifTrue:[attribs at:'code' put:codeURL].
-    parameterDictionary notNil ifTrue:[
-        attribs declareAllFrom:parameterDictionary
-    ].
-    attribs := Java as_Hashtable:attribs.
 
-    anAppletContextOrNil notNil ifTrue:[
-        appletContext := anAppletContextOrNil
-    ] ifFalse:[
-        appletContext := self newAppletContext.
-        appletContext isNil ifTrue:[
-            self warn:'no netscape.applet.MozillaAppletContext class'.
-            ^ false
-        ].
-    ].
-
-    jEmbeddedAppletFrameClass := Java classForName:'netscape.applet.EmbeddedAppletFrame'.
-    jEmbeddedAppletFrameClass isNil ifTrue:[
-        self warn:'no netscape.applet.EmbeddedAppletFrame class'.
-        ^ false
-    ].
-    jDerivedAppletFrameClass := Java classForName:'netscape.applet.DerivedAppletFrame'.
-    jDerivedAppletFrameClass notNil ifTrue:[
-        "/ ns4.0
-        embeddedAppletFrame := jDerivedAppletFrameClass new.
-        isNS40 := true.
-    ] ifFalse:[
-        "/ ns3.x
-        embeddedAppletFrame := jEmbeddedAppletFrameClass new.
-        isNS40 := false.
+    codeURL notNil ifTrue:[
+        attribs at:'code' put:codeURL
     ].
-    embeddedAppletFrame instVarNamed:'pData' put:self.
-
-    toolkit := Java classForName:'java.awt.Toolkit'.
-    toolkit := toolkit perform:#getDefaultToolkit.
-    peer := toolkit 
-                perform:#'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;'
-                with:embeddedAppletFrame.
-
-    (embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V')
-    ifTrue:[
-        "/ 4.0 netscape
-        embeddedAppletFrame 
-            perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V'
-            withArguments:
-                (Array
-                    with:jDocumentURL
-                    with:jCodeBaseURL
-                    with:jArchiveURL
-                    with:attribs
-                    with:appletContext
-                    with:(Java as_Integer:id)
-                    with:0 "/ reloadClasses-boolean
-                ).
-    ] ifFalse:[
-        (embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V')
-        ifTrue:[
-            "/ 3.01 netscape
-            embeddedAppletFrame 
-                perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V'
-                with:jDocumentURL
-                with:jCodeBaseURL
-                with:jArchiveURL
-                with:attribs
-                with:appletContext
-                with:(Java as_Integer:id).
-        ] ifFalse:[
-            "/ oldStyle netscape
-            embeddedAppletFrame 
-                perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V'
-                with:jDocumentURL
-                with:jCodeBaseURL
-                with:attribs
-                with:appletContext
-                with:id.
-        ].
-    ].
-
-    embeddedAppletFrame instVarNamed:'peer' put:peer.
-
-    self javaPeer:peer.
-
-    ^ true
-
-    "Created: / 20.10.1998 / 15:38:24 / cg"
-    "Modified: / 4.11.1998 / 21:07:03 / cg"
-!
-
-setupAppletFrameIn:anAppletContextOrNil initializeJava:initializeJava
-     |appletContext
-     jEmbeddedAppletFrameClass jDerivedAppletFrameClass
-     toolkit peer attribs id
-     jCodeBaseURL jDocumentURL jArchiveURL|
-
-    embeddedAppletFrame notNil ifTrue:[
-        "/ already setup
-        ^ self
-    ].
-
-    codeBaseURL isNil ifTrue:[
-        ^ self
-    ].
-
-    initializeJava ifTrue:[
-        Java startupJavaSystem.
-    ].
-
-    jCodeBaseURL := Java as_URL:codeBaseURL.
-    documentURL notNil ifTrue:[
-        jDocumentURL := Java as_URL:documentURL.
-    ] ifFalse:[
-        jDocumentURL := Java as_URL:codeBaseURL
-    ].
-    archiveURL notNil ifTrue:[
-        jArchiveURL := Java as_URL:archiveURL.
-    ].
-
-    id := appletID.
-    id isNil ifTrue:[
-        NextSequentialAppletID isNil ifTrue:[
-            NextSequentialAppletID := 1.
-        ].
-        id := NextSequentialAppletID.
-        NextSequentialAppletID := NextSequentialAppletID + 1
-    ].
-
-    attribs := Dictionary new.
-    width notNil ifTrue:[attribs at:'width' put:width printString].
-    height notNil ifTrue:[attribs at:'height' put:height printString].
-    codeURL notNil ifTrue:[attribs at:'code' put:codeURL].
     parameterDictionary notNil ifTrue:[
         attribs declareAllFrom:parameterDictionary
     ].
@@ -739,5 +635,5 @@
 !JavaEmbeddedFrameView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaEmbeddedFrameView.st,v 1.17 1999/01/29 15:30:24 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaEmbeddedFrameView.st,v 1.18 1999/12/23 18:07:52 cg Exp $'
 ! !
--- a/examples/JavaAppletDemo1.st	Thu Dec 23 18:07:26 1999 +0000
+++ b/examples/JavaAppletDemo1.st	Thu Dec 23 18:07:52 1999 +0000
@@ -83,7 +83,7 @@
                               #'name:' 'javaAppletComponent2'
                               #'layout:' #(#LayoutFrame 1 0.0 1 0.0 -1 1.0 -1 1.0)
                               #'codeURL:' 'ArcTest.class'
-                              #'codeBaseURL:' 'file:/home/cg/work/cg/java/examples/ArcTest'
+                              #'codeBaseURL:' 'file:examples/ArcTest'
                               #'level:' -1
                           )
                         )
@@ -100,5 +100,5 @@
 !JavaAppletDemo1 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/examples/JavaAppletDemo1.st,v 1.4 1998/02/01 17:04:45 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/examples/JavaAppletDemo1.st,v 1.5 1999/12/23 18:07:03 cg Exp $'
 ! !