Java Code Examples for com.sun.java.swing.SwingUtilities3#setDelegateRepaintManager()

The following examples show how to use com.sun.java.swing.SwingUtilities3#setDelegateRepaintManager() . 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: TransformUI.java    From darklaf with MIT License 5 votes vote down vote up
private void setView(final JComponent view) {
    if (delegatePossible) {
        if (this.view != null) {
            SwingUtilities3.setDelegateRepaintManager(this.view, null);
        }
    }
    this.view = view;
    if (delegatePossible) {
        if (this.view != null) {
            SwingUtilities3.setDelegateRepaintManager(this.view, wrappedManager);
        }
    }
    setDirty(true);
}
 
Example 2
Source File: LWComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 3
Source File: LWComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 4
Source File: LWComponentPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 5
Source File: LWComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 6
Source File: LWComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 7
Source File: LWComponentPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 8
Source File: LWComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 9
Source File: LWComponentPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 10
Source File: LWComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 11
Source File: LWComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 12
Source File: LWComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 13
Source File: LWComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}
 
Example 14
Source File: LWComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
LWComponentPeer(final T target, final PlatformComponent platformComponent) {
    targetPaintArea = new LWRepaintArea();
    this.target = target;
    this.platformComponent = platformComponent;

    // Container peer is always null for LWWindowPeers, so
    // windowPeer is always null for them as well. On the other
    // hand, LWWindowPeer shouldn't use windowPeer at all
    final Container container = SunToolkit.getNativeContainer(target);
    containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
    windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
                                       : null;
    // don't bother about z-order here as updateZOrder()
    // will be called from addNotify() later anyway
    if (containerPeer != null) {
        containerPeer.addChildPeer(this);
    }

    // the delegate must be created after the target is set
    AWTEventListener toolkitListener = null;
    synchronized (Toolkit.getDefaultToolkit()) {
        try {
            toolkitListener = getToolkitAWTEventListener();
            setToolkitAWTEventListener(null);

            synchronized (getDelegateLock()) {
                delegate = createDelegate();
                if (delegate != null) {
                    delegate.setVisible(false);
                    delegateContainer = new DelegateContainer();
                    delegateContainer.add(delegate);
                    delegateContainer.addNotify();
                    delegate.addNotify();
                    resetColorsAndFont(delegate);
                    delegate.setOpaque(true);
                } else {
                    return;
                }
            }

        } finally {
            setToolkitAWTEventListener(toolkitListener);
        }

        // todo swing: later on we will probably have one global RM
        SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
            @Override
            public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
                repaintPeer(SwingUtilities.convertRectangle(
                        c, new Rectangle(x, y, w, h), getDelegate()));
            }
        });
    }
}