Search in sources :

Example 31 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Component method updateGraphicsData.

boolean updateGraphicsData(GraphicsConfiguration gc) {
    checkTreeLock();
    if (graphicsConfig == gc) {
        return false;
    }
    AffineTransform tx = graphicsConfig != null ? graphicsConfig.getDefaultTransform() : new AffineTransform();
    AffineTransform newTx = gc != null ? gc.getDefaultTransform() : new AffineTransform();
    graphicsConfig = gc;
    if (tx.getScaleX() != newTx.getScaleX() || tx.getScaleY() != newTx.getScaleY()) {
        firePropertyChange("graphicsContextScaleTransform", tx, newTx);
    }
    ComponentPeer peer = getPeer();
    if (peer != null) {
        return peer.updateGraphicsData(gc);
    }
    return false;
}
Also used : AffineTransform(java.awt.geom.AffineTransform) ComponentPeer(java.awt.peer.ComponentPeer)

Example 32 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Component method isRequestFocusAccepted.

private boolean isRequestFocusAccepted(boolean temporary, boolean focusedWindowChangeAllowed, CausedFocusEvent.Cause cause) {
    if (!isFocusable() || !isVisible()) {
        if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
            focusLog.finest("Not focusable or not visible");
        }
        return false;
    }
    ComponentPeer peer = this.peer;
    if (peer == null) {
        if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
            focusLog.finest("peer is null");
        }
        return false;
    }
    Window window = getContainingWindow();
    if (window == null || !window.isFocusableWindow()) {
        if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
            focusLog.finest("Component doesn't have toplevel");
        }
        return false;
    }
    // We have passed all regular checks for focus request,
    // now let's call RequestFocusController and see what it says.
    Component focusOwner = KeyboardFocusManager.getMostRecentFocusOwner(window);
    if (focusOwner == null) {
        // sometimes most recent focus owner may be null, but focus owner is not
        // e.g. we reset most recent focus owner if user removes focus owner
        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (focusOwner != null && focusOwner.getContainingWindow() != window) {
            focusOwner = null;
        }
    }
    if (focusOwner == this || focusOwner == null) {
        // transfers from when these components are equal.
        if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
            focusLog.finest("focus owner is null or this");
        }
        return true;
    }
    if (CausedFocusEvent.Cause.ACTIVATION == cause) {
        // been already approved.
        if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
            focusLog.finest("cause is activation");
        }
        return true;
    }
    boolean ret = Component.requestFocusController.acceptRequestFocus(focusOwner, this, temporary, focusedWindowChangeAllowed, cause);
    if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
        focusLog.finest("RequestFocusController returns {0}", ret);
    }
    return ret;
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Example 33 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Component method validate.

/**
     * Validates this component.
     * <p>
     * The meaning of the term <i>validating</i> is defined by the ancestors of
     * this class. See {@link Container#validate} for more details.
     *
     * @see       #invalidate
     * @see       #doLayout()
     * @see       LayoutManager
     * @see       Container#validate
     * @since     JDK1.0
     */
public void validate() {
    synchronized (getTreeLock()) {
        ComponentPeer peer = this.peer;
        boolean wasValid = isValid();
        if (!wasValid && peer != null) {
            Font newfont = getFont();
            Font oldfont = peerFont;
            if (newfont != oldfont && (oldfont == null || !oldfont.equals(newfont))) {
                peer.setFont(newfont);
                peerFont = newfont;
            }
            peer.layout();
        }
        valid = true;
        if (!wasValid) {
            mixOnValidating();
        }
    }
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Example 34 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Component method addNotify.

/**
     * Makes this <code>Component</code> displayable by connecting it to a
     * native screen resource.
     * This method is called internally by the toolkit and should
     * not be called directly by programs.
     * <p>
     * This method changes layout-related information, and therefore,
     * invalidates the component hierarchy.
     *
     * @see       #isDisplayable
     * @see       #removeNotify
     * @see #invalidate
     * @since JDK1.0
     */
public void addNotify() {
    synchronized (getTreeLock()) {
        ComponentPeer peer = this.peer;
        if (peer == null || peer instanceof LightweightPeer) {
            if (peer == null) {
                // Update both the Component's peer variable and the local
                // variable we use for thread safety.
                this.peer = peer = getToolkit().createComponent(this);
            }
            // be enabled.
            if (parent != null) {
                long mask = 0;
                if ((mouseListener != null) || ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0)) {
                    mask |= AWTEvent.MOUSE_EVENT_MASK;
                }
                if ((mouseMotionListener != null) || ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0)) {
                    mask |= AWTEvent.MOUSE_MOTION_EVENT_MASK;
                }
                if ((mouseWheelListener != null) || ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0)) {
                    mask |= AWTEvent.MOUSE_WHEEL_EVENT_MASK;
                }
                if (focusListener != null || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0) {
                    mask |= AWTEvent.FOCUS_EVENT_MASK;
                }
                if (keyListener != null || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0) {
                    mask |= AWTEvent.KEY_EVENT_MASK;
                }
                if (mask != 0) {
                    parent.proxyEnableEvents(mask);
                }
            }
        } else {
            // It's native. If the parent is lightweight it will need some
            // help.
            Container parent = getContainer();
            if (parent != null && parent.isLightweight()) {
                relocateComponent();
                if (!parent.isRecursivelyVisibleUpToHeavyweightContainer()) {
                    peer.setVisible(false);
                }
            }
        }
        invalidate();
        int npopups = (popups != null ? popups.size() : 0);
        for (int i = 0; i < npopups; i++) {
            PopupMenu popup = popups.elementAt(i);
            popup.addNotify();
        }
        if (dropTarget != null)
            dropTarget.addNotify(peer);
        peerFont = getFont();
        if (getContainer() != null && !isAddNotifyComplete) {
            getContainer().increaseComponentCount(this);
        }
        // Update stacking order
        updateZOrder();
        if (!isAddNotifyComplete) {
            mixOnShowing();
        }
        isAddNotifyComplete = true;
        if (hierarchyListener != null || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 || Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK)) {
            HierarchyEvent e = new HierarchyEvent(this, HierarchyEvent.HIERARCHY_CHANGED, this, parent, HierarchyEvent.DISPLAYABILITY_CHANGED | ((isRecursivelyVisible()) ? HierarchyEvent.SHOWING_CHANGED : 0));
            dispatchEvent(e);
        }
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ComponentPeer(java.awt.peer.ComponentPeer)

Example 35 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Component method applyCompoundShape.

/**
     * Applies the shape to the component
     * @param shape Shape to be applied to the component
     */
void applyCompoundShape(Region shape) {
    checkTreeLock();
    if (!areBoundsValid()) {
        if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
            mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
        }
        return;
    }
    if (!isLightweight()) {
        ComponentPeer peer = getPeer();
        if (peer != null) {
            // greater than the hiX for instance.
            if (shape.isEmpty()) {
                shape = Region.EMPTY_REGION;
            }
            // (or has no shape at all).
            if (shape.equals(getNormalShape())) {
                if (this.compoundShape == null) {
                    return;
                }
                this.compoundShape = null;
                peer.applyShape(null);
            } else {
                if (shape.equals(getAppliedShape())) {
                    return;
                }
                this.compoundShape = shape;
                Point compAbsolute = getLocationOnWindow();
                if (mixingLog.isLoggable(PlatformLogger.Level.FINER)) {
                    mixingLog.fine("this = " + this + "; compAbsolute=" + compAbsolute + "; shape=" + shape);
                }
                peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y));
            }
        }
    }
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Aggregations

ComponentPeer (java.awt.peer.ComponentPeer)41 LightweightPeer (java.awt.peer.LightweightPeer)10 Component (java.awt.Component)5 Container (java.awt.Container)3 InputContext (java.awt.im.InputContext)2 ConstrainableGraphics (sun.awt.ConstrainableGraphics)2 Pointer (com.sun.jna.Pointer)1 BufferCapabilities (java.awt.BufferCapabilities)1 HeadlessException (java.awt.HeadlessException)1 AffineTransform (java.awt.geom.AffineTransform)1 ColorModel (java.awt.image.ColorModel)1 FramePeer (java.awt.peer.FramePeer)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 TooManyListenersException (java.util.TooManyListenersException)1 AppContext (sun.awt.AppContext)1 CausedFocusEvent (sun.awt.CausedFocusEvent)1 SunToolkit (sun.awt.SunToolkit)1 WindowClosingListener (sun.awt.WindowClosingListener)1 SunDropTargetEvent (sun.awt.dnd.SunDropTargetEvent)1