JavaVM.st
changeset 255 2d8b3948a08a
parent 253 de483f561c9e
child 261 d95d5a3cc475
--- a/JavaVM.st	Mon Jan 12 13:51:13 1998 +0000
+++ b/JavaVM.st	Mon Jan 12 14:24:47 1998 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:3.3.1 on 5-jan-1998 at 11:46:32 pm'                  !
+'From Smalltalk/X, Version:3.3.1 on 12-jan-1998 at 1:26:02 pm'                  !
 
 Object subclass:#JavaVM
 	instanceVariableNames:''
@@ -62,10 +62,9 @@
 
     FileOpenConfirmation := true.
 
-    WindowOPTrace := true.
-
-MonitorTrace := true.
-ThreadTrace := true.
+"/ WindowOPTrace := true.
+"/ MonitorTrace := true.
+"/ ThreadTrace := true.
 
     UnhandledJavaExceptionSignal := (Signal new) mayProceed:false.
     UnhandledJavaExceptionSignal nameClass:self message:#unhandledJavaExceptionSignal.
@@ -100,7 +99,7 @@
     "
 
     "Created: / 2.1.1998 / 18:02:34 / cg"
-    "Modified: / 3.1.1998 / 21:29:18 / cg"
+    "Modified: / 7.1.1998 / 23:59:25 / cg"
 !
 
 initializeBaseClasses
@@ -217,7 +216,7 @@
     props at:'hotjava.home'       put:(self defaultHotJavaHome).
 
     "/ undocumented ?
-    props at:'file.encoding.pkg'  put:'sun/io'.
+    props at:'file.encoding.pkg'  put:'sun.io'.
 
     "/ suppress copyright view in appletViewer ...
     props at:'appletviewer.version' put:'1.1'.
@@ -225,10 +224,18 @@
     ^ props
 
     "Created: / 3.1.1998 / 14:26:39 / cg"
-    "Modified: / 4.1.1998 / 10:28:29 / cg"
+    "Modified: / 9.1.1998 / 03:06:46 / cg"
 !
 
 initializeVM
+    KnownWindows := nil.
+    JavaWindowGroup := nil.
+
+    self terminateAllThreads.
+
+    Java initAllStaticFields.
+    Java markAllClassesUninitialized.
+
     self releaseAllMonitors.
 
     self initializeSimulatedLibs.
@@ -240,14 +247,31 @@
     (Java classForName:'java.lang.System') classInit.
     Java initSystemClass.
 
+    ObjectMemory addDependent:self.
+
     "
-     Java markAllClassesUninitialized.
-     Java initAllStaticFields.
      JavaVM initializeVM
     "
 
     "Created: / 3.1.1998 / 21:29:09 / cg"
-    "Modified: / 4.1.1998 / 19:05:37 / cg"
+    "Modified: / 9.1.1998 / 10:29:27 / cg"
+!
+
+releaseAllJavaResources
+    self releaseAllMonitors.
+    Java terminateAllThreads.
+    self releaseAllWindows.
+    self releaseAllStreams.
+
+    JavaWindowGroup := nil.
+    LoadedLibs := nil.       "/ gc will reclaim them ...
+
+    "
+     JavaVM releaseAllJavaResources
+    "
+
+    "Created: / 7.1.1998 / 22:49:42 / cg"
+    "Modified: / 7.1.1998 / 22:57:11 / cg"
 !
 
 releaseAllMonitors
@@ -263,7 +287,61 @@
     "
 
     "Created: / 2.1.1998 / 18:04:05 / cg"
-    "Modified: / 2.1.1998 / 21:23:55 / cg"
+    "Modified: / 7.1.1998 / 22:58:10 / cg"
+!
+
+releaseAllStreams
+    self initializeOpenFileTable.
+
+    "
+     JavaInterpreter releaseAllStreams
+    "
+
+    "Modified: / 6.8.1997 / 00:40:55 / cg"
+    "Created: / 7.1.1998 / 22:57:04 / cg"
+!
+
+releaseAllWindows
+    KnownWindows notNil ifTrue:[
+        KnownWindows do:[:aView |
+            aView destroy
+        ].
+        KnownWindows := nil.
+    ]
+
+    "
+     self releaseAllWindows
+    "
+
+    "Created: / 7.1.1998 / 22:58:32 / cg"
+!
+
+releaseLeftOverMonitors
+    "release monitors held by dead processes"
+
+    |deadProcesses|
+
+    deadProcesses := IdentitySet new.
+
+    EnteredMonitorsPerProcess keysAndValuesDo:[:p :monitors |
+        p isDead ifTrue:[
+            monitors do:[:mon |
+                Transcript showCR:'release leftover monitor ...'.
+                mon release
+            ].
+            deadProcesses add:p.
+        ]
+    ].
+    deadProcesses do:[:p |
+        EnteredMonitorsPerProcess removeKey:p
+    ].
+
+    "
+     JavaVM releaseLeftOverMonitors
+    "
+
+    "Created: / 8.1.1998 / 17:29:26 / cg"
+    "Modified: / 8.1.1998 / 17:38:33 / cg"
 !
 
 systemProperties
@@ -275,6 +353,25 @@
 
     "Created: / 3.1.1998 / 14:25:58 / cg"
     "Modified: / 3.1.1998 / 14:32:38 / cg"
+!
+
+terminateAllThreads
+    Java terminateAllThreads
+
+    "Created: / 8.1.1998 / 17:43:54 / cg"
+!
+
+update:something with:aParameter from:changedObject
+    something == #returnFromSnapshot ifTrue:[
+         self initializeVM
+    ].
+
+    "
+     JavaVM initializeVM
+    "
+
+    "Modified: / 8.1.1998 / 17:44:16 / cg"
+    "Created: / 9.1.1998 / 10:30:13 / cg"
 ! !
 
 !JavaVM class methodsFor:'Signal constants'!
@@ -593,6 +690,61 @@
     "Created: / 4.1.1998 / 17:57:16 / cg"
 !
 
+gcForWGraphics:nativeContext
+    |jGraphics gc|
+
+    jGraphics := nativeContext receiver.
+    gc := jGraphics instVarNamed:'pData'.
+    ^ gc
+
+    "Created: / 8.1.1998 / 00:16:38 / cg"
+    "Modified: / 8.1.1998 / 00:17:44 / cg"
+!
+
+pReshape:nativeContext
+    |jFramePeer view x y width height menu|
+
+    jFramePeer := nativeContext receiver.
+    view := jFramePeer instVarNamed:'pData'.
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    width := nativeContext argAt:3.
+    height := nativeContext argAt:4.
+
+"/    'pReshape ' print. view print. 
+"/    ' ' print. x print. '/' print. y print.
+"/    ' extent: ' print. width print. '/' print. height printNL.
+
+    (view isTopView 
+    or:[view isMemberOf:JavaEmbeddedFrameView]) ifTrue:[
+        "/
+        "/ dont allow setting the origin
+        "/
+        menu := self topViewsMenu:view.
+        menu notNil ifTrue:[
+            "/ must add the menus height
+            height := height + menu height
+        ].
+        view extent:width@height.
+    ] ifFalse:[
+        (view superView notNil
+        and:[view superView isTopView]) ifTrue:[
+            menu := self topViewsMenu:view superView.
+            menu notNil ifTrue:[
+                "/ must add menus height to yPos
+                y := y + menu height.
+            ]
+        ].
+        view origin:x@y extent:width@height.
+    ].
+
+    ^ nil
+
+    "Modified: / 21.8.1997 / 19:34:16 / cg"
+    "Created: / 7.1.1998 / 21:47:11 / cg"
+!
+
 topViewsMenu:view
     |idx|
 
@@ -608,6 +760,17 @@
 
     "Modified: / 4.8.1997 / 01:23:06 / cg"
     "Created: / 4.1.1998 / 18:01:42 / cg"
+!
+
+viewForWPeer:nativeContext
+    |jPeer view|
+
+    jPeer := nativeContext receiver.
+    view := jPeer instVarNamed:'pData'.
+    ^ view
+
+    "Modified: / 8.1.1998 / 00:17:44 / cg"
+    "Created: / 8.1.1998 / 17:31:25 / cg"
 ! !
 
 !JavaVM class methodsFor:'helpers - exceptions'!
@@ -633,24 +796,57 @@
 !
 
 throwClassNotFoundException
-    self throwException:(Java classForName:'java.lang.ClassNotFoundException') 
-            withMessage:'no such class'
-
-    "Modified: / 1.8.1997 / 15:21:38 / cg"
+    self 
+        throwExceptionClassName:'java.lang.ClassNotFoundException' 
+        withMessage:'no such class'
+
     "Created: / 4.1.1998 / 22:25:26 / cg"
+    "Modified: / 7.1.1998 / 15:25:35 / cg"
 !
 
 throwClassNotFoundException:className
-    self throwException:(Java classForName:'java.lang.ClassNotFoundException') 
-            withMessage:'no such class: ' , className
-
-    "Modified: / 1.8.1997 / 15:21:38 / cg"
+    self 
+        throwExceptionClassName:'java.lang.ClassNotFoundException' 
+        withMessage:'no such class: ' , className
+
     "Created: / 4.1.1998 / 22:26:09 / cg"
+    "Modified: / 7.1.1998 / 15:25:58 / cg"
+!
+
+throwException:aJavaException
+    |con|
+
+    ExceptionTrace ifTrue:[
+        'JAVA: exception: ' print. aJavaException class fullName printCR.
+    ].
+    ExceptionDebug ifTrue:[
+        self halt:('JAVA: exception: ' , aJavaException class fullName).
+        self internalError:('JAVA: exception: ' , aJavaException class fullName).
+    ].
+
+    con := self findJavaHandlerFor:aJavaException.
+    con isNil ifTrue:[
+        "/ no JavaHandler ... let smalltalk handle it
+        JavaVM javaExceptionSignal raiseWith:aJavaException.
+        self halt:'here after exception'.
+        Processor activeProcess terminate.
+    ].
+    con exceptionArg:aJavaException.
+    con markForException.
+    con unwindAndRestart.
+
+    self halt:'should not be reached'.
+    Processor activeProcess terminate.
+
+    "Created: / 7.1.1998 / 15:28:22 / cg"
+    "Modified: / 9.1.1998 / 02:27:49 / cg"
 !
 
 throwException:aJavaExceptionClass withMessage:someMessage
     |ex con|
 
+self halt.
+
     ExceptionTrace ifTrue:[
         'JAVA: exception: ' print. aJavaExceptionClass name printCR.
     ].
@@ -673,7 +869,46 @@
     self halt:'should not be reached'.
 
     "Created: / 4.1.1998 / 22:29:26 / cg"
-    "Modified: / 5.1.1998 / 00:38:11 / cg"
+    "Modified: / 7.1.1998 / 21:35:51 / cg"
+!
+
+throwExceptionClassName:aJavaExceptionClassName withMessage:someMessage
+    |aJavaExceptionClass ex|
+
+    aJavaExceptionClass := Java classForName:aJavaExceptionClassName.
+    ex := aJavaExceptionClass new.
+    ex instVarNamed:'detailMessage' put:(Java as_String:someMessage).
+
+    self throwException:ex
+
+    "Created: / 7.1.1998 / 15:25:09 / cg"
+!
+
+throwIOExceptionWithMessage:message
+    self 
+        throwExceptionClassName:'java.io.IOException' 
+        withMessage:message
+
+    "Created: / 7.1.1998 / 10:34:24 / cg"
+    "Modified: / 7.1.1998 / 15:26:25 / cg"
+!
+
+throwNullPointerException
+    self 
+        throwExceptionClassName:'java.lang.NullPointerException' 
+        withMessage:'null pointer'
+
+    "Modified: / 7.1.1998 / 15:25:35 / cg"
+    "Created: / 9.1.1998 / 02:26:08 / cg"
+!
+
+throwNumberFormatException 
+    self 
+        throwExceptionClassName:'java.lang.NumberFormatException' 
+        withMessage:'bad number format'
+
+    "Modified: / 7.1.1998 / 15:25:35 / cg"
+    "Created: / 11.1.1998 / 16:08:22 / cg"
 ! !
 
 !JavaVM class methodsFor:'helpers - io'!
@@ -768,7 +1003,9 @@
     frame := jFrame instVarNamed:'pData'.
 
     button := Button in:frame.
-    button action:[jButtonPeer invoke:#handleAction].
+    button action:[
+                        jButtonPeer invoke:#handleAction.
+                  ].
 
     lbl := jButton instVarNamed:'label'.
     lbl notNil ifTrue:[
@@ -783,8 +1020,8 @@
 
     ^ nil
 
-    "Modified: / 19.8.1997 / 01:46:42 / cg"
     "Created: / 5.1.1998 / 01:53:30 / cg"
+    "Modified: / 8.1.1998 / 22:02:43 / cg"
 !
 
 _WCanvasPeer_create:nativeContext
@@ -815,6 +1052,120 @@
     "Modified: / 5.1.1998 / 01:24:13 / cg"
 !
 
+_WCheckboxPeer_create:nativeContext
+    |jCheckboxPeer jCheckbox jFrame frame checkBox lbl|
+
+    jCheckboxPeer := nativeContext receiver.
+    jCheckbox := jCheckboxPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    checkBox := CheckBox in:frame.
+    checkBox action:[jCheckboxPeer 
+                        invoke:#'handleAction(Z)V' 
+                        with:(checkBox isOn ifTrue:[1] ifFalse:[0])
+                  ].
+
+    lbl := jCheckbox instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        checkBox label:lbl
+    ].
+
+    self createdWindowsView:checkBox for:jCheckboxPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WCheckboxPeer_create: ' print. frame print. ' -> ' print. checkBox printNL.
+    ].
+
+    ^ nil
+
+    "Modified: / 19.8.1997 / 01:46:58 / cg"
+    "Created: / 7.1.1998 / 21:48:03 / cg"
+!
+
+_WCheckboxPeer_setCheckboxGroup:nativeContext
+    |jChoicePeer jChoice jGroup|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    jGroup := nativeContext argAt:1.
+
+    "Modified: / 4.8.1997 / 01:31:24 / cg"
+    "Created: / 7.1.1998 / 21:48:47 / cg"
+!
+
+_WCheckboxPeer_setState:nativeContext
+    |jChoicePeer jChoice state|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    state := nativeContext argAt:1.
+
+    "Modified: / 4.8.1997 / 01:19:41 / cg"
+    "Created: / 7.1.1998 / 21:49:13 / cg"
+!
+
+_WChoicePeer_addItem:nativeContext
+    |jChoicePeer jChoice jString index|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    jString := nativeContext argAt:1.
+    index := nativeContext argAt:2.
+
+    "Modified: / 4.8.1997 / 01:11:48 / cg"
+    "Created: / 7.1.1998 / 21:45:12 / cg"
+!
+
+_WChoicePeer_create:nativeContext
+    |jChoicePeer jChoice jFrame frame comboBox|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    comboBox := ComboBoxView in:frame.
+"/    comboBox action:[jChoicePeer invoke:#handleAction].
+
+    self createdWindowsView:comboBox for:jChoicePeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WChoicePeer_create: ' print. frame print. ' -> ' print. comboBox printNL.
+    ].
+
+    ^ nil
+
+    "Modified: / 19.8.1997 / 01:47:05 / cg"
+    "Created: / 7.1.1998 / 21:44:31 / cg"
+!
+
+_WChoicePeer_reshape:nativeContext
+    self pReshape:nativeContext.
+    ^ self.
+
+    "Modified: / 15.8.1997 / 15:36:29 / cg"
+    "Created: / 7.1.1998 / 21:46:18 / cg"
+!
+
+_WChoicePeer_select:nativeContext
+    |jChoicePeer jChoice index|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    index := nativeContext argAt:1.
+
+    "Modified: / 4.8.1997 / 01:19:41 / cg"
+    "Created: / 7.1.1998 / 21:45:43 / cg"
+!
+
 _WClipboard_init:nativeContext
 "/ self halt.
 
@@ -857,11 +1208,24 @@
     "Modified: / 4.1.1998 / 18:06:51 / cg"
 !
 
+_WComponentPeer__dispose:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view destroy
+    ]
+
+    "Created: / 7.1.1998 / 22:36:25 / cg"
+    "Modified: / 8.1.1998 / 17:32:08 / cg"
+!
+
 _WComponentPeer__setBackground:nativeContext
-    |jPeer rgb clr view|
-
-    jPeer := nativeContext receiver.
-    view := jPeer instVarNamed:'pData'.
+    |rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
 
     rgb := nativeContext argAt:1.
     clr := Color rgbValue:rgb.
@@ -884,15 +1248,14 @@
     view viewBackground:clr.
     view backgroundPaint:clr.
 
-    "Modified: / 21.8.1997 / 16:43:49 / cg"
     "Created: / 4.1.1998 / 18:07:39 / cg"
+    "Modified: / 8.1.1998 / 17:32:34 / cg"
 !
 
 _WComponentPeer__setForeground:nativeContext
-    |jPeer rgb clr view|
-
-    jPeer := nativeContext receiver.
-    view := jPeer instVarNamed:'pData'.
+    |rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
 
     rgb := nativeContext argAt:1.
     clr := Color rgbValue:rgb.
@@ -904,8 +1267,54 @@
 
     view paint:clr.
 
-    "Modified: / 13.8.1997 / 20:43:12 / cg"
     "Created: / 4.1.1998 / 18:08:13 / cg"
+    "Modified: / 8.1.1998 / 17:32:45 / cg"
+!
+
+_WComponentPeer_disable:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view disable
+    ]
+
+    "Created: / 6.1.1998 / 18:26:36 / cg"
+    "Modified: / 8.1.1998 / 17:32:53 / cg"
+!
+
+_WComponentPeer_handleEvent:nativeContext
+"/ 'JAVA: WComponent - handleEvent ignored' infoPrintCR.
+
+    "Modified: / 21.8.1997 / 17:13:27 / cg"
+    "Created: / 6.1.1998 / 21:10:17 / cg"
+!
+
+_WComponentPeer_hide:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view beInvisible
+    ]
+
+    "Created: / 7.1.1998 / 22:35:32 / cg"
+    "Modified: / 8.1.1998 / 17:33:08 / cg"
+!
+
+_WComponentPeer_requestFocus:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    view getKeyboardFocus
+
+    "Created: / 7.1.1998 / 22:30:03 / cg"
+    "Modified: / 8.1.1998 / 17:33:18 / cg"
 !
 
 _WComponentPeer_reshape:nativeContext
@@ -938,11 +1347,10 @@
 !
 
 _WComponentPeer_show:nativeContext
-    |jFrame view|
-
-    jFrame := nativeContext receiver.
-
-    view := jFrame instVarNamed:'pData'.
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
 "/    'JAVA: show: ' print. view printNL.
 "/    self halt.
 
@@ -959,8 +1367,8 @@
 
 "/ self halt.
 
-    "Modified: / 23.8.1997 / 03:02:56 / cg"
     "Created: / 5.1.1998 / 01:26:22 / cg"
+    "Modified: / 8.1.1998 / 17:33:48 / cg"
 !
 
 _WComponentPeer_start:nativeContext
@@ -977,6 +1385,67 @@
     "Created: / 5.1.1998 / 01:55:47 / cg"
 !
 
+_WDialogPeer__hide:nativeContext
+    |dialog|
+
+    dialog := self viewForWPeer:nativeContext.
+
+    dialog hide.
+
+    "Created: / 7.1.1998 / 22:34:10 / cg"
+    "Modified: / 8.1.1998 / 17:34:10 / cg"
+!
+
+_WDialogPeer__show:nativeContext
+    |dialog|
+
+    dialog := self viewForWPeer:nativeContext.
+
+    dialog realize.
+
+    "Created: / 7.1.1998 / 21:52:15 / cg"
+    "Modified: / 8.1.1998 / 17:34:22 / cg"
+!
+
+_WDialogPeer_create:nativeContext
+    |jDialogPeer dialog|
+
+    jDialogPeer := nativeContext receiver.
+
+    dialog := ModalBox new.
+    jDialogPeer instVarNamed:'pData' put:dialog.
+
+    WindowCreationTrace == true ifTrue:[
+        'WDialogPeer_create: ' print. dialog printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:51:00 / cg"
+    "Modified: / 7.1.1998 / 22:34:32 / cg"
+!
+
+_WFileDialogPeer_show:nativeContext
+    |jDialogPeer dialog dialogView stDialog f|
+
+    jDialogPeer := nativeContext receiver.
+    dialog := jDialogPeer instVarNamed:'target'.
+    dialogView := jDialogPeer instVarNamed:'pData'.
+
+    stDialog := FileSelectionBox new.
+    stDialog label:(Java as_ST_String:(dialog instVarNamed:'title')).
+    stDialog show.
+
+    stDialog accepted ifTrue:[
+        f := stDialog pathName.
+        jDialogPeer perform:#'handleSelected(Ljava/lang/String;)V' with:(Java as_String:f).
+    ] ifFalse:[
+        jDialogPeer perform:#'handleCancel()V'
+    ].
+"/ self halt.
+
+    "Created: / 7.1.1998 / 22:38:45 / cg"
+    "Modified: / 12.1.1998 / 12:32:03 / cg"
+!
+
 _WFontMetrics_getMFCharSegmentWidth:nativeContext
     "get multi-font string-segment width.
      Not yet supported - use standard strings width"
@@ -1121,36 +1590,728 @@
     "Created: / 4.1.1998 / 17:56:39 / cg"
 !
 
+_WFramePeer_setMenuBar0:nativeContext
+    |frame jMenuBarPeer menuPanel|
+
+    frame := self viewForWPeer:nativeContext.
+
+    jMenuBarPeer := nativeContext argAt:1.
+    jMenuBarPeer isNil ifTrue:[
+        "/ mhmh - JAVA wants to remove the frames menuPanel.
+        "/ but I have no handle on it (for destroy).
+        "/ search it in subViews of the frame.
+        frame subViews copy do:[:v |
+            (v isKindOf:MenuPanel) ifTrue:[
+                v destroy
+            ]
+        ]
+    ] ifFalse:[
+        menuPanel := jMenuBarPeer instVarNamed:'pData'.
+
+        menuPanel origin:0.0@0.0 corner:1.0@(menuPanel preferredExtent y).
+        frame addSubView:menuPanel.
+    ].
+    ^ nil
+
+    "Created: / 7.1.1998 / 21:41:35 / cg"
+    "Modified: / 8.1.1998 / 17:35:04 / cg"
+!
+
+_WGraphics_changeClip:nativeContext        
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+"/ self halt.
+
+    "Created: / 6.1.1998 / 20:57:21 / cg"
+    "Modified: / 8.1.1998 / 00:21:18 / cg"
+!
+
+_WGraphics_clearRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+
+    gc realized ifFalse:[
+        'JAVA: drawing on unrealized gc - ignored' infoPrintCR.
+        ^ self
+    ].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc clearRectangleX:x y:y width:w height:h.
+
+    "Created: / 8.1.1998 / 00:16:00 / cg"
+    "Modified: / 8.1.1998 / 00:21:09 / cg"
+!
+
+_WGraphics_createFromComponent:nativeContext
+    |jGraphics win view|
+
+    jGraphics := nativeContext receiver.
+    win := nativeContext argAt:1.
+
+    view := KnownWindows at:win ifAbsent:nil.
+    view isNil ifTrue:[
+        self halt.
+        ^ self
+    ].
+
+"/    "/ just a consistency check ...
+"/    (win instVarNamed:'xid') ~~ view ifTrue:[
+"/        self halt:'consistency check'
+"/    ].
+
+    jGraphics instVarNamed:'pData' put:view.
+
+    "Modified: / 13.8.1997 / 20:37:47 / cg"
+    "Created: / 6.1.1998 / 20:55:18 / cg"
+!
+
+_WGraphics_createFromGraphics:nativeContext
+    |jGraphics graphics gc|
+
+    jGraphics := nativeContext receiver.
+    graphics := nativeContext argAt:1.
+    gc := graphics instVarNamed:'pData'.
+
+    jGraphics instVarNamed:'pData' put:gc.
+
+    "Created: / 8.1.1998 / 00:47:39 / cg"
+    "Modified: / 8.1.1998 / 00:52:20 / cg"
+!
+
+_WGraphics_dispose:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+    gc isNil ifTrue:[^ self].
+
+    "Created: / 6.1.1998 / 20:58:38 / cg"
+    "Modified: / 8.1.1998 / 00:19:09 / cg"
+!
+
+_WGraphics_drawArc:nativeContext
+    |gc x y w h startAngle endAngle|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    startAngle := nativeContext argAt:5.
+    endAngle := nativeContext argAt:6.
+
+    DrawOPTrace ifTrue:[
+        'drawArc x/y= ' print. x print. '@' print. y print. 
+               ' w/h= ' print. w print. '@' print. h print.
+               ' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR.
+    ].
+    gc displayArcX:x y:y width:w height:h from:startAngle angle:(endAngle - startAngle)
+
+    "Created: / 6.1.1998 / 21:00:15 / cg"
+    "Modified: / 8.1.1998 / 00:20:56 / cg"
+!
+
+_WGraphics_drawLine:nativeContext        
+    |gc x y x2 y2|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    x2 := nativeContext argAt:3.
+    y2 := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawLine x/y= ' print. x print. '@' print. y print. ' x2/y2= ' print. x2 print. '@' print. y2 printCR.
+    ].
+    gc displayLineFromX:x y:y toX:x2 y:y2
+
+    "Created: / 6.1.1998 / 20:59:27 / cg"
+    "Modified: / 8.1.1998 / 00:34:23 / cg"
+!
+
+_WGraphics_drawMFCharsSegment:nativeContext       
+    |jFont jFontDescr s gc x y offs len|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    jFont := nativeContext argAt:1.
+    jFontDescr := nativeContext argAt:2.
+    s := nativeContext argAt:3.
+    "/ s := Java as_ST_String:s.
+    offs := nativeContext argAt:4.
+    len := nativeContext argAt:5.
+    x := nativeContext argAt:6.
+    y := nativeContext argAt:7.
+
+    DrawOPTrace ifTrue:[
+        'drawMFCharsSegment x/y= ' print. x print. '@' print. y print. ' s= ' print. s printCR.
+    ].
+    gc displayString:s from:offs+1 to:offs+len x:x y:y.
+    ^ (gc font widthOf:s).
+
+    "Created: / 6.1.1998 / 21:01:07 / cg"
+    "Modified: / 8.1.1998 / 00:34:06 / cg"
+!
+
+_WGraphics_drawOval:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawOval x/y= ' print. x print. '@' print. y print. 
+                ' w/h= ' print. w print. '@' print. h printCR.
+    ].
+    gc displayArcX:x y:y width:w height:h from:0 angle:360
+
+    "Created: / 8.1.1998 / 00:44:31 / cg"
+    "Modified: / 8.1.1998 / 00:44:55 / cg"
+!
+
+_WGraphics_drawPolygon:nativeContext        
+    |gc xVector yVector count points|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    xVector := nativeContext argAt:1.
+    yVector := nativeContext argAt:2.
+    count := nativeContext argAt:3.
+
+    DrawOPTrace ifTrue:[
+        'drawPolgon' printCR.
+    ].
+
+    points := (1 to:count) collect:[:i | (xVector at:i) @ (yVector at:i)].
+    gc displayPolygon:points
+
+    "Created: / 8.1.1998 / 00:57:28 / cg"
+    "Modified: / 8.1.1998 / 00:57:49 / cg"
+!
+
+_WGraphics_drawRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:05 / cg"
+!
+
+_WGraphics_drawRoundRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:26 / cg"
+!
+
+_WGraphics_fillArc:nativeContext
+    |gc x y w h startAngle endAngle|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    startAngle := nativeContext argAt:5.
+    endAngle := nativeContext argAt:6.
+
+    DrawOPTrace ifTrue:[
+        'fillArc x/y= ' print. x print. '@' print. y print. 
+               ' w/h= ' print. w print. '@' print. h print.
+               ' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR.
+    ].
+    gc fillArcX:x y:y width:w height:h from:startAngle angle:(endAngle - startAngle)
+
+    "Created: / 6.1.1998 / 21:11:31 / cg"
+    "Modified: / 8.1.1998 / 00:33:59 / cg"
+!
+
+_WGraphics_fillOval:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawOval x/y= ' print. x print. '@' print. y print. 
+                ' w/h= ' print. w print. '@' print. h printCR.
+    ].
+    gc fillArcX:x y:y width:w height:h from:0 angle:360
+
+    "Created: / 8.1.1998 / 00:46:00 / cg"
+    "Modified: / 8.1.1998 / 00:46:20 / cg"
+!
+
+_WGraphics_fillPolygon:nativeContext        
+    |gc xVector yVector count points|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    xVector := nativeContext argAt:1.
+    yVector := nativeContext argAt:2.
+    count := nativeContext argAt:3.
+
+    DrawOPTrace ifTrue:[
+        'fillPolgon' printCR.
+    ].
+
+    points := (1 to:count) collect:[:i | (xVector at:i) @ (yVector at:i)].
+    gc fillPolygon:points
+
+    "Modified: / 8.1.1998 / 00:34:23 / cg"
+    "Created: / 8.1.1998 / 00:58:09 / cg"
+!
+
+_WGraphics_fillRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc fillRectangleX:x y:y width:w height:h.
+
+    "Created: / 15.8.1997 / 15:43:10 / cg"
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+!
+
+_WGraphics_fillRoundRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:36 / cg"
+!
+
+_WGraphics_getClipBounds:nativeContext        
+    |gc rect r|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+
+    rect := (Java classForName:'java.awt.Rectangle') basicNew.
+
+    (gc isMemberOf:JavaView) ifTrue:[
+        r := gc getNextUpdateRectangle.
+        r isNil ifTrue:[
+            rect instVarNamed:'x' put:0.
+            rect instVarNamed:'y' put:0.
+            rect instVarNamed:'width' put:(gc width).
+            rect instVarNamed:'height' put:(gc height).
+        ] ifFalse:[
+            rect instVarNamed:'x' put:(r left).
+            rect instVarNamed:'y' put:(r top).
+            rect instVarNamed:'width' put:(r width).
+            rect instVarNamed:'height' put:(r height).
+        ]
+    ] ifFalse:[
+        rect instVarNamed:'x' put:0.
+        rect instVarNamed:'y' put:0.
+        rect instVarNamed:'width' put:9999.
+        rect instVarNamed:'height' put:9999.
+    ].
+
+"/ 'JAVA: getClipBounds' infoPrintCR.
+"/ self halt.
+
+    ^ rect
+
+    "Created: / 6.1.1998 / 20:58:07 / cg"
+    "Modified: / 8.1.1998 / 00:34:39 / cg"
+!
+
+_WGraphics_imageCreate:nativeContext        
+    |imgRep|
+
+    imgRep := nativeContext argAt:1.
+
+    "Created: / 11.1.1998 / 16:34:30 / cg"
+    "Modified: / 11.1.1998 / 16:35:04 / cg"
+!
+
+_WGraphics_pSetFont:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+"/ self halt.
+
+    "Created: / 6.1.1998 / 20:56:47 / cg"
+    "Modified: / 8.1.1998 / 00:34:44 / cg"
+!
+
+_WGraphics_pSetForeground:nativeContext
+    |gc rgb clr|
+
+    gc := self gcForWGraphics:nativeContext.
+
+    rgb := nativeContext argAt:1.
+
+    clr := Color rgbValue:rgb.
+    gc paint:clr.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    "Created: / 6.1.1998 / 20:56:14 / cg"
+    "Modified: / 8.1.1998 / 00:34:51 / cg"
+!
+
+_WGraphics_setPaintMode:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+"/ self halt.
+    gc function:#copy
+
+    "Created: / 8.1.1998 / 00:33:44 / cg"
+    "Modified: / 8.1.1998 / 00:35:41 / cg"
+!
+
+_WGraphics_setXORMode:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+"/ self halt.
+    gc function:#xor
+
+    "Modified: / 8.1.1998 / 00:35:41 / cg"
+    "Created: / 8.1.1998 / 00:36:17 / cg"
+!
+
+_WLabelPeer_create:nativeContext
+    |jLabelPeer jLabel jFrame frame label
+     lbl|
+
+    jLabelPeer := nativeContext receiver.
+    jLabel := jLabelPeer instVarNamed:'target'.
+
+    lbl := jLabel instVarNamed:'text'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl
+    ].
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    label := Label in:frame.
+    lbl notNil ifTrue:[
+        label label:lbl
+    ].
+    self createdWindowsView:label for:jLabelPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WLabelPeer_create: ' print. frame print. ' -> ' print. label printNL.
+    ].
+
+    ^ nil
+
+    "Modified: / 19.8.1997 / 01:47:29 / cg"
+    "Created: / 7.1.1998 / 21:42:31 / cg"
+!
+
+_WLabelPeer_setAlignment:nativeContext
+    |label alignNr|
+
+    alignNr := nativeContext argAt:1.
+    label := self viewForWPeer:nativeContext.
+    label notNil ifTrue:[
+    ].
+
+    "Created: / 7.1.1998 / 21:43:12 / cg"
+    "Modified: / 8.1.1998 / 17:35:29 / cg"
+!
+
+_WLabelPeer_setText:nativeContext
+    |label jString|
+
+    jString := nativeContext argAt:1.
+
+    label := self viewForWPeer:nativeContext.
+    label label:(Java as_ST_String:jString)
+
+    "Created: / 7.1.1998 / 21:43:51 / cg"
+    "Modified: / 8.1.1998 / 17:35:50 / cg"
+!
+
+_WMenuBarPeer_create:nativeContext
+    |jMenuBarPeer jMenuBar jFrame frame menuBar|
+
+    jMenuBarPeer := nativeContext receiver.
+    jMenuBar := jMenuBarPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    menuBar := MenuPanel in:frame.
+    menuBar verticalLayout:false.
+
+    self createdWindowsView:menuBar for:jMenuBarPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WMenuBarPeer_create: ' print. frame print. ' -> ' print. menuBar printNL.
+    ].
+
+    ^ nil
+
+    "Modified: / 19.8.1997 / 01:47:36 / cg"
+    "Created: / 7.1.1998 / 21:38:31 / cg"
+!
+
+_WMenuItemPeer_create:nativeContext
+    |jMenuItemPeer jMenuItem jMenuPeer menu item lbl|
+
+    jMenuItemPeer := nativeContext receiver.
+    jMenuItem := jMenuItemPeer instVarNamed:'target'.
+
+    jMenuPeer := nativeContext argAt:1.
+    menu := jMenuPeer instVarNamed:'pData'.
+
+    item := menu createAtIndex:nil.
+    item value:[jMenuItemPeer invoke:#'handleAction(I)V' with:0].
+
+    lbl := jMenuItem instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        item label:lbl
+    ].
+
+    jMenuItemPeer instVarNamed:'pData' put:item.
+
+    WindowOPTrace == true ifTrue:[
+        'WMenuItem_create: ' print. menu print. ' -> ' print. item printNL.
+    ].
+    ^ nil
+
+    "Created: / 7.1.1998 / 21:40:44 / cg"
+    "Modified: / 7.1.1998 / 23:07:42 / cg"
+!
+
+_WMenuItemPeer_enable:nativeContext
+    |jMenuItemPeer item state|
+
+    jMenuItemPeer := nativeContext receiver.
+    item := jMenuItemPeer instVarNamed:'pData'.
+
+    state := nativeContext argAt:1.
+    item enabled:(state == 0) not
+
+    "Modified: / 4.8.1997 / 03:05:50 / cg"
+    "Created: / 7.1.1998 / 22:41:38 / cg"
+!
+
+_WMenuPeer_createMenu:nativeContext
+    |jMenuPeer jMenu jMenuBarPeer menuPanel menu
+     lbl item|
+
+    jMenuPeer := nativeContext receiver.
+    jMenu := jMenuPeer instVarNamed:'target'.
+
+    jMenuBarPeer := nativeContext argAt:1.
+    menuPanel := jMenuBarPeer instVarNamed:'pData'.
+
+    item := menuPanel createAtIndex:nil.
+    lbl := jMenu instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        item label:lbl
+    ].
+
+    menu := MenuPanel new.
+    item submenu:menu.
+
+    jMenuPeer instVarNamed:'pData' put:menu.
+
+'createMenuPeer: ' print. menuPanel print. ' -> ' print. menu printNL.
+    ^ nil
+
+    "Modified: / 8.8.1997 / 12:07:06 / cg"
+    "Created: / 7.1.1998 / 21:39:50 / cg"
+!
+
+_WTextAreaPeer_create:nativeContext
+    |jTextAreaPeer jFrame frame editTextView|
+
+    jTextAreaPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    editTextView := EditTextView in:frame.
+
+    self createdWindowsView:editTextView for:jTextAreaPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WTextAreaPeer_create: ' print. frame print. ' -> ' print. editTextView printNL.
+    ].
+
+    ^ nil
+
+    "Modified: / 19.8.1997 / 01:47:44 / cg"
+    "Created: / 7.1.1998 / 21:49:49 / cg"
+!
+
+_WTextAreaPeer_insertText:nativeContext
+    |textView pos string jstring|
+
+    textView := self viewForWPeer:nativeContext.
+
+    jstring := nativeContext argAt:1.
+    string := Java as_ST_String:jstring.
+    pos := nativeContext argAt:2.
+
+    textView insert:string at:pos.
+    ^ nil
+
+    "Created: / 7.1.1998 / 21:50:23 / cg"
+    "Modified: / 8.1.1998 / 17:36:24 / cg"
+!
+
 _WTextComponentPeer_enableEditing:nativeContext
-    |peer textView|
-
-    peer := nativeContext receiver.
-    textView := peer instVarNamed:'pData'.
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
 
     ^ textView readOnly:false
 
-    "Modified: / 16.8.1997 / 01:01:34 / cg"
     "Created: / 5.1.1998 / 01:29:38 / cg"
+    "Modified: / 8.1.1998 / 17:36:35 / cg"
+!
+
+_WTextComponentPeer_getSelectionEnd:nativeContext
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
+
+    ^ textView characterPositionOfSelectionEnd
+
+    "Created: / 8.1.1998 / 17:41:56 / cg"
+!
+
+_WTextComponentPeer_getSelectionStart:nativeContext
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
+
+    ^ textView characterPositionOfSelection
+
+    "Created: / 15.8.1997 / 15:45:45 / cg"
+    "Modified: / 8.1.1998 / 17:36:43 / cg"
+!
+
+_WTextComponentPeer_getText:nativeContext
+    |textView string jString|
+
+    textView := self viewForWPeer:nativeContext.
+
+    string := textView contents asString.
+    jString := Java as_String:string.
+    ^ jString
+
+    "Created: / 6.1.1998 / 21:05:15 / cg"
+    "Modified: / 8.1.1998 / 17:36:52 / cg"
 !
 
 _WTextComponentPeer_select:nativeContext
-    |peer textView|
-
-    peer := nativeContext receiver.
-    textView := peer instVarNamed:'pData'.
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
 
 "/ self halt.
 "/     self unimplementedNativeMethod.
 
     "Created: / 15.8.1997 / 15:45:58 / cg"
-    "Modified: / 5.1.1998 / 01:29:10 / cg"
+    "Modified: / 8.1.1998 / 17:37:01 / cg"
 !
 
 _WTextComponentPeer_setText:nativeContext
-    |peer textView string jstring|
-
-    peer := nativeContext receiver.
-    textView := peer instVarNamed:'pData'.
+    |textView string jstring|
+
+    textView := self viewForWPeer:nativeContext.
 
     jstring := nativeContext argAt:1.
     string := Java as_ST_String:jstring.
@@ -1158,8 +2319,8 @@
     textView contents:string.
 "/ self halt.
 
-    "Modified: / 16.8.1997 / 01:02:22 / cg"
     "Created: / 5.1.1998 / 01:28:23 / cg"
+    "Modified: / 8.1.1998 / 17:37:15 / cg"
 !
 
 _WTextFieldPeer_create:nativeContext
@@ -1184,6 +2345,19 @@
     "Created: / 5.1.1998 / 01:27:37 / cg"
 !
 
+_WToolkit_eventLoop:nativeContext
+    [true] whileTrue:[
+        AbortSignal handle:[:ex |
+            ex return
+        ] do:[
+            self doWindowsEventThread.
+        ]
+    ].
+
+    "Modified: / 17.8.1997 / 20:13:13 / cg"
+    "Created: / 6.1.1998 / 21:01:44 / cg"
+!
+
 _WToolkit_init:nativeContext
 
     "Created: / 3.1.1998 / 02:30:57 / cg"
@@ -1197,10 +2371,9 @@
 !
 
 _WWindowPeer__setResizable:nativeContext
-    |jFrame view onOff|
-
-    jFrame := nativeContext receiver.
-    view := jFrame instVarNamed:'pData'.
+    |view onOff|
+
+    view := self viewForWPeer:nativeContext.
 
     onOff := nativeContext argAt:1.
 
@@ -1209,14 +2382,13 @@
     ^ nil
 
     "Created: / 5.1.1998 / 00:57:59 / cg"
-    "Modified: / 5.1.1998 / 01:23:59 / cg"
+    "Modified: / 8.1.1998 / 17:37:31 / cg"
 !
 
 _WWindowPeer__setTitle:nativeContext
-    |jFrame view jString string|
-
-    jFrame := nativeContext receiver.
-    view := jFrame instVarNamed:'pData'.
+    |view jString string|
+
+    view := self viewForWPeer:nativeContext.
 
     jString := nativeContext argAt:1.
     string := Java as_ST_String:jString.
@@ -1227,7 +2399,7 @@
     ^ nil
 
     "Created: / 5.1.1998 / 00:57:17 / cg"
-    "Modified: / 5.1.1998 / 01:23:43 / cg"
+    "Modified: / 8.1.1998 / 17:37:41 / cg"
 !
 
 _WWindowPeer_updateInsets:nativeContext
@@ -1371,6 +2543,35 @@
     "Modified: / 4.1.1998 / 16:51:26 / cg"
 !
 
+_FileOutputStream_writeBytes:nativeContext
+    |bytes offset count stream|
+
+    bytes := nativeContext argAt:1.
+    offset := nativeContext argAt:2.
+    count := nativeContext argAt:3.
+
+    stream := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        stream isFileStream ifTrue:[
+            ('JAVA: write ' , count printString , ' bytes to ' , stream pathName) infoPrintCR.
+        ] ifFalse:[
+            stream ~~ Stdout ifTrue:[
+                stream ~~ Stderr ifTrue:[
+                    ('JAVA: write ' , count printString , ' bytes to ' , stream displayString) infoPrintCR.
+                ]
+            ]
+        ]
+    ].
+
+    "/ should always be bytes
+
+    stream nextPutBytes:count from:bytes startingAt:offset+1
+
+    "Created: / 7.1.1998 / 20:46:19 / cg"
+    "Modified: / 7.1.1998 / 20:47:34 / cg"
+!
+
 _File_canRead0:nativeContext
     |file path f|
 
@@ -1379,13 +2580,13 @@
     path notNil ifTrue:[
         path := Java as_ST_String:path.
         (f := path asFilename) isReadable ifTrue:[
-            ^ 1 "/ true
+            ^ 1 "/ TRUE
         ]
     ].
-    ^ 0 "/ false
-
-    "Modified: / 19.8.1997 / 16:34:19 / cg"
+    ^ 0 "/ FALSE
+
     "Created: / 4.1.1998 / 18:09:55 / cg"
+    "Modified: / 7.1.1998 / 10:31:52 / cg"
 !
 
 _File_exists0:nativeContext
@@ -1396,17 +2597,157 @@
     path notNil ifTrue:[
         path := Java as_ST_String:path.
         (f := path asFilename) exists ifTrue:[
-            ^ 1
+            ^ 1 "TRUE"
+        ]
+    ].
+    ^ 0 "FALSE"
+
+    "Created: / 5.1.1998 / 02:07:48 / cg"
+    "Modified: / 7.1.1998 / 10:32:15 / cg"
+!
+
+_File_isAbsolute:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        (f := path asFilename) isAbsolute ifTrue:[
+            ^ 1 "/ TRUE
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Modified: / 8.8.1997 / 12:04:05 / cg"
+    "Created: / 11.1.1998 / 09:54:38 / cg"
+!
+
+_File_isDirectory0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        (f := path asFilename) exists ifTrue:[
+            f isDirectory ifTrue:[^ 1 "TRUE"]
+        ]
+    ].
+    ^ 0 "FALSE"
+
+    "Modified: / 19.8.1997 / 16:34:32 / cg"
+    "Created: / 7.1.1998 / 10:31:37 / cg"
+!
+
+_File_isFile0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        (f := path asFilename) exists ifTrue:[
+            f isDirectory ifFalse:[^ 1 "TRUE"]
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Modified: / 19.8.1997 / 16:34:42 / cg"
+    "Created: / 11.1.1998 / 11:40:22 / cg"
+!
+
+_File_length0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        (f := path asFilename) exists ifTrue:[
+            ^ f fileSize
         ]
     ].
     ^ 0
 
-    "Modified: / 19.8.1997 / 16:34:13 / cg"
-    "Created: / 5.1.1998 / 02:07:48 / cg"
+    "Modified: / 8.8.1997 / 12:04:05 / cg"
+    "Created: / 7.1.1998 / 12:18:57 / cg"
 ! !
 
 !JavaVM class methodsFor:'native - java.lang'!
 
+_ClassLoader_defineClass0:nativeContext
+    "create a new class from a given byteArray.
+     Here, construct a stream on it and pass the work to the
+     JavaClassReader."
+
+    |jClassLoader jName name data offset length inStream newClass
+     loaderStub jClass|
+
+    jClassLoader := nativeContext receiver.
+    jName := nativeContext argAt:1.
+
+    "/ className is now optional ...
+"/    jName isNil ifTrue:[
+"/        self internalError:'nil name in defineClass'.
+"/        ^ nil
+"/    ] ifFalse:[
+"/        name := Java as_ST_String:jName.
+"/    ].
+
+    data := nativeContext argAt:2.
+    offset := nativeContext argAt:3.
+    length := nativeContext argAt:4.
+
+    inStream := data readStream.
+    inStream position:offset + 1.
+    inStream readLimit:(offset + length).
+
+    loaderStub := Plug new.
+    loaderStub respondTo:#loadClass: with:[:clsName |
+                                                |jName|
+
+self halt.
+                                                jName := Java as_String:clsName.
+                                                "/ jClassLoader loadClass:jName
+                                                jClassLoader 
+                                                    perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
+                                                    with:jName.
+                                          ].
+
+    ('JAVA: defining class ...') infoPrintCR.
+
+"/    self internalError:'break'.
+
+    newClass := JavaClassReader 
+                    readStream:inStream 
+                    loader:loaderStub
+                    loadUnresolved:false.
+
+newClass isNil ifTrue:[
+    ('JAVA: defineClass failed') infoPrintCR.
+    ^ nil.
+].
+    Transcript showCR:('defined class ' , newClass fullName , '.').
+    newClass classLoader:jClassLoader.
+
+    ('Java: defined new class: ' , newClass fullName) infoPrintCR.
+
+    jClass := JavaClasses at:newClass ifAbsent:nil.
+    jClass isNil ifTrue:[
+        "/ class must be initialized (with all of its superclasses ?).
+        newClass initializeIfNotYetDone.
+
+        JavaClasses at:newClass put:(jClass := (Java at:'java.lang.Class') new).
+        JavaClasses at:jClass put:newClass.
+    ].
+
+    ^ jClass
+
+    "Created: / 7.1.1998 / 12:35:10 / cg"
+    "Modified: / 8.1.1998 / 16:14:27 / cg"
+!
+
 _ClassLoader_findSystemClass0:nativeContext
     |loader name class jClass|
 
@@ -1414,19 +2755,25 @@
     name := nativeContext argAt:1.
     name := Java as_ST_String:name.
 
-    ('JAVA: findSystemClass0 for ' , name) infoPrintCR.
-
-    JavaClassReader classLoaderQuerySignal answer:nil
-    do:[
-        class := Java classForName:name.
+    ('JAVA: findSystemClass0 for ' , name , ' loader is ' , loader displayString) infoPrintCR.
+    loader class == (Java classForName:'java.util.SystemClassLoader') ifTrue:[
+        Java classForName:name.
     ].
 
-    class isNil ifTrue:[
+"/    JavaClassReader classLoaderQuerySignal answer:nil "loader"
+"/    do:[
+"/        class := Java classForName:name.
+"/        JavaClassReader postLoadActions:true.
+"/    ].
+    class := Java at:name.
+    (class isNil 
+    "or:[class classLoader notNil]") ifTrue:[
 "/        self halt:'class: ' , name , ' not found.'.
 "/        self internalError:'class: ' , name , ' not found.'.
 
-        self throwException:(Java classForName:'java.lang.ClassNotFoundException') 
-                withMessage:'class: ' , name , ' not found.'.
+        self 
+            throwExceptionClassName:'java.lang.ClassNotFoundException'
+            withMessage:'class: ' , name , ' not found.'.
         ^ nil
     ].
 
@@ -1442,7 +2789,35 @@
     ^ jClass
 
     "Created: / 5.1.1998 / 02:53:04 / cg"
-    "Modified: / 5.1.1998 / 02:56:43 / cg"
+    "Modified: / 9.1.1998 / 22:32:50 / cg"
+!
+
+_ClassLoader_getSystemResourceAsStream0:nativeContext
+    |jString rString dir file text data inStream|
+
+    jString := nativeContext argAt:1.
+    rString := Java as_ST_String:jString.
+    Java classPath do:[:aPath |
+        (dir := aPath asFilename) exists ifTrue:[
+            (file := dir construct:rString) exists ifTrue:[
+                text := file contents asString.
+
+                "/ Copy data from returned buffer into Java byte array. 
+
+                data := text asByteArray.
+
+                "/ Create input stream using byte array 
+
+                inStream := (Java classForName:'java.io.ByteArrayInputStream') basicNew.
+                inStream invoke:'<init>([B)V' with:data.
+                ^ inStream.
+            ]
+        ]
+    ].
+    ^ nil
+
+    "Modified: / 8.8.1997 / 12:03:45 / cg"
+    "Created: / 8.1.1998 / 16:06:56 / cg"
 !
 
 _ClassLoader_init:nativeContext
@@ -1451,15 +2826,67 @@
     "Created: / 5.1.1998 / 02:04:43 / cg"
 !
 
+_ClassLoader_resolveClass0:nativeContext
+    "resolve a new class as previously created by defineClass0"
+
+    |jClassLoader jCls cls loaderStub|
+
+    jClassLoader := nativeContext receiver.
+    jCls := nativeContext argAt:1.
+    jCls isNil ifTrue:[
+        self halt.
+        ^ nil
+    ].
+    cls := JavaClasses at:jCls ifAbsent:nil.
+    cls isNil ifTrue:[
+        self halt.
+        ^ nil
+    ].
+    Transcript showCR:('resolving class ' , cls fullName , ' ...').
+
+    JavaClassReader classLoaderQuerySignal answer:jClassLoader 
+    do:[
+        JavaClassReader postLoadActions:true.
+        cls constantPool do:[:entry |
+            (entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
+                self halt:'debugHalt'.
+                entry preResolve.
+                self halt:'debugHalt'.
+            ]
+        ]
+    ].
+
+    "Created: / 7.1.1998 / 13:12:27 / cg"
+    "Modified: / 8.1.1998 / 16:13:57 / cg"
+!
+
 _Class_forName:nativeContext
     "get a java.lang.Class by name"
 
-    |jClassName className cls jClass|
+    |jClassName className cls jClass s m c loader|
 
     jClassName := nativeContext argAt:1.
     className := Java as_ST_String:jClassName.
 
-    cls := Java classForName:className.
+    (s := nativeContext sender) notNil ifTrue:[
+        (s isMemberOf:JavaContext) ifTrue:[
+            c := s method javaClass.
+            loader := c classLoader.
+            loader isNil ifTrue:[
+"/ self halt.
+            ]
+        ]
+    ].
+
+    JavaClassReader classLoaderQuerySignal answer:loader
+    do:[
+        cls := Java classForName:className.
+    ].
+
+"/(className startsWith:'sun.awt') ifTrue:[self halt].
+"/('classForName: ' , className , ' -> ') print.
+"/cls notNil ifTrue:[cls fullName printCR] ifFalse:['nil' printCR].
+
     cls isNil ifTrue:[
         ExceptionTrace ifTrue:[
             self halt:'no such class:' , className.
@@ -1482,7 +2909,7 @@
 
     ^ jClass
 
-    "Modified: / 4.1.1998 / 20:32:48 / cg"
+    "Modified: / 9.1.1998 / 03:08:39 / cg"
 !
 
 _Class_getClassLoader:nativeContext
@@ -1500,6 +2927,18 @@
     "Created: / 5.1.1998 / 02:51:59 / cg"
 !
 
+_Class_getName:nativeContext
+    "get a classes name"
+
+    |jClass cls|
+
+    jClass := nativeContext receiver.
+    cls := JavaClasses at:jClass.
+    ^ Java as_String:((cls fullName copyFrom:1) replaceAll:$/ with:$.).
+
+    "Modified: / 6.1.1998 / 18:30:52 / cg"
+!
+
 _Class_getPrimitiveClass:nativeContext
     "get a primitive class by name"
 
@@ -1542,6 +2981,44 @@
     "Modified: / 4.1.1998 / 01:12:27 / cg"
 !
 
+_Class_getSuperclass:nativeContext
+    "return a classes superclass"
+
+    |jClass cls superCls|
+
+    jClass := nativeContext receiver.
+    cls := JavaClasses at:jClass.
+    superCls := cls superclass.
+    superCls == JavaObject ifTrue:[
+        ^ nil.
+    ].
+    jClass := JavaClasses at:cls ifAbsent:nil.
+    jClass isNil ifTrue:[
+        "/ class must be initialized (with all of its superclasses ?).
+        cls initializeIfNotYetDone.
+
+        JavaClasses at:cls put:(jClass := (Java at:'java.lang.Class') new).
+        JavaClasses at:jClass put:cls.
+    ].
+    ^ jClass
+
+    "Created: / 12.1.1998 / 12:38:36 / cg"
+    "Modified: / 12.1.1998 / 12:39:00 / cg"
+!
+
+_Class_isInterface:nativeContext
+    "return true, if this class is an interface"
+
+    |jClass cls|
+
+    jClass := nativeContext receiver.
+    cls := JavaClasses at:jClass.
+    cls isInterface ifTrue:[^ 1 "TRUE"].
+    ^ 0 "FALSE"
+
+    "Created: / 12.1.1998 / 12:37:02 / cg"
+!
+
 _Class_newInstance:nativeContext
     "get an instance for a java.lang.Class"
 
@@ -1551,11 +3028,12 @@
     cls := JavaClasses at:jClass.
     cls initializeIfNotYetDone.
     newInst := cls newCleared.
+    newInst perform:#'<init>()V'.
 
     ^ newInst
 
     "Created: / 2.1.1998 / 22:41:38 / cg"
-    "Modified: / 5.1.1998 / 02:57:00 / cg"
+    "Modified: / 7.1.1998 / 14:41:34 / cg"
 !
 
 _Double_doubleToLongBits:nativeContext
@@ -1619,6 +3097,25 @@
     "Created: / 4.1.1998 / 01:45:00 / cg"
 !
 
+_Double_valueOf0:nativeContext
+    |s d|
+
+    s := nativeContext argAt:1.
+    s notNil ifTrue:[
+        s := Java as_ST_String:s.
+        d := Float readFrom:s onError:nil.
+    ].
+    d isNil ifTrue:[
+        self throwNumberFormatException.
+        "/ not reached
+    ].
+
+    ^ d
+
+    "Modified: / 8.8.1997 / 12:03:55 / cg"
+    "Created: / 7.1.1998 / 11:09:43 / cg"
+!
+
 _Float_floatToIntBits:nativeContext
     |f i|
 
@@ -1641,6 +3138,109 @@
     "Created: / 4.1.1998 / 01:25:50 / cg"
 !
 
+_Math_ceil:nativeContext
+    "ceiling"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal ceilingAsFloat
+
+    "Created: / 7.1.1998 / 15:43:00 / cg"
+!
+
+_Math_cos:nativeContext
+    "cosine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal cos
+
+    "Created: / 7.1.1998 / 15:41:30 / cg"
+!
+
+_Math_floor:nativeContext
+    "floor"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal floorAsFloat
+
+    "Created: / 7.1.1998 / 19:09:21 / cg"
+!
+
+_Math_log:nativeContext
+    "logarithm"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal log
+
+    "Created: / 7.1.1998 / 15:42:19 / cg"
+!
+
+_Math_pow:nativeContext
+    "power"
+
+    |dVal1 dVal2|
+
+    dVal1 := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    dVal2 := nativeContext argAt:3.
+    (nativeContext argAt:4) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal1 raisedTo:dVal2
+
+    "Modified: / 15.8.1997 / 05:24:27 / cg"
+    "Created: / 7.1.1998 / 15:44:13 / cg"
+!
+
+_Math_sin:nativeContext
+    "sine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal sin
+
+    "Created: / 7.1.1998 / 15:41:40 / cg"
+!
+
+_Math_sqrt:nativeContext
+    "square root"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+        self halt:'expected double arg'
+    ].
+    ^ dVal sqrt
+
+    "Created: / 7.1.1998 / 15:42:40 / cg"
+!
+
 _Object_clone:nativeContext
     "clone an object"
 
@@ -1653,6 +3253,28 @@
     "Created: / 4.1.1998 / 19:39:26 / cg"
 !
 
+_Object_getClass:nativeContext
+    "return an objects class"
+
+    |o cls jClass|
+
+    o := nativeContext receiver.
+    cls := o class.
+
+    jClass := JavaClasses at:cls ifAbsent:nil.
+    jClass isNil ifTrue:[
+        "/ class must be initialized (with all of its superclasses ?).
+        cls initializeIfNotYetDone.
+
+        JavaClasses at:cls put:(jClass := (Java at:'java.lang.Class') new).
+        JavaClasses at:jClass put:cls.
+    ].
+    ^ jClass
+
+    "Created: / 6.1.1998 / 18:28:27 / cg"
+    "Modified: / 6.1.1998 / 18:28:56 / cg"
+!
+
 _Object_hashCode:nativeContext
     "identityHash"
 
@@ -1665,6 +3287,14 @@
     "Created: / 4.1.1998 / 19:40:26 / cg"
 !
 
+_Object_notify:nativeContext
+    "wakeup"
+
+    self wakeup:(nativeContext receiver).
+
+    "Created: / 6.1.1998 / 21:09:26 / cg"
+!
+
 _Object_notifyAll:nativeContext
     self wakeupAll:(nativeContext receiver).
 
@@ -1715,6 +3345,7 @@
             ('====> thread ' , Processor activeProcess name , ' waiting ...') infoPrintCR.
         ].
         tmo = 0 ifTrue:[
+            Processor activeProcess state:#javaWait.
             sema wait.
         ] ifFalse:[
             sema waitWithTimeout:tmo / 1000.
@@ -1749,7 +3380,7 @@
         '====> thread continues ...' printCR.
     ]
 
-    "Modified: / 2.1.1998 / 21:42:59 / cg"
+    "Modified: / 9.1.1998 / 10:41:47 / cg"
 !
 
 _Runtime_buildLibName:nativeContext
@@ -1772,6 +3403,55 @@
     "Created: / 4.1.1998 / 19:07:14 / cg"
 !
 
+_Runtime_exitInternal:nativeContext
+    "exit - here, we only shut down java threads"
+
+    |enteredMonitors|
+
+    (enteredMonitors := self enteredMonitors) size > 0 ifTrue:[
+        enteredMonitors do:[:handle | 
+            | mon |
+
+            mon := LockTable at:handle ifAbsent:nil.
+            mon isNil ifTrue:[
+                self halt:'no monitor in exitInternal'.
+            ] ifFalse:[
+                mon exit.
+('====> terminateThread - exit monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR. 
+"/                LockTableAccess critical:[
+"/                    mon isFree ifTrue:[
+"/                        LockTable removeKey:handle
+"/                    ]
+"/                ]
+            ].
+        ].
+    ].
+
+    JavaVM releaseAllJavaResources.
+    AbortSignal raise.
+    self halt.
+
+    "Created: / 7.1.1998 / 22:48:51 / cg"
+    "Modified: / 7.1.1998 / 22:56:07 / cg"
+!
+
+_Runtime_freeMemory:nativeContext
+    "free memory - Returns the number of free bytes"
+
+    ^ ObjectMemory freeListSpace + ObjectMemory freeSpace
+
+    "Created: / 12.1.1998 / 12:59:53 / cg"
+!
+
+_Runtime_gc:nativeContext
+    "Runs the garbage collector.
+     Ignored, since the ST-gc runs all the time."
+
+    ^ self
+
+    "Modified: / 12.1.1998 / 12:58:32 / cg"
+!
+
 _Runtime_initializeLinkerInternal:nativeContext
     "init sharedLib linker, return searchPath as javaString"
 
@@ -1849,6 +3529,14 @@
     "Created: / 4.1.1998 / 19:10:54 / cg"
 !
 
+_Runtime_totalMemory:nativeContext
+    "free memory - Returns the total number of bytes"
+
+    ^ ObjectMemory oldSpaceSize + ObjectMemory newSpaceSize
+
+    "Created: / 12.1.1998 / 12:59:23 / cg"
+!
+
 _System_arraycopy:nativeContext
     |srcArray srcIdx dstArray dstIdx count|
 
@@ -1877,11 +3565,12 @@
 
     |seconds|
 
-    seconds := AbsoluteTime now - (AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0).
-    ^ seconds * 1000
+    ^ AbsoluteTime now millisecondDeltaFrom:(AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0).
+"/    seconds := AbsoluteTime now - (AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0).
+"/    ^ seconds * 1000
 
     "Created: / 3.1.1998 / 03:25:50 / cg"
-    "Modified: / 3.1.1998 / 03:47:32 / cg"
+    "Modified: / 10.1.1998 / 01:32:24 / cg"
 !
 
 _System_initProperties:nativeContext
@@ -1974,14 +3663,51 @@
     stProcess := JavaVM stProcessForJavaThread:jThread.
     stProcess isNil ifTrue:[
         ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ^ 0 "FALSE"
+    ].
+    stProcess isDead ifTrue:[^ 0 "FALSE"].
+    ^ 1 "TRUE"
+
+    "Created: / 5.1.1998 / 02:03:51 / cg"
+    "Modified: / 8.1.1998 / 01:07:03 / cg"
+!
+
+_Thread_isInterrupted:nativeContext
+    "ask if a thread is interrupted (clear interruptState if arg is true)"
+
+    |jThread stProcess clearInterrupt rslt|
+
+    jThread := nativeContext receiver.
+    stProcess := self stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        self halt.
         ^ 0
     ].
-"/    'JAVA: isAlive: ' print. jThread print. ' stProcess= ' print. stProcess printNL.
-    stProcess isDead ifTrue:[^ 0].
-    ^ 1
-
-    "Modified: / 2.1.1998 / 21:48:56 / cg"
-    "Created: / 5.1.1998 / 02:03:51 / cg"
+
+    clearInterrupt := nativeContext argAt:1.
+    rslt := stProcess isInterrupted ifTrue:[1] ifFalse:[0].
+    clearInterrupt ~~ 0 ifTrue:[stProcess clearInterruptActions].
+    ^ rslt
+
+    "Modified: / 2.1.1998 / 21:49:06 / cg"
+    "Created: / 7.1.1998 / 18:50:26 / cg"
+!
+
+_Thread_resume0:nativeContext
+    "yield"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ^ nil "void"
+    ].
+    stProcess resume
+
+    "Modified: / 8.1.1998 / 00:14:43 / cg"
+    "Created: / 8.1.1998 / 01:06:27 / cg"
 !
 
 _Thread_setPriority0:nativeMethodContext
@@ -2005,6 +3731,22 @@
     "Modified: / 2.1.1998 / 22:38:20 / cg"
 !
 
+_Thread_sleep:nativeContext
+    "sleep for some milliseconds "
+
+    |millis|
+
+    (nativeContext argAt:2) ~~ DUMMY_LONG_HIGHWORD ifTrue:[
+        self internalError:'expected long arg'.
+    ] ifFalse:[
+        millis := nativeContext argAt:1.
+        Delay waitForMilliseconds:(millis max:200)
+    ].
+
+    "Created: / 7.1.1998 / 15:34:23 / cg"
+    "Modified: / 7.1.1998 / 15:34:36 / cg"
+!
+
 _Thread_start:nativeContext
     "start the thread"
 
@@ -2020,6 +3762,10 @@
                     for:[   
                             jThread perform:#'run()V'.
                             ('JAVA: thread ' , stProcess name , ' terminated') infoPrintCR.
+
+                            jThread perform:#'exit()V'.
+                            ('JAVA: after exit of thread ' , stProcess name) infoPrintCR.
+                            Java threads removeKey:jThread.
                         ] 
                     priority:(Processor activePriority).
 
@@ -2040,12 +3786,85 @@
 
     ^ nil
 
-    "Modified: / 2.1.1998 / 18:13:03 / cg"
     "Created: / 3.1.1998 / 02:05:52 / cg"
+    "Modified: / 9.1.1998 / 03:39:54 / cg"
+!
+
+_Thread_stop0:nativeContext
+    "terminate a thread"
+
+    |jThread stProcess death|
+
+    jThread := nativeContext receiver.
+
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ^ nil "void"
+    ].
+    death := nativeContext argAt:1.
+    stProcess 
+        interruptWith:[
+                        JavaVM javaExceptionSignal handle:[:ex |
+                            Processor activeProcess terminate
+                        ] do:[
+                            ('JAVA: thread exit: ' , jThread displayString) infoPrintNL.
+                            jThread perform:#'exit()V'.
+                            self throwException:death.
+                        ]
+                      ].
+    stProcess resume.
+
+    [stProcess isDead] whileFalse:[
+        stProcess resume.
+        Delay waitForSeconds:0.1
+    ].
+    stProcess terminate
+
+    "Created: / 8.1.1998 / 13:11:17 / cg"
+    "Modified: / 9.1.1998 / 03:49:45 / cg"
+!
+
+_Thread_suspend0:nativeContext
+    "yield"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ^ nil "void"
+    ].
+    stProcess suspend
+
+    "Created: / 8.1.1998 / 01:05:49 / cg"
+    "Modified: / 8.1.1998 / 01:06:36 / cg"
+!
+
+_Thread_yield:nativeContext
+    "yield"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ^ nil "void"
+    ].
+    stProcess == Processor activeProcess ifTrue:[
+        Processor yield.
+    ] ifFalse:[
+        self halt.
+    ].
+
+    "Created: / 5.1.1998 / 02:03:51 / cg"
+    "Modified: / 8.1.1998 / 01:06:41 / cg"
 !
 
 _Throwable_fillInStackTrace:nativeContext
-    |exClass exceptionObject con|
+    |exClass exceptionObject list con|
 
     exClass := Java classNamed:'java.lang.Throwable'.
 
@@ -2070,12 +3889,48 @@
         ].
     ].
 
-    exceptionObject instVarNamed:'backtrace' put:con.
+    list := OrderedCollection new.
+    [con notNil] whileTrue:[
+        (con isKindOf:JavaContext) ifTrue:[
+            list add:con
+        ].
+        con := con sender
+    ].
+
+    exceptionObject instVarNamed:'backtrace' put:(list asArray).
 
     ^ nil.
 
-    "Modified: / 14.8.1997 / 18:47:24 / cg"
     "Created: / 4.1.1998 / 14:27:40 / cg"
+    "Modified: / 8.1.1998 / 03:06:03 / cg"
+!
+
+_Throwable_printStackTrace0:nativeContext
+    |outStream exceptionObject contextList|
+
+    outStream := nativeContext argAt:1.
+    exceptionObject := nativeContext receiver.
+
+    contextList := exceptionObject instVarNamed:'backtrace'.
+
+    self javaConsoleStream cr.
+    self javaConsoleStream nextPutLine:'JAVA: stackTrace:'.
+
+    contextList do:[:con |
+        self javaConsoleStream nextPutLine:('    ' , con displayString).
+    ].
+    self javaConsoleStream nextPutLine:'----------------------------------------------------'
+
+    "Created: / 4.1.1998 / 14:27:40 / cg"
+    "Modified: / 8.1.1998 / 14:34:34 / cg"
+! !
+
+!JavaVM class methodsFor:'native - java.math'!
+
+_BigInteger_plumbInit:nativeContext
+    "/ self unimplementedNativeMethod.
+
+    "Created: / 12.1.1998 / 12:55:53 / cg"
 ! !
 
 !JavaVM class methodsFor:'native - java.net'!
@@ -2101,6 +3956,25 @@
     "Created: / 5.1.1998 / 02:07:03 / cg"
 !
 
+_InetAddressImpl_lookupAllHostAddr:nativeContext
+    ""
+
+    |jAddrImpl jHostName hostName addrBytes|
+
+    jAddrImpl := nativeContext receiver.
+    jHostName := nativeContext argAt:1.
+
+    hostName := Java as_ST_String:jHostName.
+    addrBytes := Socket ipAddressOfHost:hostName.
+    addrBytes isNil ifTrue:[
+        addrBytes := #[0 0 0 0] copy
+    ].
+    ^ Array with:addrBytes
+
+    "Modified: / 8.8.1997 / 12:04:25 / cg"
+    "Created: / 7.1.1998 / 18:51:31 / cg"
+!
+
 _InetAddressImpl_makeAnyLocalAddress:nativeContext
     ""
 
@@ -2125,6 +3999,11 @@
 
     "Modified: / 7.8.1997 / 21:16:57 / cg"
     "Created: / 5.1.1998 / 02:06:27 / cg"
+!
+
+_PlainSocketImpl_initProto:nativeContext
+
+    "Created: / 12.1.1998 / 12:56:52 / cg"
 ! !
 
 !JavaVM class methodsFor:'native - java.utils'!
@@ -2159,6 +4038,111 @@
     "Modified: / 5.1.1998 / 02:49:47 / cg"
 ! !
 
+!JavaVM class methodsFor:'native - netscape'!
+
+_MozillaAppletContext_pMochaOnLoad:nativeContext
+    |id|
+
+    id := nativeContext argAt:1.
+'JAVA: MozillaAppletContext_pMochaOnLoad: ' print. id printNL.
+    ^ nil
+
+    "Modified: / 21.8.1997 / 16:40:45 / cg"
+    "Created: / 6.1.1998 / 20:37:13 / cg"
+!
+
+_MozillaAppletContext_pShowStatus:nativeContext
+    |s js|
+
+    js := nativeContext argAt:1.
+    s := Java as_ST_String:js.
+
+    self activityNotification:s.
+"/ Transcript showCR:s.
+    ^ nil
+
+    "Created: / 6.1.1998 / 18:31:34 / cg"
+    "Modified: / 8.1.1998 / 17:06:13 / cg"
+!
+
+_URLStreamHandlerFactory_pInit:nativeContext
+    "/ self unimplementedNativeMethod.
+
+    "Created: / 10.1.1998 / 15:47:24 / cg"
+! !
+
+!JavaVM class methodsFor:'native - sun.audio'!
+
+_AudioDevice_audioClose:nativeContext
+
+    "Created: / 10.1.1998 / 15:45:16 / cg"
+!
+
+_AudioDevice_audioOpen:nativeContext
+    ^ -1
+
+    "Created: / 10.1.1998 / 15:45:30 / cg"
+! !
+
+!JavaVM class methodsFor:'native - sun.awt'!
+
+_GifImageDecoder_parseImage:nativeContext
+    |decoder width height bool1 depth srcBytes dstBytes i1 i2 colorModel|
+
+    decoder := nativeContext receiver.
+
+    i1 := nativeContext argAt:1.
+    i2 := nativeContext argAt:2.
+    width := nativeContext argAt:3.
+    height := nativeContext argAt:4.
+    bool1 := nativeContext argAt:5.
+    depth := nativeContext argAt:6.
+    srcBytes := nativeContext argAt:7.
+    dstBytes := nativeContext argAt:8.
+    colorModel := nativeContext argAt:9.
+
+'JAVA: GIF parseImage ignored for now' infoPrintCR.
+
+self halt.
+"/ self internalError:'breakPoint'.
+    ^ 1 "/ true
+
+    "Modified: / 11.1.1998 / 16:00:34 / cg"
+!
+
+_ImageRepresentation_disposeImage:nativeContext
+    |imgRep|
+
+    imgRep := nativeContext receiver.
+
+    "Created: / 7.1.1998 / 22:31:46 / cg"
+    "Modified: / 7.1.1998 / 23:00:07 / cg"
+!
+
+_ImageRepresentation_finish:nativeContext
+    |imgRep bool|
+
+    imgRep := nativeContext receiver.
+    bool := nativeContext argAt:1.
+
+    'JAVA: ImageRepresentation_finish ignored for now' infoPrintCR.
+
+    ^ 1 "/ true
+
+    "Modified: / 21.8.1997 / 17:07:13 / cg"
+    "Created: / 8.1.1998 / 00:11:40 / cg"
+!
+
+_ImageRepresentation_offscreenInit:nativeContext
+    |imgRep jclr|
+
+    imgRep := nativeContext receiver.
+    jclr := nativeContext argAt:1
+
+    "Created: / 7.1.1998 / 22:31:46 / cg"
+    "Modified: / 11.1.1998 / 16:32:29 / cg"
+! !
+
 !JavaVM class methodsFor:'semaphores & monitors'!
 
 monitorFor:someObject
@@ -2287,9 +4271,400 @@
     "Modified: / 3.1.1998 / 03:05:18 / cg"
 ! !
 
+!JavaVM class methodsFor:'windows - events'!
+
+awtEventsForEvent:anEvent javaWindow:jWin
+    "given an ST/X event, create corresponding AWT event(s) for it"
+
+    |jEv jEv1 jEv2
+     modifiers key keyChar untranslatedKey id type x y w h 
+     eventArgs clickCount jRect
+     jKeyEventClass jInputEventClass jMouseEventClass
+     jWindowEventClass jPaintEventClass jComponentEventClass|
+
+    type := anEvent type.
+    eventArgs := anEvent arguments.
+
+    key := 0.
+    modifiers := 0.
+    x := 0.
+    y := 0.
+
+    jInputEventClass := Java classForName:'java.awt.event.InputEvent'.
+
+    (anEvent isKeyEvent 
+    or:[anEvent isButtonEvent
+    or:[anEvent isPointerEnterLeaveEvent]]) ifTrue:[
+        anEvent hasAlt ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'ALT_MASK')
+        ].
+        anEvent hasCtrl ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'CTRL_MASK')
+        ].
+        anEvent hasMeta ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'META_MASK')
+        ].
+        anEvent hasShift ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'SHIFT_MASK')
+        ].
+        anEvent hasButton1 ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON1_MASK')
+        ].
+        anEvent hasButton2 ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON2_MASK')
+        ].
+        anEvent hasButton3 ifTrue:[
+            modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON3_MASK')
+        ].
+
+        anEvent isPointerEnterLeaveEvent ifFalse:[
+            "/ ST/X does not (yet) record this information
+            "/ with pointerLeave events.
+
+            x := anEvent x.
+            y := anEvent y.
+        ].
+    ].
+
+    anEvent isKeyEvent ifTrue:[
+        jKeyEventClass := Java classForName:'java.awt.event.KeyEvent'.
+
+        key := 0.
+        keyChar := 0.
+
+        key := anEvent key.
+        key isCharacter ifTrue:[
+            key := keyChar := key asciiValue
+        ] ifFalse:[
+            untranslatedKey := anEvent view device keyboardMap keyAtValue:key ifAbsent:key.
+            untranslatedKey == #Delete ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_DELETE' "/ 127
+            ].
+            untranslatedKey == #BackSpace ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_BACK_SPACE' "/ 8
+            ].
+            untranslatedKey == #Return ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_ENTER' "/ 13
+            ].
+            untranslatedKey == #Tab ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_TAB' "/ 9
+            ].
+            untranslatedKey == #Home ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_HOME'
+            ].
+            untranslatedKey == #End ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_END'
+            ].
+            untranslatedKey == #Prior ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_PAGE_UP'
+            ].
+            key == #EndOfText ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_PAGE_DOWN'
+            ].
+            untranslatedKey == #CursorUp ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_UP'
+            ].
+            untranslatedKey == #CursorDown ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_DOWN'
+            ].
+            untranslatedKey == #CursorLeft ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_LEFT'
+            ].
+            untranslatedKey == #CursorRight ifTrue:[
+                key := jKeyEventClass instVarNamed:'VK_RIGHT'
+            ].
+            (#( F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11)
+            includes:untranslatedKey) ifTrue:[
+                key := jKeyEventClass instVarNamed:('VK_' , untranslatedKey)
+            ].
+        ].
+        (type == #'keyPress:x:y:') ifTrue:[
+            id := jKeyEventClass instVarNamed:'KEY_PRESSED'
+        ] ifFalse:[
+            id := jKeyEventClass instVarNamed:'KEY_RELEASED'
+        ].
+        jEv := jKeyEventClass basicNew.
+        jEv instVarNamed:'modifiers' put:modifiers.
+        jEv instVarNamed:'keyCode'   put:key.
+        jEv instVarNamed:'keyChar'   put:keyChar.
+        jEv instVarNamed:'id'        put:id.
+"/        jEv instVarNamed:'x'         put:x.
+"/        jEv instVarNamed:'y'         put:y.
+        jEv instVarNamed:'when'      put:(OperatingSystem getMillisecondTime).
+        ^ Array with:jEv
+    ].
+
+    (anEvent isButtonEvent 
+    or:[anEvent isPointerEnterLeaveEvent]) ifTrue:[
+        jMouseEventClass := Java classForName:'java.awt.event.MouseEvent'.
+        clickCount := 1.
+
+        (type == #'buttonPress:x:y:') ifTrue:[
+            id := jMouseEventClass instVarNamed:'MOUSE_PRESSED'
+        ] ifFalse:[
+            (type == #'buttonRelease:x:y:') ifTrue:[
+                id := jMouseEventClass instVarNamed:'MOUSE_RELEASED'
+            ] ifFalse:[
+                (type == #'buttonMotion:x:y:') ifTrue:[
+                    id := jMouseEventClass instVarNamed:'MOUSE_MOVED'
+                ] ifFalse:[
+"/                    (type == #'pointerMotion:x:y:') ifTrue:[
+"/                        id := jMouseEventClass instVarNamed:'MOUSE_MOVED'
+"/                    ] ifFalse:[
+                        (type == #'pointerEnter:x:y:') ifTrue:[
+                            id := jMouseEventClass instVarNamed:'MOUSE_ENTERED'
+                        ] ifFalse:[
+                            (type == #'pointerLeave:') ifTrue:[
+                                id := jMouseEventClass instVarNamed:'MOUSE_EXITED'
+                            ] ifFalse:[
+                                (type == #'buttonMultiPress:x:y:') ifTrue:[
+                                    id := jMouseEventClass instVarNamed:'MOUSE_PRESSED'.
+                                    clickCount := 2.
+                                ] ifFalse:[
+                                    self halt.
+                                ]
+                            ]
+"/                        ]
+                    ]
+                ]
+            ]
+        ].
+        jEv := jMouseEventClass basicNew.
+        jEv instVarNamed:'modifiers' put:modifiers.
+        jEv instVarNamed:'id'        put:id.
+        jEv instVarNamed:'x'         put:x.
+        jEv instVarNamed:'y'         put:y.
+        jEv instVarNamed:'when'      put:(OperatingSystem getMillisecondTime).
+        ^ Array with:jEv
+    ].
+
+
+    ((type == #'exposeX:y:width:height:') 
+    or:[(type == #'graphicExposeX:y:width:height:')
+    or:[(type == #damage)]]) ifTrue:[
+        jPaintEventClass := Java classForName:'java.awt.event.PaintEvent'.
+        jWindowEventClass := Java classForName:'java.awt.event.WindowEvent'.
+        id := (jPaintEventClass instVarNamed:'PAINT').
+"/        id := (jPaintEventClass instVarNamed:'UPDATE').
+
+        ((type == #'exposeX:y:width:height:') 
+        or:[(type == #'graphicExposeX:y:width:height:')]) ifTrue:[
+            x := eventArgs at:1.
+            y := eventArgs at:2.
+            w := eventArgs at:3.
+            h := eventArgs at:4.
+        ] ifFalse:[
+            x := eventArgs left.
+            y := eventArgs top.
+            w := eventArgs width.
+            h := eventArgs height.
+        ].
+        jRect := (Java classForName:'java.awt.Rectangle') basicNew.
+        jRect instVarNamed:'x' put:x.
+        jRect instVarNamed:'y' put:y.
+        jRect instVarNamed:'width' put:w.
+        jRect instVarNamed:'height' put:h.
+
+        jEv := jPaintEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        jEv instVarNamed:'updateRect' put:jRect.
+
+"/        jEv instVarNamed:'g'         put:jWin.
+        ^ Array with:jEv.
+    ].
+
+    (type == #'configureX:y:width:height:') ifTrue:[
+        jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'.
+        id := (jComponentEventClass instVarNamed:'COMPONENT_MOVED').
+"/        x := eventArgs at:1.
+"/        y := eventArgs at:2.
+        jEv1 := jComponentEventClass basicNew.
+        jEv1 instVarNamed:'id'        put:id.
+
+        id := (jComponentEventClass instVarNamed:'COMPONENT_RESIZED').
+        jEv2 := jComponentEventClass basicNew.
+        jEv2 instVarNamed:'id'        put:id.
+        ^ Array with:jEv1 with:jEv2.
+    ].
+    (type == #'focusIn') ifTrue:[
+'shown' printCR.
+        jComponentEventClass := Java classForName:'java.awt.event.FocusEvent'.
+        id := (jComponentEventClass instVarNamed:'FOCUS_GAINED').
+        jEv := jComponentEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        ^ Array with:jEv.
+    ].
+    (type == #'focusOut') ifTrue:[
+'shown' printCR.
+        jComponentEventClass := Java classForName:'java.awt.event.FocusEvent'.
+        id := (jComponentEventClass instVarNamed:'FOCUS_LOST').
+        jEv := jComponentEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        ^ Array with:jEv.
+    ].
+    (type == #'mapped') ifTrue:[
+'shown' printCR.
+        jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'.
+        id := (jComponentEventClass instVarNamed:'COMPONENT_SHOWN').
+"/        x := eventArgs at:1.
+"/        y := eventArgs at:2.
+        jEv := jComponentEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        ^ Array with:jEv.
+    ].
+    (type == #'unmapped') ifTrue:[
+'hidden' printCR.
+        jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'.
+        id := (jComponentEventClass instVarNamed:'COMPONENT_HIDDEN').
+"/        x := eventArgs at:1.
+"/        y := eventArgs at:2.
+        jEv := jComponentEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        ^ Array with:jEv.
+    ].
+
+    (type == #terminate) ifTrue:[
+        jWindowEventClass := Java classForName:'java.awt.event.WindowEvent'.
+        id := (jWindowEventClass instVarNamed:'WINDOW_CLOSED').
+        jEv := jWindowEventClass basicNew.
+        jEv instVarNamed:'id'        put:id.
+        ^ Array with:jEv.
+    ].
+    ('JAVA: unhandled event:' , type) infoPrintCR.
+    ^ nil.
+
+    "Created: / 6.1.1998 / 20:38:58 / cg"
+    "Modified: / 11.1.1998 / 12:11:07 / cg"
+!
+
+doWindowsEventThread
+    "invoked in an endless loop by the WToolkit-eventLoop
+     native method."
+
+    |sensor event|
+
+    JavaWindowGroup isNil ifTrue:[
+        "/ '*** eventThread: no windowGroup ...' printCR.
+        Delay waitForSeconds:0.1.
+        ^ self
+    ].
+
+    KnownWindows isNil ifTrue:[
+        "/ '*** eventThread: no views ...' printCR.
+        Delay waitForSeconds:0.1.
+        ^ self
+    ].
+
+    "/ wait for an event to arrive ...
+
+    sensor := JavaWindowGroup sensor.
+    (sensor hasEvents or:[sensor hasDamage]) ifFalse:[
+        EventTrace ifTrue:[
+            '*** eventThread waiting ...' printCR.
+        ].
+        Processor activeProcess state:#eventWait.
+        sensor eventSemaphore wait.
+        ^ self.
+    ].
+
+    EventTrace ifTrue:[
+        '*** eventThread event arrived ...' printCR.
+    ].
+
+    "/ EventTrace := true
+    sensor hasDamage ifTrue:[
+        EventTrace ifTrue:[
+            '*** eventThread: damage arrived ...' printCR.
+        ].
+        event := sensor nextDamage.
+    ] ifFalse:[
+        event := sensor nextEvent.
+    ].
+    event isNil ifTrue:[
+        '*** eventThread: nil event ignored' printCR.
+        ^ self
+    ].
+
+    self processEvent:event
+
+    "Created: / 6.1.1998 / 21:02:40 / cg"
+    "Modified: / 8.1.1998 / 17:57:41 / cg"
+!
+
+processEvent:event
+    |evQ jEvents jWToolKit jWinPeer jWin v|
+
+    KnownWindows isNil ifTrue:[
+        ^ self
+    ].
+
+    v := event view.
+    jWinPeer := KnownWindows keyAtValue:v.
+    jWinPeer isNil ifTrue:[
+        EventTrace ifTrue:[
+            ('*** eventThread: ' , event type , '-event for unknown java-view - passed to view.') printCR.
+        ].
+        event sendEventWithFocusOn:nil.
+        ^ self
+    ].
+
+    "/ most views handle their events themself (being ST/X views) ...
+
+    v class ~~ JavaView ifTrue:[
+        v class ~~ StandardSystemView ifTrue:[
+            EventTrace ifTrue:[
+                    ('*** eventThread: event handled by view itself (' , v class name , ')') printCR.
+            ].
+            event sendEventWithFocusOn:nil.
+            ^ self.
+        ].
+        "/ send to view, but also handle in JAVA
+        event sendEventWithFocusOn:nil.
+    ].
+
+    jWin := jWinPeer instVarNamed:'target'.
+
+    EventTrace ifTrue:[
+        ('*** eventThread: event (' , event type , ') handled by JAVA: ') infoPrint.
+        jWinPeer class name infoPrint. ' (' infoPrint.
+        jWin class name infoPrint. ')' infoPrintCR.
+    ].
+
+    "/ create an event
+
+    jEvents := self awtEventsForEvent:event javaWindow:jWin.
+    jEvents isNil ifTrue:[
+        EventTrace ifTrue:[
+            ('*** eventThread: event ignored: ' , event type) printCR.
+        ].
+        ^ self
+    ].
+
+"/    v superView isNil ifTrue:[
+"/        ('*** eventThread: event ignored for topView: ' , event type) printCR.
+"/        ^ self
+"/    ].
+
+    jWToolKit := (Java classForName:'java.awt.Toolkit') invoke:#getDefaultToolkit.
+
+    jEvents do:[:jEv |
+        jEv instVarNamed:'source'   put:jWin.
+        jEv instVarNamed:'consumed' put:0.
+
+        "/ post it (them) to the event queue
+
+        jWToolKit class
+            invoke:#'postEvent(Ljava/awt/AWTEvent;)V' 
+            with:jEv.
+    ].
+
+    "Created: / 6.1.1998 / 20:36:36 / cg"
+    "Modified: / 9.1.1998 / 10:39:01 / cg"
+! !
+
 !JavaVM class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.1 1998/01/05 18:50:00 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.2 1998/01/12 14:24:40 cg Exp $'
 ! !
 JavaVM initialize!