jdk/src/share/classes/java/awt/Window.java

Print this page

        

*** 439,449 **** } transient Object anchor = new Object(); static class WindowDisposerRecord implements sun.java2d.DisposerRecord { final WeakReference<Window> owner; ! final WeakReference weakThis; final WeakReference<AppContext> context; WindowDisposerRecord(AppContext context, Window victim) { owner = new WeakReference<Window>(victim.getOwner()); weakThis = victim.weakThis; this.context = new WeakReference<AppContext>(context); --- 439,449 ---- } transient Object anchor = new Object(); static class WindowDisposerRecord implements sun.java2d.DisposerRecord { final WeakReference<Window> owner; ! final WeakReference<Window> weakThis; final WeakReference<AppContext> context; WindowDisposerRecord(AppContext context, Window victim) { owner = new WeakReference<Window>(victim.getOwner()); weakThis = victim.weakThis; this.context = new WeakReference<AppContext>(context);
*** 756,766 **** * @since JDK1.0 */ public void addNotify() { synchronized (getTreeLock()) { Container parent = this.parent; ! if (parent != null && parent.getPeer() == null) { parent.addNotify(); } if (peer == null) { peer = getToolkit().createWindow(this); } --- 756,766 ---- * @since JDK1.0 */ public void addNotify() { synchronized (getTreeLock()) { Container parent = this.parent; ! if (parent != null && parent.peer == null) { parent.addNotify(); } if (peer == null) { peer = getToolkit().createWindow(this); }
*** 798,808 **** * @see Component#isDisplayable * @see #setMinimumSize */ public void pack() { Container parent = this.parent; ! if (parent != null && parent.getPeer() == null) { parent.addNotify(); } if (peer == null) { addNotify(); } --- 798,808 ---- * @see Component#isDisplayable * @see #setMinimumSize */ public void pack() { Container parent = this.parent; ! if (parent != null && parent.peer == null) { parent.addNotify(); } if (peer == null) { addNotify(); }
*** 1067,1078 **** state |= OPENED; } } static void updateChildFocusableWindowState(Window w) { ! if (w.getPeer() != null && w.isShowing()) { ! ((WindowPeer)w.getPeer()).updateFocusableWindowState(); } for (int i = 0; i < w.ownedWindowList.size(); i++) { Window child = w.ownedWindowList.elementAt(i).get(); if (child != null) { updateChildFocusableWindowState(child); --- 1067,1078 ---- state |= OPENED; } } static void updateChildFocusableWindowState(Window w) { ! if (w.peer != null && w.isShowing()) { ! ((WindowPeer)w.peer).updateFocusableWindowState(); } for (int i = 0; i < w.ownedWindowList.size(); i++) { Window child = w.ownedWindowList.elementAt(i).get(); if (child != null) { updateChildFocusableWindowState(child);
*** 1153,1163 **** * as reported in javadoc. So we need to implement this functionality even if a * child overrides dispose() in a wrong way without calling super.dispose(). */ void disposeImpl() { dispose(); ! if (getPeer() != null) { doDispose(); } } void doDispose() { --- 1153,1163 ---- * as reported in javadoc. So we need to implement this functionality even if a * child overrides dispose() in a wrong way without calling super.dispose(). */ void disposeImpl() { dispose(); ! if (peer != null) { doDispose(); } } void doDispose() {
*** 1540,1549 **** --- 1540,1550 ---- } private static Window[] getWindows(AppContext appContext) { synchronized (Window.class) { Window realCopy[]; + @SuppressWarnings("unchecked") Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)appContext.get(Window.class); if (windowList != null) { int fullSize = windowList.size(); int realSize = 0;
*** 1864,1874 **** * @see #addWindowListener * @see #removeWindowListener * @since 1.4 */ public synchronized WindowListener[] getWindowListeners() { ! return (WindowListener[])(getListeners(WindowListener.class)); } /** * Returns an array of all the window focus listeners * registered on this window. --- 1865,1875 ---- * @see #addWindowListener * @see #removeWindowListener * @since 1.4 */ public synchronized WindowListener[] getWindowListeners() { ! return getListeners(WindowListener.class); } /** * Returns an array of all the window focus listeners * registered on this window.
*** 1880,1890 **** * @see #addWindowFocusListener * @see #removeWindowFocusListener * @since 1.4 */ public synchronized WindowFocusListener[] getWindowFocusListeners() { ! return (WindowFocusListener[])(getListeners(WindowFocusListener.class)); } /** * Returns an array of all the window state listeners * registered on this window. --- 1881,1891 ---- * @see #addWindowFocusListener * @see #removeWindowFocusListener * @since 1.4 */ public synchronized WindowFocusListener[] getWindowFocusListeners() { ! return getListeners(WindowFocusListener.class); } /** * Returns an array of all the window state listeners * registered on this window.
*** 1896,1906 **** * @see #addWindowStateListener * @see #removeWindowStateListener * @since 1.4 */ public synchronized WindowStateListener[] getWindowStateListeners() { ! return (WindowStateListener[])(getListeners(WindowStateListener.class)); } /** * Returns an array of all the objects currently registered --- 1897,1907 ---- * @see #addWindowStateListener * @see #removeWindowStateListener * @since 1.4 */ public synchronized WindowStateListener[] getWindowStateListeners() { ! return getListeners(WindowStateListener.class); } /** * Returns an array of all the objects currently registered
*** 2012,2022 **** case WindowEvent.WINDOW_LOST_FOCUS: processWindowFocusEvent((WindowEvent)e); break; case WindowEvent.WINDOW_STATE_CHANGED: processWindowStateEvent((WindowEvent)e); - default: break; } return; } super.processEvent(e); --- 2013,2022 ----
*** 2380,2395 **** --- 2380,2397 ---- * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * @since 1.4 */ + @SuppressWarnings("unchecked") public Set<AWTKeyStroke> getFocusTraversalKeys(int id) { if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) { throw new IllegalArgumentException("invalid focus traversal key identifier"); } // Okay to return Set directly because it is an unmodifiable view + @SuppressWarnings("rawtypes") Set keystrokes = (focusTraversalKeys != null) ? focusTraversalKeys[id] : null; if (keystrokes != null) {
*** 2763,2773 **** } /* * Support for tracking all windows owned by this window */ ! void addOwnedWindow(WeakReference weakWindow) { if (weakWindow != null) { synchronized(ownedWindowList) { // this if statement should really be an assert, but we don't // have asserts... if (!ownedWindowList.contains(weakWindow)) { --- 2765,2775 ---- } /* * Support for tracking all windows owned by this window */ ! void addOwnedWindow(WeakReference<Window> weakWindow) { if (weakWindow != null) { synchronized(ownedWindowList) { // this if statement should really be an assert, but we don't // have asserts... if (!ownedWindowList.contains(weakWindow)) {
*** 2775,2785 **** } } } } ! void removeOwnedWindow(WeakReference weakWindow) { if (weakWindow != null) { // synchronized block not required since removeElement is // already synchronized ownedWindowList.removeElement(weakWindow); } --- 2777,2787 ---- } } } } ! void removeOwnedWindow(WeakReference<Window> weakWindow) { if (weakWindow != null) { // synchronized block not required since removeElement is // already synchronized ownedWindowList.removeElement(weakWindow); }
*** 2790,2810 **** addOwnedWindow(child.weakThis); } private void addToWindowList() { synchronized (Window.class) { Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)appContext.get(Window.class); if (windowList == null) { windowList = new Vector<WeakReference<Window>>(); appContext.put(Window.class, windowList); } windowList.add(weakThis); } } ! private static void removeFromWindowList(AppContext context, WeakReference weakThis) { synchronized (Window.class) { Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class); if (windowList != null) { windowList.remove(weakThis); } } --- 2792,2814 ---- addOwnedWindow(child.weakThis); } private void addToWindowList() { synchronized (Window.class) { + @SuppressWarnings("unchecked") Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)appContext.get(Window.class); if (windowList == null) { windowList = new Vector<WeakReference<Window>>(); appContext.put(Window.class, windowList); } windowList.add(weakThis); } } ! private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) { synchronized (Window.class) { + @SuppressWarnings("unchecked") Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class); if (windowList != null) { windowList.remove(weakThis); } }
*** 2943,2964 **** inputContextLock = new Object(); // Deserialized Windows are not yet visible. visible = false; ! weakThis = new WeakReference(this); anchor = new Object(); sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this)); addToWindowList(); initGC(null); } private void deserializeResources(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException { ! ownedWindowList = new Vector(); if (windowSerializedDataVersion < 2) { // Translate old-style focus tracking to new model. For 1.4 and // later releases, we'll rely on the Window's initial focusable // Component. --- 2947,2968 ---- inputContextLock = new Object(); // Deserialized Windows are not yet visible. visible = false; ! weakThis = new WeakReference<>(this); anchor = new Object(); sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this)); addToWindowList(); initGC(null); } private void deserializeResources(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException { ! ownedWindowList = new Vector<>(); if (windowSerializedDataVersion < 2) { // Translate old-style focus tracking to new model. For 1.4 and // later releases, we'll rely on the Window's initial focusable // Component.
*** 3598,3610 **** throw new UnsupportedOperationException( "TRANSLUCENT translucency is not supported."); } } this.opacity = opacity; ! WindowPeer peer = (WindowPeer)getPeer(); ! if (peer != null) { ! peer.setOpacity(opacity); } } } /** --- 3602,3614 ---- throw new UnsupportedOperationException( "TRANSLUCENT translucency is not supported."); } } this.opacity = opacity; ! WindowPeer windowPeer = (WindowPeer)peer; ! if (windowPeer != null) { ! windowPeer.setOpacity(opacity); } } } /**
*** 3692,3704 **** throw new UnsupportedOperationException( "PERPIXEL_TRANSPARENT translucency is not supported."); } } this.shape = (shape == null) ? null : new Path2D.Float(shape); ! WindowPeer peer = (WindowPeer)getPeer(); ! if (peer != null) { ! peer.applyShape(shape == null ? null : Region.getInstance(shape, null)); } } } /** --- 3696,3708 ---- throw new UnsupportedOperationException( "PERPIXEL_TRANSPARENT translucency is not supported."); } } this.shape = (shape == null) ? null : new Path2D.Float(shape); ! WindowPeer windowPeer = (WindowPeer)peer; ! if (windowPeer != null) { ! windowPeer.applyShape(shape == null ? null : Region.getInstance(shape, null)); } } } /**
*** 3819,3831 **** } setLayersOpaque(this, false); } else if ((oldAlpha < 255) && (alpha == 255)) { setLayersOpaque(this, true); } ! WindowPeer peer = (WindowPeer)getPeer(); ! if (peer != null) { ! peer.setOpaque(alpha == 255); } } /** * Indicates if the window is currently opaque. --- 3823,3835 ---- } setLayersOpaque(this, false); } else if ((oldAlpha < 255) && (alpha == 255)) { setLayersOpaque(this, true); } ! WindowPeer windowPeer = (WindowPeer)peer; ! if (windowPeer != null) { ! windowPeer.setOpaque(alpha == 255); } } /** * Indicates if the window is currently opaque.
*** 3846,3858 **** return bg != null ? bg.getAlpha() == 255 : true; } private void updateWindow() { synchronized (getTreeLock()) { ! WindowPeer peer = (WindowPeer)getPeer(); ! if (peer != null) { ! peer.updateWindow(); } } } /** --- 3850,3862 ---- return bg != null ? bg.getAlpha() == 255 : true; } private void updateWindow() { synchronized (getTreeLock()) { ! WindowPeer windowPeer = (WindowPeer)peer; ! if (windowPeer != null) { ! windowPeer.updateWindow(); } } } /**
*** 4043,4055 **** window.securityWarningPointY = point.getY(); window.securityWarningAlignmentX = alignmentX; window.securityWarningAlignmentY = alignmentY; synchronized (window.getTreeLock()) { ! WindowPeer peer = (WindowPeer)window.getPeer(); ! if (peer != null) { ! peer.repositionSecurityWarning(); } } } public Point2D calculateSecurityWarningPosition(Window window, --- 4047,4059 ---- window.securityWarningPointY = point.getY(); window.securityWarningAlignmentX = alignmentX; window.securityWarningAlignmentY = alignmentY; synchronized (window.getTreeLock()) { ! WindowPeer windowPeer = (WindowPeer)window.peer; ! if (windowPeer != null) { ! windowPeer.repositionSecurityWarning(); } } } public Point2D calculateSecurityWarningPosition(Window window,