java.awt.peer.LightweightPeer Java Examples

The following examples show how to use java.awt.peer.LightweightPeer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Container.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This is called by lightweight components that want the containing
 * windowed parent to enable some kind of events on their behalf.
 * This is needed for events that are normally only dispatched to
 * windows to be accepted so that they can be forwarded downward to
 * the lightweight component that has enabled them.
 */
void proxyEnableEvents(long events) {
    if (peer instanceof LightweightPeer) {
        // this container is lightweight.... continue sending it
        // upward.
        if (parent != null) {
            parent.proxyEnableEvents(events);
        }
    } else {
        // This is a native container, so it needs to host
        // one of it's children.  If this function is called before
        // a peer has been created we don't yet have a dispatcher
        // because it has not yet been determined if this instance
        // is lightweight.
        if (dispatcher != null) {
            dispatcher.enableEvents(events);
        }
    }
}
 
Example #2
Source File: DropTarget.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 */
public void addNotify() {
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    ComponentPeer peer = acc.getPeer(component);
    if (peer == null || peer == componentPeer) {
        return;
    }

    componentPeer = peer;


    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = acc.getPeer(c);
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = (DropTargetPeer) peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example #3
Source File: Container.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #4
Source File: DropTarget.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 * <P>
 * @param peer The Peer of the Component we are associated with!
 *
 */

public void addNotify(ComponentPeer peer) {
    if (peer == componentPeer) return;

    componentPeer = peer;

    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = c.getPeer();
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example #5
Source File: DropTarget.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 * <P>
 * @param peer The Peer of the Component we are associated with!
 *
 */

public void addNotify(ComponentPeer peer) {
    if (peer == componentPeer) return;

    componentPeer = peer;

    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = c.getPeer();
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example #6
Source File: Container.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #7
Source File: Container.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #8
Source File: Container.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #9
Source File: DropTarget.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 * <P>
 * @param peer The Peer of the Component we are associated with!
 *
 */

public void addNotify(ComponentPeer peer) {
    if (peer == componentPeer) return;

    componentPeer = peer;

    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = c.getPeer();
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example #10
Source File: Container.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #11
Source File: Container.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * This is called by lightweight components that want the containing
 * windowed parent to enable some kind of events on their behalf.
 * This is needed for events that are normally only dispatched to
 * windows to be accepted so that they can be forwarded downward to
 * the lightweight component that has enabled them.
 */
void proxyEnableEvents(long events) {
    if (peer instanceof LightweightPeer) {
        // this container is lightweight.... continue sending it
        // upward.
        if (parent != null) {
            parent.proxyEnableEvents(events);
        }
    } else {
        // This is a native container, so it needs to host
        // one of it's children.  If this function is called before
        // a peer has been created we don't yet have a dispatcher
        // because it has not yet been determined if this instance
        // is lightweight.
        if (dispatcher != null) {
            dispatcher.enableEvents(events);
        }
    }
}
 
Example #12
Source File: Container.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This is called by lightweight components that want the containing
 * windowed parent to enable some kind of events on their behalf.
 * This is needed for events that are normally only dispatched to
 * windows to be accepted so that they can be forwarded downward to
 * the lightweight component that has enabled them.
 */
void proxyEnableEvents(long events) {
    if (peer instanceof LightweightPeer) {
        // this container is lightweight.... continue sending it
        // upward.
        if (parent != null) {
            parent.proxyEnableEvents(events);
        }
    } else {
        // This is a native container, so it needs to host
        // one of it's children.  If this function is called before
        // a peer has been created we don't yet have a dispatcher
        // because it has not yet been determined if this instance
        // is lightweight.
        if (dispatcher != null) {
            dispatcher.enableEvents(events);
        }
    }
}
 
Example #13
Source File: Container.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #14
Source File: Container.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #15
Source File: DropTarget.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 * <P>
 * @param peer The Peer of the Component we are associated with!
 *
 */

public void addNotify(ComponentPeer peer) {
    if (peer == componentPeer) return;

    componentPeer = peer;

    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = c.getPeer();
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example #16
Source File: Container.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Container displayable by connecting it to
 * a native screen resource.  Making a container displayable will
 * cause all of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        // addNotify() on the children may cause proxy event enabling
        // on this instance, so we first call super.addNotify() and
        // possibly create an lightweight event dispatcher before calling
        // addNotify() on the children which may be lightweight.
        super.addNotify();
        if (! (peer instanceof LightweightPeer)) {
            dispatcher = new LightweightDispatcher(this);
        }

        // We shouldn't use iterator because of the Swing menu
        // implementation specifics:
        // the menu is being assigned as a child to JLayeredPane
        // instead of particular component so always affect
        // collection of component if menu is becoming shown or hidden.
        for (int i = 0; i < component.size(); i++) {
            component.get(i).addNotify();
        }
    }
}
 
Example #17
Source File: KeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static Component getHeavyweight(Component comp) {
    if (comp == null || comp.getPeer() == null) {
        return null;
    } else if (comp.getPeer() instanceof LightweightPeer) {
        return comp.getNativeContainer();
    } else {
        return comp;
    }
}
 
Example #18
Source File: GraphicsCallback.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    comp.validate();
    if (comp.peer instanceof LightweightPeer) {
        comp.lightweightPrint(cg);
    } else {
        comp.peer.print(cg);
    }
}
 
Example #19
Source File: Container.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns closest heavyweight component to this container. If this container is heavyweight
 * returns this.
 * @since 1.5
 */
Container getHeavyweightContainer() {
    checkTreeLock();
    if (peer != null && !(peer instanceof LightweightPeer)) {
        return this;
    } else {
        return getNativeContainer();
    }
}
 
Example #20
Source File: GraphicsCallback.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    comp.validate();
    if (comp.peer instanceof LightweightPeer) {
        comp.lightweightPaint(cg);
    } else {
        comp.peer.paint(cg);
    }
}
 
Example #21
Source File: GraphicsCallback.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    if (comp.peer instanceof LightweightPeer) {
        comp.paintHeavyweightComponents(cg);
    } else {
        comp.paintAll(cg);
    }
}
 
Example #22
Source File: KeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Component getHeavyweight(Component comp) {
    if (comp == null || comp.getPeer() == null) {
        return null;
    } else if (comp.getPeer() instanceof LightweightPeer) {
        return comp.getNativeContainer();
    } else {
        return comp;
    }
}
 
Example #23
Source File: GraphicsCallback.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    if (comp.peer instanceof LightweightPeer) {
        comp.paintHeavyweightComponents(cg);
    } else {
        comp.paintAll(cg);
    }
}
 
Example #24
Source File: GraphicsCallback.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    comp.validate();
    if (comp.peer instanceof LightweightPeer) {
        comp.lightweightPrint(cg);
    } else {
        comp.peer.print(cg);
    }
}
 
Example #25
Source File: GraphicsCallback.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    comp.validate();
    if (comp.peer instanceof LightweightPeer) {
        comp.lightweightPaint(cg);
    } else {
        comp.peer.paint(cg);
    }
}
 
Example #26
Source File: BasicSplitPaneUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #27
Source File: KeyboardFocusManager.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static Component getHeavyweight(Component comp) {
    if (comp == null || comp.peer == null) {
        return null;
    } else if (comp.peer instanceof LightweightPeer) {
        return comp.getNativeContainer();
    } else {
        return comp;
    }
}
 
Example #28
Source File: GraphicsCallback.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    if (comp.peer instanceof LightweightPeer) {
        comp.printHeavyweightComponents(cg);
    } else {
        comp.printAll(cg);
    }
}
 
Example #29
Source File: GraphicsCallback.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    if (comp.peer instanceof LightweightPeer) {
        comp.paintHeavyweightComponents(cg);
    } else {
        comp.paintAll(cg);
    }
}
 
Example #30
Source File: GraphicsCallback.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void run(Component comp, Graphics cg) {
    comp.validate();
    if (comp.peer instanceof LightweightPeer) {
        comp.lightweightPrint(cg);
    } else {
        comp.peer.print(cg);
    }
}