src/java.desktop/share/classes/java/awt/Component.java

Print this page

        

*** 196,206 **** * behavior. The peer is set when the <code>Component</code> is * added to a container that also is a peer. * @see #addNotify * @see #removeNotify */ ! transient ComponentPeer peer; /** * The parent of the object. It may be <code>null</code> * for top-level components. * @see #getParent --- 196,206 ---- * behavior. The peer is set when the <code>Component</code> is * added to a container that also is a peer. * @see #addNotify * @see #removeNotify */ ! transient volatile ComponentPeer peer; /** * The parent of the object. It may be <code>null</code> * for top-level components. * @see #getParent
*** 922,933 **** return comp.peer != null; } public Cursor getCursor(Component comp) { return comp.getCursor_NoClientCode(); } ! public ComponentPeer getPeer(Component comp) { ! return comp.peer; } public void setPeer(Component comp, ComponentPeer peer) { comp.peer = peer; } public boolean isLightweight(Component comp) { --- 922,934 ---- return comp.peer != null; } public Cursor getCursor(Component comp) { return comp.getCursor_NoClientCode(); } ! @SuppressWarnings("unchecked") ! public <T extends ComponentPeer> T getPeer(Component comp) { ! return (T) comp.peer; } public void setPeer(Component comp, ComponentPeer peer) { comp.peer = peer; } public boolean isLightweight(Component comp) {
*** 1067,1087 **** Container getContainer() { return getParent_NoClientCode(); } /** - * @deprecated As of JDK version 1.1, - * programs should not directly manipulate peers; - * replaced by <code>boolean isDisplayable()</code>. - * @return the peer for this component - */ - @Deprecated - public ComponentPeer getPeer() { - return peer; - } - - /** * Associate a <code>DropTarget</code> with this component. * The <code>Component</code> will receive drops only if it * is enabled. * * @see #isEnabled --- 1068,1077 ----
*** 1177,1187 **** return false; } graphicsConfig = gc; ! ComponentPeer peer = getPeer(); if (peer != null) { return peer.updateGraphicsData(gc); } return false; } --- 1167,1177 ---- return false; } graphicsConfig = gc; ! ComponentPeer peer = this.peer; if (peer != null) { return peer.updateGraphicsData(gc); } return false; }
*** 1279,1289 **** * @see Container#remove(Component) * @see Window#dispose * @since 1.2 */ public boolean isDisplayable() { ! return getPeer() != null; } /** * Determines whether this component should be visible when its * parent is visible. Components are --- 1269,1279 ---- * @see Container#remove(Component) * @see Window#dispose * @since 1.2 */ public boolean isDisplayable() { ! return peer != null; } /** * Determines whether this component should be visible when its * parent is visible. Components are
*** 2580,2590 **** * @return true if this component is completely opaque * @see #isLightweight * @since 1.2 */ public boolean isOpaque() { ! if (getPeer() == null) { return false; } else { return !isLightweight(); } --- 2570,2580 ---- * @return true if this component is completely opaque * @see #isLightweight * @since 1.2 */ public boolean isOpaque() { ! if (peer == null) { return false; } else { return !isLightweight(); }
*** 2606,2616 **** * it has a native peer or no peer * @see #isDisplayable * @since 1.2 */ public boolean isLightweight() { ! return getPeer() instanceof LightweightPeer; } /** * Sets the preferred size of this component to a constant --- 2596,2606 ---- * it has a native peer or no peer * @see #isDisplayable * @since 1.2 */ public boolean isLightweight() { ! return peer instanceof LightweightPeer; } /** * Sets the preferred size of this component to a constant
*** 3124,3134 **** * {@link Font Font} class. * @param font the font for which font metrics is to be * obtained * @return the font metrics for <code>font</code> * @see #getFont - * @see #getPeer * @see java.awt.peer.ComponentPeer#getFontMetrics(Font) * @see Toolkit#getFontMetrics(Font) * @since 1.0 */ public FontMetrics getFontMetrics(Font font) { --- 3114,3123 ----
*** 3184,3194 **** if (peer instanceof LightweightPeer) { Container nativeContainer = getNativeContainer(); if (nativeContainer == null) return; ! ComponentPeer cPeer = nativeContainer.getPeer(); if (cPeer != null) { cPeer.updateCursorImmediately(); } } else if (peer != null) { --- 3173,3183 ---- if (peer instanceof LightweightPeer) { Container nativeContainer = getNativeContainer(); if (nativeContainer == null) return; ! ComponentPeer cPeer = nativeContainer.peer; if (cPeer != null) { cPeer.updateCursorImmediately(); } } else if (peer != null) {
*** 5014,5024 **** // processes event Component source = (Component)e.getSource(); if (source != null) { Container target = source.getNativeContainer(); if (target != null) { ! tpeer = target.getPeer(); } } } if (tpeer != null) { tpeer.handleEvent(e); --- 5003,5013 ---- // processes event Component source = (Component)e.getSource(); if (source != null) { Container target = source.getNativeContainer(); if (target != null) { ! tpeer = target.peer; } } } if (tpeer != null) { tpeer.handleEvent(e);
*** 9845,9855 **** } return; } if (!isLightweight()) { ! ComponentPeer peer = getPeer(); if (peer != null) { // The Region class has some optimizations. That's why // we should manually check whether it's empty and // substitute the object ourselves. Otherwise we end up // with some incorrect Region object with loX being --- 9834,9844 ---- } return; } if (!isLightweight()) { ! ComponentPeer peer = this.peer; if (peer != null) { // The Region class has some optimizations. That's why // we should manually check whether it's empty and // substitute the object ourselves. Otherwise we end up // with some incorrect Region object with loX being
*** 9969,9979 **** while (cont != null) { for (int i = indexAbove; i > -1; i--) { Component comp = cont.getComponent(i); if (comp != null && comp.isDisplayable() && !comp.isLightweight()) { ! return comp.getPeer(); } } // traversing the hierarchy up to the closest HW container; // further traversing may return a component that is not actually // a native sibling of this component and this kind of z-order --- 9958,9968 ---- while (cont != null) { for (int i = indexAbove; i > -1; i--) { Component comp = cont.getComponent(i); if (comp != null && comp.isDisplayable() && !comp.isLightweight()) { ! return comp.peer; } } // traversing the hierarchy up to the closest HW container; // further traversing may return a component that is not actually // a native sibling of this component and this kind of z-order