Search in sources :

Example 1 with LightweightPeer

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

the class Component method getGraphics_NoClientCode.

final Graphics getGraphics_NoClientCode() {
    ComponentPeer peer = this.peer;
    if (peer instanceof LightweightPeer) {
        // This is for a lightweight component, need to
        // translate coordinate spaces and clip relative
        // to the parent.
        Container parent = this.parent;
        if (parent == null)
            return null;
        Graphics g = parent.getGraphics_NoClientCode();
        if (g == null)
            return null;
        if (g instanceof ConstrainableGraphics) {
            ((ConstrainableGraphics) g).constrain(x, y, width, height);
        } else {
            g.translate(x, y);
            g.setClip(0, 0, width, height);
        }
        g.setFont(getFont_NoClientCode());
        return g;
    } else {
        return (peer != null) ? peer.getGraphics() : null;
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ComponentPeer(java.awt.peer.ComponentPeer)

Example 2 with LightweightPeer

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

the class Component method show.

/**
     * @deprecated As of JDK version 1.1,
     * replaced by <code>setVisible(boolean)</code>.
     */
@Deprecated
public void show() {
    if (!visible) {
        synchronized (getTreeLock()) {
            visible = true;
            mixOnShowing();
            ComponentPeer peer = this.peer;
            if (peer != null) {
                peer.setVisible(true);
                createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, this, parent, HierarchyEvent.SHOWING_CHANGED, Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
                if (peer instanceof LightweightPeer) {
                    repaint();
                }
                updateCursorImmediately();
            }
            if (componentListener != null || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 || Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
                ComponentEvent e = new ComponentEvent(this, ComponentEvent.COMPONENT_SHOWN);
                Toolkit.getEventQueue().postEvent(e);
            }
        }
        Container parent = this.parent;
        if (parent != null) {
            parent.invalidate();
        }
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ComponentPeer(java.awt.peer.ComponentPeer)

Example 3 with LightweightPeer

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

the class Component method hide.

/**
     * @deprecated As of JDK version 1.1,
     * replaced by <code>setVisible(boolean)</code>.
     */
@Deprecated
public void hide() {
    isPacked = false;
    if (visible) {
        clearCurrentFocusCycleRootOnHide();
        clearMostRecentFocusOwnerOnHide();
        synchronized (getTreeLock()) {
            visible = false;
            mixOnHiding(isLightweight());
            if (containsFocus() && KeyboardFocusManager.isAutoFocusTransferEnabled()) {
                transferFocus(true);
            }
            ComponentPeer peer = this.peer;
            if (peer != null) {
                peer.setVisible(false);
                createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, this, parent, HierarchyEvent.SHOWING_CHANGED, Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
                if (peer instanceof LightweightPeer) {
                    repaint();
                }
                updateCursorImmediately();
            }
            if (componentListener != null || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 || Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
                ComponentEvent e = new ComponentEvent(this, ComponentEvent.COMPONENT_HIDDEN);
                Toolkit.getEventQueue().postEvent(e);
            }
        }
        Container parent = this.parent;
        if (parent != null) {
            parent.invalidate();
        }
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ComponentPeer(java.awt.peer.ComponentPeer)

Example 4 with LightweightPeer

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

the class BasicSplitPaneUI method startDragging.

/**
     * Should be messaged before the dragging session starts, resets
     * lastDragLocation and dividerSize.
     */
protected void startDragging() {
    Component leftC = splitPane.getLeftComponent();
    Component rightC = splitPane.getRightComponent();
    ComponentPeer cPeer;
    beginDragDividerLocation = getDividerLocation(splitPane);
    draggingHW = false;
    if (leftC != null && (cPeer = leftC.getPeer()) != null && !(cPeer instanceof LightweightPeer)) {
        draggingHW = true;
    } else if (rightC != null && (cPeer = rightC.getPeer()) != null && !(cPeer instanceof LightweightPeer)) {
        draggingHW = true;
    }
    if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
        setLastDragLocation(divider.getBounds().x);
        dividerSize = divider.getSize().width;
        if (!isContinuousLayout() && draggingHW) {
            nonContinuousLayoutDivider.setBounds(getLastDragLocation(), 0, dividerSize, splitPane.getHeight());
            addHeavyweightDivider();
        }
    } else {
        setLastDragLocation(divider.getBounds().y);
        dividerSize = divider.getSize().height;
        if (!isContinuousLayout() && draggingHW) {
            nonContinuousLayoutDivider.setBounds(0, getLastDragLocation(), splitPane.getWidth(), dividerSize);
            addHeavyweightDivider();
        }
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ComponentPeer(java.awt.peer.ComponentPeer)

Example 5 with LightweightPeer

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

the class Component method updateCursorImmediately.

/**
     * Updates the cursor.  May not be invoked from the native
     * message pump.
     */
final void updateCursorImmediately() {
    if (peer instanceof LightweightPeer) {
        Container nativeContainer = getNativeContainer();
        if (nativeContainer == null)
            return;
        ComponentPeer cPeer = nativeContainer.getPeer();
        if (cPeer != null) {
            cPeer.updateCursorImmediately();
        }
    } else if (peer != null) {
        peer.updateCursorImmediately();
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ComponentPeer(java.awt.peer.ComponentPeer)

Aggregations

LightweightPeer (java.awt.peer.LightweightPeer)11 ComponentPeer (java.awt.peer.ComponentPeer)10 ConstrainableGraphics (sun.awt.ConstrainableGraphics)2 Component (java.awt.Component)1 DropTargetPeer (java.awt.dnd.peer.DropTargetPeer)1 InputContext (java.awt.im.InputContext)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 CompositionArea (sun.awt.im.CompositionArea)1