src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 40,52 **** import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; import java.awt.peer.KeyboardFocusManagerPeer; import java.util.concurrent.atomic.AtomicBoolean; - import java.lang.reflect.Field; - import java.security.AccessController; - import java.security.PrivilegedAction; import sun.awt.*; import sun.awt.event.IgnorePaintEvent; --- 40,49 ----
*** 130,140 **** // private volatile boolean paintPending; private volatile boolean isLayouting; private final D delegate; ! private Container delegateContainer; private Component delegateDropTarget; private final Object dropTargetLock = new Object(); private int fNumDropTargets = 0; private CDropTarget fDropTarget = null; --- 127,137 ---- // private volatile boolean paintPending; private volatile boolean isLayouting; private final D delegate; ! private final Container delegateContainer; private Component delegateDropTarget; private final Object dropTargetLock = new Object(); private int fNumDropTargets = 0; private CDropTarget fDropTarget = null;
*** 155,167 **** * All Swing delegates use delegateContainer as a parent. This container * intentionally do not use parent of the peer. */ @SuppressWarnings("serial")// Safe: outer class is non-serializable. private final class DelegateContainer extends Container { - { - enableEvents(0xFFFFFFFF); - } // Empty non private constructor was added because access to this // class shouldn't be emulated by a synthetic accessor method. DelegateContainer() { super(); --- 152,161 ----
*** 210,289 **** 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())); } }); } - } - - /** - * This method must be called under Toolkit.getDefaultToolkit() lock - * and followed by setToolkitAWTEventListener() - */ - protected final AWTEventListener getToolkitAWTEventListener() { - return AccessController.doPrivileged(new PrivilegedAction<AWTEventListener>() { - public AWTEventListener run() { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - try { - Field field = Toolkit.class.getDeclaredField("eventListener"); - field.setAccessible(true); - return (AWTEventListener) field.get(toolkit); - } catch (Exception e) { - throw new InternalError(e.toString()); - } - } - }); - } - - protected final void setToolkitAWTEventListener(final AWTEventListener listener) { - AccessController.doPrivileged(new PrivilegedAction<Void>() { - public Void run() { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - try { - Field field = Toolkit.class.getDeclaredField("eventListener"); - field.setAccessible(true); - field.set(toolkit, listener); - } catch (Exception e) { - throw new InternalError(e.toString()); - } - return null; - } - }); - } /** * This method is called under getDelegateLock(). * Overridden in subclasses. */ --- 204,237 ---- if (containerPeer != null) { containerPeer.addChildPeer(this); } // the delegate must be created after the target is set synchronized (getDelegateLock()) { delegate = createDelegate(); ! if (delegate == null) { ! delegateContainer = null; ! return; ! } delegate.setVisible(false); delegateContainer = new DelegateContainer(); delegateContainer.add(delegate); delegateContainer.addNotify(); resetColorsAndFont(delegate); delegate.setOpaque(true); } // 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())); } }); } /** * This method is called under getDelegateLock(). * Overridden in subclasses. */