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

Print this page




1234                 eventTarget = delegate;
1235             }
1236             delegateEvent = SwingUtilities.convertMouseEvent(getTarget(), me, eventTarget);
1237         } else if (e instanceof KeyEvent) {
1238             KeyEvent ke = (KeyEvent) e;
1239             delegateEvent = new KeyEvent(getDelegateFocusOwner(), ke.getID(), ke.getWhen(),
1240                     ke.getModifiers(), ke.getKeyCode(), ke.getKeyChar(), ke.getKeyLocation());
1241         } else if (e instanceof FocusEvent) {
1242             FocusEvent fe = (FocusEvent) e;
1243             delegateEvent = new FocusEvent(getDelegateFocusOwner(), fe.getID(), fe.isTemporary());
1244         }
1245         return delegateEvent;
1246     }
1247 
1248     protected void handleJavaMouseEvent(MouseEvent e) {
1249         Component target = getTarget();
1250         assert (e.getSource() == target);
1251 
1252         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
1253             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
1254         } else {
1255             // Anyway request focus to the toplevel.
1256             getWindowPeerOrSelf().requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
1257         }
1258     }
1259 
1260     /**
1261      * Handler for FocusEvents.
1262      */
1263     protected void handleJavaFocusEvent(FocusEvent e) {
1264         // Note that the peer receives all the FocusEvents from
1265         // its lightweight children as well
1266         LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
1267                 setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
1268     }
1269 
1270     /**
1271      * All peers should clear background before paint.
1272      *
1273      * @return false on components that DO NOT require a clearRect() before
1274      *         painting.
1275      */
1276     protected final boolean shouldClearRectBeforePaint() {




1234                 eventTarget = delegate;
1235             }
1236             delegateEvent = SwingUtilities.convertMouseEvent(getTarget(), me, eventTarget);
1237         } else if (e instanceof KeyEvent) {
1238             KeyEvent ke = (KeyEvent) e;
1239             delegateEvent = new KeyEvent(getDelegateFocusOwner(), ke.getID(), ke.getWhen(),
1240                     ke.getModifiers(), ke.getKeyCode(), ke.getKeyChar(), ke.getKeyLocation());
1241         } else if (e instanceof FocusEvent) {
1242             FocusEvent fe = (FocusEvent) e;
1243             delegateEvent = new FocusEvent(getDelegateFocusOwner(), fe.getID(), fe.isTemporary());
1244         }
1245         return delegateEvent;
1246     }
1247 
1248     protected void handleJavaMouseEvent(MouseEvent e) {
1249         Component target = getTarget();
1250         assert (e.getSource() == target);
1251         
1252         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
1253             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);



1254         }
1255     }
1256 
1257     /**
1258      * Handler for FocusEvents.
1259      */
1260     protected void handleJavaFocusEvent(FocusEvent e) {
1261         // Note that the peer receives all the FocusEvents from
1262         // its lightweight children as well
1263         LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
1264                 setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
1265     }
1266 
1267     /**
1268      * All peers should clear background before paint.
1269      *
1270      * @return false on components that DO NOT require a clearRect() before
1271      *         painting.
1272      */
1273     protected final boolean shouldClearRectBeforePaint() {