Buggy code:
if ( ( vStyle == ( SWT . UP ) ) || ( vStyle == ( SWT . DOWN ) ) ) { cursorOrientation |= vStyle ; } int hStyle = ( style ) & ( ( SWT . LEFT ) | ( SWT . RIGHT ) ) ; if ( ( hStyle == ( SWT . LEFT ) ) || ( hStyle == ( SWT . RIGHT ) ) ) { cursorOrientation |= hStyle ; } handle = OS . gcnew_Window ( ) ; if ( ( handle ) == 0 ) error ( ERROR_NO_HANDLES ) ; canvasHandle = OS . gcnew_Canvas ( ) ; if ( ( canvasHandle ) == 0 ) error ( ERROR_NO_HANDLES ) ; OS . ContentControl_Content ( handle , canvasHandle ) ; if ( ( parent ) != null ) { Rectangle bounds = parent . getBounds ( ) ; OS . Window_Left ( handle , bounds . x ) ; OS . Window_Top ( handle , bounds . y ) ; OS . FrameworkElement_Width ( handle , bounds . width ) ; OS . FrameworkElement_Height ( handle , bounds . height ) ; } else { OS . Window_Left ( handle , 0 ) ; OS . Window_Top ( handle , 0 ) ; OS . FrameworkElement_Width ( handle , OS . SystemParameters_PrimaryScreenWidth ( ) ) ; OS . FrameworkElement_Height ( handle , OS . SystemParameters_PrimaryScreenHeight ( ) ) ; } OS . Window_ShowInTaskbar ( handle , false ) ; OS . Window_AllowsTransparency ( handle , true ) ; OS . Window_ResizeMode ( handle , ResizeMode_NoResize ) ; OS . Window_WindowStyle ( handle , WindowStyle_None ) ; if ( ( clientCursor ) != 0 ) OS . FrameworkElement_Cursor ( handle , clientCursor ) ; int color = OS . Colors_Black ; int brush = OS . gcnew_SolidColorBrush ( color ) ; OS . Brush_Opacity ( brush , 0.01 ) ; OS . Control_Background ( handle , brush ) ; OS . GCHandle_Free ( brush ) ; int children = OS . Panel_Children ( canvasHandle ) ; int stroke = ( stippled ) ? 3 : 1 ; brush = ( stippled ) ? OS . Brushes_Navy ( ) : OS . Brushes_Black ( ) ; rectShapes = new int [ rectangles . length ] ; for ( int i = 0 ; i < ( rectShapes . length ) ; i ++ ) { int child = rectShapes [ i ] = OS . gcnew_Rectangle ( ) ; OS . UIElementCollection_Add ( children , child ) ; OS . Shape_StrokeThickness ( child , stroke ) ; OS . Shape_Stroke ( child , brush ) ; } OS . GCHandle_Free ( brush ) ; drawRectangles ( ) ; jniRef = OS . NewGlobalRef ( this ) ; if ( ( jniRef ) == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; int handler = OS . gcnew_KeyEventHandler ( jniRef , "HandleKeyDown" ) ; OS . UIElement_KeyDown ( handle , handler ) ; OS . GCHandle_Free ( handler ) ; handler = OS . gcnew_KeyEventHandler ( jniRef , "HandleKeyUp" ) ; OS . UIElement_KeyUp ( handle , handler ) ; OS . GCHandle_Free ( handler ) ; handler = OS . gcnew_MouseEventHandler ( jniRef , "HandleMouseMove" ) ; OS . UIElement_MouseMove ( handle , handler ) ; OS . GCHandle_Free ( handler ) ; handler = OS . gcnew_MouseButtonEventHandler ( jniRef , "HandleMouseUp" ) ; OS . UIElement_MouseUp ( handle , handler ) ; OS . GCHandle_Free ( handler ) ; handler = OS . gcnew_MouseButtonEventHandler ( jniRef , "HandleMouseDown" ) ; OS . UIElement_MouseDown ( handle , handler ) ; OS . GCHandle_Free ( handler ) ; OS . UIElement_Focus ( handle ) ; OS . Window_Show ( handle ) ; boolean mouseDown = ( OS . Mouse_LeftButton ( ) ) == ( OS . MouseButtonState_Pressed ) ; Point cursorPos ; if ( mouseDown ) { int point = OS . Mouse_GetPosition ( handle ) ; cursorPos = new Point ( ( ( int ) ( OS . Point_X ( point ) ) ) , ( ( int ) ( OS . Point_Y ( point ) ) ) ) ; OS . GCHandle_Free ( point ) ; } else { if ( ( ( style ) & ( SWT . RESIZE ) ) != 0 ) { cursorPos = adjustResizeCursor ( ) ; } else { cursorPos = adjustMoveCursor ( ) ; } } oldX = cursorPos . x ; oldY = cursorPos . y ; Display display = Display . getCurrent ( ) ; while ( ( tracking ) && ( ! ( cancelled ) ) ) { if ( ! ( display . readAndDispatch ( ) ) ) { <START_BUG> display . readAndDispatch ( ) ; <END_BUG> } } for ( int i = 0 ; i < ( rectShapes . length ) ; i ++ ) { int child = rectShapes [ i ] ; OS . UIElementCollection_Remove ( children , child ) ; OS . GCHandle_Free ( child ) ; } OS . GCHandle_Free ( children ) ; if ( ( resizeCursor ) != 0 ) { OS . GCHandle_Free ( resizeCursor ) ; resizeCursor = 0 ; } OS . Window_Close ( handle ) ; OS . GCHandle_Free ( canvasHandle ) ; OS . GCHandle_Free ( handle ) ; jniRef = 0 ; OS . DeleteGlobalRef ( jniRef ) ; handle = 0 ; rectShapes = null ; tracking = false ; return ! ( cancelled ) ; } public void removeControlListener ( ControlListener listener ) { } public void removeKeyListener ( KeyListener listener ) { } void resizeRectangles ( int xChange , int yChange ) { } public void setCursor ( Cursor newCursor ) { } public void setRectangles ( Rectangle [ ] rectangles ) { } public void setStippled ( boolean stippled ) { } }

Fix:
display . sleep ( ) ;