src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page




1210         switch (e.getID()) {
1211             case FocusEvent.FOCUS_GAINED:
1212             case FocusEvent.FOCUS_LOST:
1213                 handleJavaFocusEvent((FocusEvent) e);
1214                 break;
1215             case PaintEvent.PAINT:
1216                 // Got a native paint event
1217 //                paintPending = false;
1218                 // fall through to the next statement
1219             case PaintEvent.UPDATE:
1220                 handleJavaPaintEvent();
1221                 break;
1222             case MouseEvent.MOUSE_PRESSED:
1223                 handleJavaMouseEvent((MouseEvent)e);
1224         }
1225 
1226         sendEventToDelegate(e);
1227     }
1228 
1229     protected void sendEventToDelegate(final AWTEvent e) {
1230         synchronized (getDelegateLock()) {
1231             if (getDelegate() == null || !isShowing() || !isEnabled()) {
1232                 return;
1233             }

1234             AWTEvent delegateEvent = createDelegateEvent(e);
1235             if (delegateEvent != null) {
1236                 AWTAccessor.getComponentAccessor()
1237                         .processEvent((Component) delegateEvent.getSource(),
1238                                 delegateEvent);
1239                 if (delegateEvent instanceof KeyEvent) {
1240                     KeyEvent ke = (KeyEvent) delegateEvent;
1241                     SwingUtilities.processKeyBindings(ke);
1242                 }
1243             }
1244         }
1245     }
1246 
1247     protected AWTEvent createDelegateEvent(AWTEvent e) {





1248         AWTEvent delegateEvent = null;
1249         if (e instanceof MouseWheelEvent) {
1250             MouseWheelEvent me = (MouseWheelEvent) e;
1251             delegateEvent = new MouseWheelEvent(
1252                     delegate, me.getID(), me.getWhen(),
1253                     me.getModifiers(),
1254                     me.getX(), me.getY(),
1255                     me.getClickCount(),
1256                     me.isPopupTrigger(),
1257                     me.getScrollType(),
1258                     me.getScrollAmount(),
1259                     me.getWheelRotation());
1260         } else if (e instanceof MouseEvent) {
1261             MouseEvent me = (MouseEvent) e;
1262 
1263             Component eventTarget = SwingUtilities.getDeepestComponentAt(delegate, me.getX(), me.getY());
1264 
1265             if (me.getID() == MouseEvent.MOUSE_DRAGGED) {
1266                 if (delegateDropTarget == null) {
1267                     delegateDropTarget = eventTarget;




1210         switch (e.getID()) {
1211             case FocusEvent.FOCUS_GAINED:
1212             case FocusEvent.FOCUS_LOST:
1213                 handleJavaFocusEvent((FocusEvent) e);
1214                 break;
1215             case PaintEvent.PAINT:
1216                 // Got a native paint event
1217 //                paintPending = false;
1218                 // fall through to the next statement
1219             case PaintEvent.UPDATE:
1220                 handleJavaPaintEvent();
1221                 break;
1222             case MouseEvent.MOUSE_PRESSED:
1223                 handleJavaMouseEvent((MouseEvent)e);
1224         }
1225 
1226         sendEventToDelegate(e);
1227     }
1228 
1229     protected void sendEventToDelegate(final AWTEvent e) {

1230         if (getDelegate() == null || !isShowing() || !isEnabled()) {
1231             return;
1232         }
1233         synchronized (getDelegateLock()) {
1234             AWTEvent delegateEvent = createDelegateEvent(e);
1235             if (delegateEvent != null) {
1236                 AWTAccessor.getComponentAccessor()
1237                         .processEvent((Component) delegateEvent.getSource(),
1238                                 delegateEvent);
1239                 if (delegateEvent instanceof KeyEvent) {
1240                     KeyEvent ke = (KeyEvent) delegateEvent;
1241                     SwingUtilities.processKeyBindings(ke);
1242                 }
1243             }
1244         }
1245     }
1246 
1247     /**
1248      * Changes the target of the AWTEvent from awt component to appropriate
1249      * swing delegate.
1250      */
1251     private AWTEvent createDelegateEvent(final AWTEvent e) {
1252         // TODO modifiers should be changed to getModifiers()|getModifiersEx()?
1253         AWTEvent delegateEvent = null;
1254         if (e instanceof MouseWheelEvent) {
1255             MouseWheelEvent me = (MouseWheelEvent) e;
1256             delegateEvent = new MouseWheelEvent(
1257                     delegate, me.getID(), me.getWhen(),
1258                     me.getModifiers(),
1259                     me.getX(), me.getY(),
1260                     me.getClickCount(),
1261                     me.isPopupTrigger(),
1262                     me.getScrollType(),
1263                     me.getScrollAmount(),
1264                     me.getWheelRotation());
1265         } else if (e instanceof MouseEvent) {
1266             MouseEvent me = (MouseEvent) e;
1267 
1268             Component eventTarget = SwingUtilities.getDeepestComponentAt(delegate, me.getX(), me.getY());
1269 
1270             if (me.getID() == MouseEvent.MOUSE_DRAGGED) {
1271                 if (delegateDropTarget == null) {
1272                     delegateDropTarget = eventTarget;