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

Print this page




1182 
1183         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
1184             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
1185         } else {
1186             // Anyway request focus to the toplevel.
1187             getWindowPeerOrSelf().requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
1188         }
1189     }
1190 
1191     /**
1192      * Handler for FocusEvents.
1193      */
1194     protected void handleJavaFocusEvent(FocusEvent e) {
1195         // Note that the peer receives all the FocusEvents from
1196         // its lightweight children as well
1197         LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
1198                 setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
1199     }
1200 
1201     /**
1202      * Peers with null delegates should clear background before paint.
1203      *
1204      * @return false on components that DO NOT require a clearRect() before
1205      *         painting.
1206      */
1207     protected final boolean shouldClearRectBeforePaint() {
1208         // By default, just fill the entire bounds with a bg color
1209         // TODO: sun.awt.noerasebackground
1210         return getDelegate() == null;
1211     }
1212 
1213     /**
1214      * Handler for PAINT and UPDATE PaintEvents.
1215      */
1216     private void handleJavaPaintEvent() {
1217         // Skip all painting while layouting and all UPDATEs
1218         // while waiting for native paint
1219 //        if (!isLayouting && !paintPending) {
1220         if (!isLayouting()) {
1221             targetPaintArea.paint(getTarget(), shouldClearRectBeforePaint());
1222         }
1223     }
1224 
1225     // ---- UTILITY METHODS ---- //
1226 
1227     /**
1228      * Finds a top-most visible component for the given point. The location is
1229      * specified relative to the peer's parent.
1230      */




1182 
1183         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
1184             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
1185         } else {
1186             // Anyway request focus to the toplevel.
1187             getWindowPeerOrSelf().requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
1188         }
1189     }
1190 
1191     /**
1192      * Handler for FocusEvents.
1193      */
1194     protected void handleJavaFocusEvent(FocusEvent e) {
1195         // Note that the peer receives all the FocusEvents from
1196         // its lightweight children as well
1197         LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
1198                 setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
1199     }
1200 
1201     /**
1202      * All peers should clear background before paint.
1203      *
1204      * @return false on components that DO NOT require a clearRect() before
1205      *         painting.
1206      */
1207     protected final boolean shouldClearRectBeforePaint() {

1208         // TODO: sun.awt.noerasebackground
1209         return true;
1210     }
1211 
1212     /**
1213      * Handler for PAINT and UPDATE PaintEvents.
1214      */
1215     private void handleJavaPaintEvent() {
1216         // Skip all painting while layouting and all UPDATEs
1217         // while waiting for native paint
1218 //        if (!isLayouting && !paintPending) {
1219         if (!isLayouting()) {
1220             targetPaintArea.paint(getTarget(), shouldClearRectBeforePaint());
1221         }
1222     }
1223 
1224     // ---- UTILITY METHODS ---- //
1225 
1226     /**
1227      * Finds a top-most visible component for the given point. The location is
1228      * specified relative to the peer's parent.
1229      */