diff --git a/jdk/src/share/classes/com/sun/java/swing/Painter.java b/jdk/src/share/classes/com/sun/java/swing/Painter.java index b0bd8463d69..b710126d02d 100644 --- a/jdk/src/share/classes/com/sun/java/swing/Painter.java +++ b/jdk/src/share/classes/com/sun/java/swing/Painter.java @@ -29,5 +29,5 @@ package com.sun.java.swing; * * @deprecated Use {@link javax.swing.Painter} instead. */ -public interface Painter extends javax.swing.Painter { +public interface Painter extends javax.swing.Painter { } diff --git a/jdk/src/share/classes/java/awt/AWTEvent.java b/jdk/src/share/classes/java/awt/AWTEvent.java index e3b650fc0ab..87469980e6d 100644 --- a/jdk/src/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/share/classes/java/awt/AWTEvent.java @@ -278,9 +278,9 @@ public abstract class AWTEvent extends EventObject { private static synchronized Field get_InputEvent_CanAccessSystemClipboard() { if (inputEvent_CanAccessSystemClipboard_Field == null) { inputEvent_CanAccessSystemClipboard_Field = - (Field)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Field run() { Field field = null; try { field = InputEvent.class. diff --git a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java index 9be8a504b09..a5daab688dc 100644 --- a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java +++ b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java @@ -953,7 +953,7 @@ public class AWTEventMulticaster implements * AWTEventMulticaster. Additionally, only listeners of type listenerType * are counted. Method modified to fix bug 4513402. -bchristi */ - private static int getListenerCount(EventListener l, Class listenerType) { + private static int getListenerCount(EventListener l, Class listenerType) { if (l instanceof AWTEventMulticaster) { AWTEventMulticaster mc = (AWTEventMulticaster)l; return getListenerCount(mc.a, listenerType) + @@ -1017,6 +1017,7 @@ public class AWTEventMulticaster implements * * @since 1.4 */ + @SuppressWarnings("unchecked") public static T[] getListeners(EventListener l, Class listenerType) { diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java index 550ba7654b0..22c380137c0 100644 --- a/jdk/src/share/classes/java/awt/Component.java +++ b/jdk/src/share/classes/java/awt/Component.java @@ -382,7 +382,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @serial * @see #add */ - Vector popups; + Vector popups; /** * A component's name. @@ -441,7 +441,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getFocusTraversalKeys * @since 1.4 */ - Set[] focusTraversalKeys; + Set[] focusTraversalKeys; private static final String[] focusTraversalKeyPropertyNames = { "forwardFocusTraversalKeys", @@ -598,12 +598,12 @@ public abstract class Component implements ImageObserver, MenuContainer, initIDs(); } - String s = (String) java.security.AccessController.doPrivileged( - new GetPropertyAction("awt.image.incrementaldraw")); + String s = java.security.AccessController.doPrivileged( + new GetPropertyAction("awt.image.incrementaldraw")); isInc = (s == null || s.equals("true")); - s = (String) java.security.AccessController.doPrivileged( - new GetPropertyAction("awt.image.redrawrate")); + s = java.security.AccessController.doPrivileged( + new GetPropertyAction("awt.image.redrawrate")); incRate = (s != null) ? Integer.parseInt(s) : 100; } @@ -986,6 +986,7 @@ public abstract class Component implements ImageObserver, MenuContainer, appContext = AppContext.getAppContext(); } + @SuppressWarnings({"rawtypes", "unchecked"}) void initializeFocusTraversalKeys() { focusTraversalKeys = new Set[3]; } @@ -1369,13 +1370,13 @@ public abstract class Component implements ImageObserver, MenuContainer, throw new HeadlessException(); } - PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - return MouseInfo.getPointerInfo(); - } - } - ); + PointerInfo pi = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PointerInfo run() { + return MouseInfo.getPointerInfo(); + } + } + ); synchronized (getTreeLock()) { Component inTheSameWindow = findUnderMouseInWindow(pi); @@ -2334,7 +2335,7 @@ public abstract class Component implements ImageObserver, MenuContainer, peer.setBounds(nativeX, nativeY, width, height, op); } - + @SuppressWarnings("deprecation") private void notifyNewBounds(boolean resized, boolean moved) { if (componentListener != null || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 @@ -4690,6 +4691,7 @@ public abstract class Component implements ImageObserver, MenuContainer, dispatchEventImpl(e); } + @SuppressWarnings("deprecation") void dispatchEventImpl(AWTEvent e) { int id = e.getID(); @@ -5242,7 +5244,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized ComponentListener[] getComponentListeners() { - return (ComponentListener[]) (getListeners(ComponentListener.class)); + return getListeners(ComponentListener.class); } /** @@ -5311,7 +5313,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized FocusListener[] getFocusListeners() { - return (FocusListener[]) (getListeners(FocusListener.class)); + return getListeners(FocusListener.class); } /** @@ -5402,7 +5404,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized HierarchyListener[] getHierarchyListeners() { - return (HierarchyListener[])(getListeners(HierarchyListener.class)); + return getListeners(HierarchyListener.class); } /** @@ -5564,8 +5566,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() { - return (HierarchyBoundsListener[]) - (getListeners(HierarchyBoundsListener.class)); + return getListeners(HierarchyBoundsListener.class); } /* @@ -5644,7 +5645,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized KeyListener[] getKeyListeners() { - return (KeyListener[]) (getListeners(KeyListener.class)); + return getListeners(KeyListener.class); } /** @@ -5713,7 +5714,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized MouseListener[] getMouseListeners() { - return (MouseListener[]) (getListeners(MouseListener.class)); + return getListeners(MouseListener.class); } /** @@ -5782,7 +5783,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized MouseMotionListener[] getMouseMotionListeners() { - return (MouseMotionListener[]) (getListeners(MouseMotionListener.class)); + return getListeners(MouseMotionListener.class); } /** @@ -5855,7 +5856,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized MouseWheelListener[] getMouseWheelListeners() { - return (MouseWheelListener[]) (getListeners(MouseWheelListener.class)); + return getListeners(MouseWheelListener.class); } /** @@ -5922,7 +5923,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.4 */ public synchronized InputMethodListener[] getInputMethodListeners() { - return (InputMethodListener[]) (getListeners(InputMethodListener.class)); + return getListeners(InputMethodListener.class); } /** @@ -5967,6 +5968,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * * @since 1.3 */ + @SuppressWarnings("unchecked") public T[] getListeners(Class listenerType) { EventListener l = null; if (listenerType == ComponentListener.class) { @@ -6909,7 +6911,7 @@ public abstract class Component implements ImageObserver, MenuContainer, int npopups = (popups != null? popups.size() : 0); for (int i = 0 ; i < npopups ; i++) { - PopupMenu popup = (PopupMenu)popups.elementAt(i); + PopupMenu popup = popups.elementAt(i); popup.addNotify(); } @@ -6979,7 +6981,7 @@ public abstract class Component implements ImageObserver, MenuContainer, int npopups = (popups != null? popups.size() : 0); for (int i = 0 ; i < npopups ; i++) { - PopupMenu popup = (PopupMenu)popups.elementAt(i); + PopupMenu popup = popups.elementAt(i); popup.removeNotify(); } // If there is any input context for this component, notify @@ -7238,7 +7240,7 @@ public abstract class Component implements ImageObserver, MenuContainer, // would erroneously generate an IllegalArgumentException for // DOWN_CYCLE_TRAVERSAL_KEY. final void setFocusTraversalKeys_NoIDCheck(int id, Set keystrokes) { - Set oldKeys; + Set oldKeys; synchronized (this) { if (focusTraversalKeys == null) { @@ -7246,20 +7248,12 @@ public abstract class Component implements ImageObserver, MenuContainer, } if (keystrokes != null) { - for (Iterator iter = keystrokes.iterator(); iter.hasNext(); ) { - Object obj = iter.next(); + for (AWTKeyStroke keystroke : keystrokes ) { - if (obj == null) { + if (keystroke == null) { throw new IllegalArgumentException("cannot set null focus traversal key"); } - // Fix for 6195828: - //According to javadoc this method should throw IAE instead of ClassCastException - if (!(obj instanceof AWTKeyStroke)) { - throw new IllegalArgumentException("object is expected to be AWTKeyStroke"); - } - AWTKeyStroke keystroke = (AWTKeyStroke)obj; - if (keystroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { throw new IllegalArgumentException("focus traversal keys cannot map to KEY_TYPED events"); } @@ -7279,16 +7273,16 @@ public abstract class Component implements ImageObserver, MenuContainer, oldKeys = focusTraversalKeys[id]; focusTraversalKeys[id] = (keystrokes != null) - ? Collections.unmodifiableSet(new HashSet(keystrokes)) + ? Collections.unmodifiableSet(new HashSet(keystrokes)) : null; } firePropertyChange(focusTraversalKeyPropertyNames[id], oldKeys, keystrokes); } - final Set getFocusTraversalKeys_NoIDCheck(int id) { + final Set getFocusTraversalKeys_NoIDCheck(int id) { // Okay to return Set directly because it is an unmodifiable view - Set keystrokes = (focusTraversalKeys != null) + Set keystrokes = (focusTraversalKeys != null) ? focusTraversalKeys[id] : null; @@ -7686,7 +7680,7 @@ public abstract class Component implements ImageObserver, MenuContainer, } Window window = getContainingWindow(); - if (window == null || !((Window)window).isFocusableWindow()) { + if (window == null || !window.isFocusableWindow()) { if (focusLog.isLoggable(PlatformLogger.FINEST)) { focusLog.finest("Component doesn't have toplevel"); } @@ -8025,7 +8019,7 @@ public abstract class Component implements ImageObserver, MenuContainer, popup.parent.remove(popup); } if (popups == null) { - popups = new Vector(); + popups = new Vector(); } popups.addElement(popup); popup.parent = this; @@ -8044,6 +8038,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #add(PopupMenu) * @since JDK1.1 */ + @SuppressWarnings("unchecked") public void remove(MenuComponent popup) { synchronized (getTreeLock()) { if (popups == null) { @@ -8556,26 +8551,26 @@ public abstract class Component implements ImageObserver, MenuContainer, // // Swing classes MUST be loaded by the bootstrap class loader, // otherwise we don't consider them. - for (Class klass = Component.this.getClass(); klass != null; + for (Class klass = Component.this.getClass(); klass != null; klass = klass.getSuperclass()) { if (klass.getPackage() == swingPackage && klass.getClassLoader() == null) { - final Class swingClass = klass; + final Class swingClass = klass; // Find the first override of the compWriteObjectNotify method - Method[] methods = (Method[])AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return swingClass.getDeclaredMethods(); - } - }); + Method[] methods = AccessController.doPrivileged( + new PrivilegedAction() { + public Method[] run() { + return swingClass.getDeclaredMethods(); + } + }); for (int counter = methods.length - 1; counter >= 0; counter--) { final Method method = methods[counter]; if (method.getName().equals("compWriteObjectNotify")){ // We found it, use doPrivileged to make it accessible // to use. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { method.setAccessible(true); return null; } @@ -8804,7 +8799,7 @@ public abstract class Component implements ImageObserver, MenuContainer, if (popups != null) { int npopups = popups.size(); for (int i = 0 ; i < npopups ; i++) { - PopupMenu popup = (PopupMenu)popups.elementAt(i); + PopupMenu popup = popups.elementAt(i); popup.parent = this; } } @@ -9658,7 +9653,7 @@ public abstract class Component implements ImageObserver, MenuContainer, if (obj == null) return false; if (className == null) return false; - Class cls = obj.getClass(); + Class cls = obj.getClass(); while (cls != null) { if (cls.getName().equals(className)) { return true; diff --git a/jdk/src/share/classes/java/awt/Font.java b/jdk/src/share/classes/java/awt/Font.java index a877d28450a..e3d48d6a236 100644 --- a/jdk/src/share/classes/java/awt/Font.java +++ b/jdk/src/share/classes/java/awt/Font.java @@ -254,7 +254,7 @@ public class Font implements java.io.Serializable * @serial * @see #getAttributes() */ - private Hashtable fRequestedAttributes; + private Hashtable fRequestedAttributes; /* * Constants to be used for logical font family names. @@ -446,6 +446,7 @@ public class Font implements java.io.Serializable // We implement this functionality in a package-private method // to insure that it cannot be overridden by client subclasses. // DO NOT INVOKE CLIENT CODE ON THIS THREAD! + @SuppressWarnings("deprecation") final FontPeer getPeer_NoClientCode() { if(peer == null) { Toolkit tk = Toolkit.getDefaultToolkit(); @@ -907,11 +908,11 @@ public class Font implements java.io.Serializable break; } if (tracker != null) { - if (totalSize+bytesRead > tracker.MAX_FILE_SIZE) { + if (totalSize+bytesRead > CreatedFontTracker.MAX_FILE_SIZE) { throw new IOException("File too big."); } if (totalSize+tracker.getNumBytes() > - tracker.MAX_TOTAL_BYTES) + CreatedFontTracker.MAX_TOTAL_BYTES) { throw new IOException("Total files too big."); } @@ -2126,11 +2127,11 @@ public class Font implements java.io.Serializable return false; // REMIND always safe, but prevents caller optimize } - private transient SoftReference flmref; + private transient SoftReference flmref; private FontLineMetrics defaultLineMetrics(FontRenderContext frc) { FontLineMetrics flm = null; if (flmref == null - || (flm = (FontLineMetrics)flmref.get()) == null + || (flm = flmref.get()) == null || !flm.frc.equals(frc)) { /* The device transform in the frc is not used in obtaining line @@ -2194,7 +2195,7 @@ public class Font implements java.io.Serializable ssOffset, italicAngle); flm = new FontLineMetrics(0, cm, frc); - flmref = new SoftReference(flm); + flmref = new SoftReference(flm); } return (FontLineMetrics)flm.clone(); diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 8187084b52d..d9f8cf07efb 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -706,9 +706,9 @@ public abstract class Toolkit { final Properties properties = new Properties(); - atNames = (String)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + atNames = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public String run() { // Try loading the per-user accessibility properties file. try { @@ -798,7 +798,7 @@ public abstract class Toolkit { while (parser.hasMoreTokens()) { atName = parser.nextToken(); try { - Class clazz; + Class clazz; if (cl != null) { clazz = cl.loadClass(atName); } else { @@ -860,8 +860,8 @@ public abstract class Toolkit { java.lang.Compiler.disable(); java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { String nm = null; Class cls = null; try { @@ -1653,8 +1653,8 @@ public abstract class Toolkit { static { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { try { resources = ResourceBundle.getBundle("sun.awt.resources.awt", @@ -1984,7 +1984,7 @@ public abstract class Toolkit { private int[] calls = new int[LONG_BITS]; private static volatile long enabledOnToolkitMask; private AWTEventListener eventListener = null; - private WeakHashMap listener2SelectiveListener = new WeakHashMap(); + private WeakHashMap listener2SelectiveListener = new WeakHashMap<>(); /* * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy, @@ -2051,7 +2051,7 @@ public abstract class Toolkit { } synchronized (this) { SelectiveAWTEventListener selectiveListener = - (SelectiveAWTEventListener)listener2SelectiveListener.get(localL); + listener2SelectiveListener.get(localL); if (selectiveListener == null) { // Create a new selectiveListener. @@ -2121,7 +2121,7 @@ public abstract class Toolkit { synchronized (this) { SelectiveAWTEventListener selectiveListener = - (SelectiveAWTEventListener)listener2SelectiveListener.get(localL); + listener2SelectiveListener.get(localL); if (selectiveListener != null) { listener2SelectiveListener.remove(localL); @@ -2244,7 +2244,7 @@ public abstract class Toolkit { synchronized (this) { EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); - java.util.List list = new ArrayList(la.length); + java.util.List list = new ArrayList<>(la.length); for (int i = 0; i < la.length; i++) { SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i]; @@ -2254,7 +2254,7 @@ public abstract class Toolkit { sael.getListener())); } } - return (AWTEventListener[])list.toArray(new AWTEventListener[0]); + return list.toArray(new AWTEventListener[0]); } } @@ -2457,7 +2457,9 @@ public abstract class Toolkit { } } + @SuppressWarnings("serial") private static class DesktopPropertyChangeSupport extends PropertyChangeSupport { + private static final StringBuilder PROP_CHANGE_SUPPORT_KEY = new StringBuilder("desktop property change support key"); private final Object source; diff --git a/jdk/src/share/classes/java/awt/image/ColorModel.java b/jdk/src/share/classes/java/awt/image/ColorModel.java index 77f0459cb5f..010fc53829a 100644 --- a/jdk/src/share/classes/java/awt/image/ColorModel.java +++ b/jdk/src/share/classes/java/awt/image/ColorModel.java @@ -357,7 +357,7 @@ public abstract class ColorModel implements Transparency{ this.transparency = transparency; } - nBits = (int[]) bits.clone(); + nBits = bits.clone(); this.pixel_bits = pixel_bits; if (pixel_bits <= 0) { throw new IllegalArgumentException("Number of pixel bits must "+ @@ -474,7 +474,7 @@ public abstract class ColorModel implements Transparency{ */ public int[] getComponentSize() { if (nBits != null) { - return (int[]) nBits.clone(); + return nBits.clone(); } return null; @@ -1692,10 +1692,10 @@ public abstract class ColorModel implements Transparency{ static short[] s8Tol16 = null; // 8-bit non-linear sRGB to 16-bit linear LUT // Maps to hold LUTs for grayscale conversions - static Map g8Tos8Map = null; // 8-bit gray values to 8-bit sRGB values - static Map lg16Toog8Map = null; // 16-bit linear to 8-bit "other" gray - static Map g16Tos8Map = null; // 16-bit gray values to 8-bit sRGB values - static Map lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray + static Map g8Tos8Map = null; // 8-bit gray values to 8-bit sRGB values + static Map lg16Toog8Map = null; // 16-bit linear to 8-bit "other" gray + static Map g16Tos8Map = null; // 16-bit gray values to 8-bit sRGB values + static Map lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray static boolean isLinearRGBspace(ColorSpace cs) { // Note: CMM.LINEAR_RGBspace will be null if the linear @@ -1799,7 +1799,7 @@ public abstract class ColorModel implements Transparency{ return getLinearRGB8TosRGB8LUT(); } if (g8Tos8Map != null) { - byte[] g8Tos8LUT = (byte []) g8Tos8Map.get(grayCS); + byte[] g8Tos8LUT = g8Tos8Map.get(grayCS); if (g8Tos8LUT != null) { return g8Tos8LUT; } @@ -1827,7 +1827,7 @@ public abstract class ColorModel implements Transparency{ g8Tos8LUT[i] = tmp[j]; } if (g8Tos8Map == null) { - g8Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); + g8Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); } g8Tos8Map.put(grayCS, g8Tos8LUT); return g8Tos8LUT; @@ -1840,7 +1840,7 @@ public abstract class ColorModel implements Transparency{ */ static byte[] getLinearGray16ToOtherGray8LUT(ICC_ColorSpace grayCS) { if (lg16Toog8Map != null) { - byte[] lg16Toog8LUT = (byte []) lg16Toog8Map.get(grayCS); + byte[] lg16Toog8LUT = lg16Toog8Map.get(grayCS); if (lg16Toog8LUT != null) { return lg16Toog8LUT; } @@ -1866,7 +1866,7 @@ public abstract class ColorModel implements Transparency{ (byte) (((float) (tmp[i] & 0xffff)) * (1.0f /257.0f) + 0.5f); } if (lg16Toog8Map == null) { - lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap(2)); + lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap(2)); } lg16Toog8Map.put(grayCS, lg16Toog8LUT); return lg16Toog8LUT; @@ -1884,7 +1884,7 @@ public abstract class ColorModel implements Transparency{ return getLinearRGB16TosRGB8LUT(); } if (g16Tos8Map != null) { - byte[] g16Tos8LUT = (byte []) g16Tos8Map.get(grayCS); + byte[] g16Tos8LUT = g16Tos8Map.get(grayCS); if (g16Tos8LUT != null) { return g16Tos8LUT; } @@ -1916,7 +1916,7 @@ public abstract class ColorModel implements Transparency{ (byte) (((float) (tmp[j] & 0xffff)) * (1.0f /257.0f) + 0.5f); } if (g16Tos8Map == null) { - g16Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); + g16Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); } g16Tos8Map.put(grayCS, g16Tos8LUT); return g16Tos8LUT; @@ -1929,7 +1929,7 @@ public abstract class ColorModel implements Transparency{ */ static short[] getLinearGray16ToOtherGray16LUT(ICC_ColorSpace grayCS) { if (lg16Toog16Map != null) { - short[] lg16Toog16LUT = (short []) lg16Toog16Map.get(grayCS); + short[] lg16Toog16LUT = lg16Toog16Map.get(grayCS); if (lg16Toog16LUT != null) { return lg16Toog16LUT; } @@ -1950,7 +1950,7 @@ public abstract class ColorModel implements Transparency{ transformList); short[] lg16Toog16LUT = t.colorConvert(tmp, null); if (lg16Toog16Map == null) { - lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap(2)); + lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap(2)); } lg16Toog16Map.put(grayCS, lg16Toog16LUT); return lg16Toog16LUT; diff --git a/jdk/src/share/classes/javax/swing/AbstractButton.java b/jdk/src/share/classes/javax/swing/AbstractButton.java index d95f1d4b602..b8612f1280a 100644 --- a/jdk/src/share/classes/javax/swing/AbstractButton.java +++ b/jdk/src/share/classes/javax/swing/AbstractButton.java @@ -1349,6 +1349,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl return new ButtonActionPropertyChangeListener(this, a); } + @SuppressWarnings("serial") private static class ButtonActionPropertyChangeListener extends ActionPropertyChangeListener { ButtonActionPropertyChangeListener(AbstractButton b, Action a) { @@ -1976,6 +1977,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class ButtonChangeListener implements ChangeListener, Serializable { // NOTE: This class is NOT used, instead the functionality has // been moved to Handler. @@ -2320,6 +2322,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl // // Listeners that are added to model // + @SuppressWarnings("serial") class Handler implements ActionListener, ChangeListener, ItemListener, Serializable { // @@ -2472,7 +2475,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl // the members of the button group. int len = group.getButtonCount(); Object [] target = new Object[len]; - Enumeration elem = group.getElements(); + Enumeration elem = group.getElements(); for (int i = 0; i < len; i++) { if (elem.hasMoreElements()) { target[i] = elem.nextElement(); diff --git a/jdk/src/share/classes/javax/swing/ActionMap.java b/jdk/src/share/classes/javax/swing/ActionMap.java index 9c0cbf798f0..d3a03ff4062 100644 --- a/jdk/src/share/classes/javax/swing/ActionMap.java +++ b/jdk/src/share/classes/javax/swing/ActionMap.java @@ -55,6 +55,7 @@ import java.util.Set; * @author Scott Violet * @since 1.3 */ +@SuppressWarnings("serial") public class ActionMap implements Serializable { /** Handles the mapping between Action name and Action. */ private transient ArrayTable arrayTable; diff --git a/jdk/src/share/classes/javax/swing/ActionPropertyChangeListener.java b/jdk/src/share/classes/javax/swing/ActionPropertyChangeListener.java index 558f51a1109..cccbd2aeb84 100644 --- a/jdk/src/share/classes/javax/swing/ActionPropertyChangeListener.java +++ b/jdk/src/share/classes/javax/swing/ActionPropertyChangeListener.java @@ -101,9 +101,9 @@ abstract class ActionPropertyChangeListener // Check to see whether any old buttons have // been enqueued for GC. If so, look up their // PCL instance and remove it from its Action. - OwnedWeakReference r; + OwnedWeakReference r; while ((r = (OwnedWeakReference)queue.poll()) != null) { - ActionPropertyChangeListener oldPCL = r.getOwner(); + ActionPropertyChangeListener oldPCL = r.getOwner(); Action oldAction = oldPCL.getAction(); if (oldAction!=null) { oldAction.removePropertyChangeListener(oldPCL); @@ -142,15 +142,15 @@ abstract class ActionPropertyChangeListener private static class OwnedWeakReference extends WeakReference { - private ActionPropertyChangeListener owner; + private ActionPropertyChangeListener owner; OwnedWeakReference(U target, ReferenceQueue queue, - ActionPropertyChangeListener owner) { + ActionPropertyChangeListener owner) { super(target, queue); this.owner = owner; } - public ActionPropertyChangeListener getOwner() { + public ActionPropertyChangeListener getOwner() { return owner; } } diff --git a/jdk/src/share/classes/javax/swing/AncestorNotifier.java b/jdk/src/share/classes/javax/swing/AncestorNotifier.java index 2c58f4a96a9..288d7fdb599 100644 --- a/jdk/src/share/classes/javax/swing/AncestorNotifier.java +++ b/jdk/src/share/classes/javax/swing/AncestorNotifier.java @@ -42,6 +42,7 @@ import java.io.Serializable; * @author Dave Moore */ +@SuppressWarnings("serial") class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable { Component firstInvisibleAncestor; diff --git a/jdk/src/share/classes/javax/swing/ArrayTable.java b/jdk/src/share/classes/javax/swing/ArrayTable.java index 35b169dbde0..787809201bb 100644 --- a/jdk/src/share/classes/javax/swing/ArrayTable.java +++ b/jdk/src/share/classes/javax/swing/ArrayTable.java @@ -133,7 +133,7 @@ class ArrayTable implements Cloneable { if ((size==ARRAY_BOUNDARY) && isArray()) { grow(); } - ((Hashtable)table).put(key, value); + ((Hashtable)table).put(key, value); } } } @@ -259,8 +259,8 @@ class ArrayTable implements Cloneable { newArrayTable.put(array[i], array[i+1]); } } else { - Hashtable tmp = (Hashtable)table; - Enumeration keys = tmp.keys(); + Hashtable tmp = (Hashtable)table; + Enumeration keys = tmp.keys(); while (keys.hasMoreElements()) { Object o = keys.nextElement(); newArrayTable.put(o,tmp.get(o)); @@ -289,8 +289,8 @@ class ArrayTable implements Cloneable { keys[index] = array[i]; } } else { - Hashtable tmp = (Hashtable)table; - Enumeration enum_ = tmp.keys(); + Hashtable tmp = (Hashtable)table; + Enumeration enum_ = tmp.keys(); int counter = tmp.size(); if (keys == null) { keys = new Object[counter]; @@ -326,9 +326,9 @@ class ArrayTable implements Cloneable { * Shrinks the storage from a hashtable to an array. */ private void shrink() { - Hashtable tmp = (Hashtable)table; + Hashtable tmp = (Hashtable)table; Object[] array = new Object[tmp.size()*2]; - Enumeration keys = tmp.keys(); + Enumeration keys = tmp.keys(); int j = 0; while (keys.hasMoreElements()) { diff --git a/jdk/src/share/classes/javax/swing/Box.java b/jdk/src/share/classes/javax/swing/Box.java index ff02a216c20..d1c132364b6 100644 --- a/jdk/src/share/classes/javax/swing/Box.java +++ b/jdk/src/share/classes/javax/swing/Box.java @@ -76,6 +76,7 @@ import javax.accessibility.*; * * @author Timothy Prinzing */ +@SuppressWarnings("serial") public class Box extends JComponent implements Accessible { /** @@ -301,6 +302,7 @@ public class Box extends JComponent implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") public static class Filler extends JComponent implements Accessible { /** @@ -380,6 +382,7 @@ public class Box extends JComponent implements Accessible { * This class implements accessibility support for the * Box.Filler class. */ + @SuppressWarnings("serial") protected class AccessibleBoxFiller extends AccessibleAWTComponent { // AccessibleContext methods // @@ -420,6 +423,7 @@ public class Box extends JComponent implements Accessible { * This class implements accessibility support for the * Box class. */ + @SuppressWarnings("serial") protected class AccessibleBox extends AccessibleAWTContainer { // AccessibleContext methods // diff --git a/jdk/src/share/classes/javax/swing/BoxLayout.java b/jdk/src/share/classes/javax/swing/BoxLayout.java index 4b5a87500fa..de1703d5b76 100644 --- a/jdk/src/share/classes/javax/swing/BoxLayout.java +++ b/jdk/src/share/classes/javax/swing/BoxLayout.java @@ -135,6 +135,7 @@ import java.io.PrintStream; * * @author Timothy Prinzing */ +@SuppressWarnings("serial") public class BoxLayout implements LayoutManager2, Serializable { /** diff --git a/jdk/src/share/classes/javax/swing/ButtonGroup.java b/jdk/src/share/classes/javax/swing/ButtonGroup.java index 9346a2b094a..c2971f722e4 100644 --- a/jdk/src/share/classes/javax/swing/ButtonGroup.java +++ b/jdk/src/share/classes/javax/swing/ButtonGroup.java @@ -65,6 +65,7 @@ import java.io.Serializable; * * @author Jeff Dinkins */ +@SuppressWarnings("serial") public class ButtonGroup implements Serializable { // the list of buttons participating in this group diff --git a/jdk/src/share/classes/javax/swing/ComponentInputMap.java b/jdk/src/share/classes/javax/swing/ComponentInputMap.java index 3d5ed5fc309..bf8cda326dc 100644 --- a/jdk/src/share/classes/javax/swing/ComponentInputMap.java +++ b/jdk/src/share/classes/javax/swing/ComponentInputMap.java @@ -35,6 +35,7 @@ package javax.swing; * @author Scott Violet * @since 1.3 */ +@SuppressWarnings("serial") public class ComponentInputMap extends InputMap { /** Component binding is created for. */ private JComponent component; diff --git a/jdk/src/share/classes/javax/swing/InputMap.java b/jdk/src/share/classes/javax/swing/InputMap.java index 4de3a754b62..fa2a0369a8f 100644 --- a/jdk/src/share/classes/javax/swing/InputMap.java +++ b/jdk/src/share/classes/javax/swing/InputMap.java @@ -52,6 +52,7 @@ import java.util.Set; * @author Scott Violet * @since 1.3 */ +@SuppressWarnings("serial") public class InputMap implements Serializable { /** Handles the mapping between KeyStroke and Action name. */ private transient ArrayTable arrayTable; diff --git a/jdk/src/share/classes/javax/swing/JButton.java b/jdk/src/share/classes/javax/swing/JButton.java index ad1aeffeb8b..afa1bf0e7de 100644 --- a/jdk/src/share/classes/javax/swing/JButton.java +++ b/jdk/src/share/classes/javax/swing/JButton.java @@ -75,6 +75,7 @@ import java.io.IOException; * * @author Jeff Dinkins */ +@SuppressWarnings("serial") public class JButton extends AbstractButton implements Accessible { /** @@ -307,6 +308,7 @@ public class JButton extends AbstractButton implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJButton extends AccessibleAbstractButton { /** diff --git a/jdk/src/share/classes/javax/swing/JComponent.java b/jdk/src/share/classes/javax/swing/JComponent.java index 3a9d1684b53..314a9315e48 100644 --- a/jdk/src/share/classes/javax/swing/JComponent.java +++ b/jdk/src/share/classes/javax/swing/JComponent.java @@ -2109,7 +2109,8 @@ public abstract class JComponent extends Container implements Serializable, private void registerWithKeyboardManager(boolean onlyIfNew) { InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); KeyStroke[] strokes; - Hashtable registered = (Hashtable)getClientProperty + Hashtable registered = + (Hashtable)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); if (inputMap != null) { @@ -2161,14 +2162,15 @@ public abstract class JComponent extends Container implements Serializable, * WHEN_IN_FOCUSED_WINDOW KeyStroke bindings. */ private void unregisterWithKeyboardManager() { - Hashtable registered = (Hashtable)getClientProperty + Hashtable registered = + (Hashtable)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); if (registered != null && registered.size() > 0) { - Enumeration keys = registered.keys(); + Enumeration keys = registered.keys(); while (keys.hasMoreElements()) { - KeyStroke ks = (KeyStroke)keys.nextElement(); + KeyStroke ks = keys.nextElement(); unregisterWithKeyboardManager(ks); } } @@ -3469,6 +3471,7 @@ public abstract class JComponent extends Container implements Serializable, } } + @SuppressWarnings("serial") static class KeyboardState implements Serializable { private static final Object keyCodesKey = JComponent.KeyboardState.class; @@ -4125,13 +4128,13 @@ public abstract class JComponent extends Container implements Serializable, if (!getFlag(FOCUS_TRAVERSAL_KEYS_FORWARD_SET)) { super.setFocusTraversalKeys(KeyboardFocusManager. FORWARD_TRAVERSAL_KEYS, - (Set)value); + (Set)value); } } else if (propertyName == "focusTraversalKeysBackward") { if (!getFlag(FOCUS_TRAVERSAL_KEYS_BACKWARD_SET)) { super.setFocusTraversalKeys(KeyboardFocusManager. BACKWARD_TRAVERSAL_KEYS, - (Set)value); + (Set)value); } } else { throw new IllegalArgumentException("property \""+ @@ -4188,6 +4191,7 @@ public abstract class JComponent extends Container implements Serializable, * * @return true if this component is lightweight */ + @SuppressWarnings("deprecation") public static boolean isLightweightComponent(Component c) { return c.getPeer() instanceof LightweightPeer; } diff --git a/jdk/src/share/classes/javax/swing/JLabel.java b/jdk/src/share/classes/javax/swing/JLabel.java index 3717abd9c74..106245ac295 100644 --- a/jdk/src/share/classes/javax/swing/JLabel.java +++ b/jdk/src/share/classes/javax/swing/JLabel.java @@ -104,6 +104,7 @@ import java.util.*; * * @author Hans Muller */ +@SuppressWarnings("serial") public class JLabel extends JComponent implements SwingConstants, Accessible { /** @@ -1067,6 +1068,7 @@ public class JLabel extends JComponent implements SwingConstants, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJLabel extends AccessibleJComponent implements AccessibleText, AccessibleExtendedComponent { diff --git a/jdk/src/share/classes/javax/swing/JLayeredPane.java b/jdk/src/share/classes/javax/swing/JLayeredPane.java index 182416b3aeb..3b61f28f1c6 100644 --- a/jdk/src/share/classes/javax/swing/JLayeredPane.java +++ b/jdk/src/share/classes/javax/swing/JLayeredPane.java @@ -154,6 +154,7 @@ import javax.accessibility.*; * * @author David Kloba */ +@SuppressWarnings("serial") public class JLayeredPane extends JComponent implements Accessible { /// Watch the values in getObjectForLayer() /** Convenience object defining the Default layer. Equivalent to new Integer(0).*/ @@ -256,7 +257,7 @@ public class JLayeredPane extends JComponent implements Accessible { */ public void removeAll() { Component[] children = getComponents(); - Hashtable cToL = getComponentToLayer(); + Hashtable cToL = getComponentToLayer(); for (int counter = children.length - 1; counter >= 0; counter--) { Component c = children[counter]; if (c != null && !(c instanceof JComponent)) { @@ -768,6 +769,7 @@ public class JLayeredPane extends JComponent implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJLayeredPane extends AccessibleJComponent { /** diff --git a/jdk/src/share/classes/javax/swing/JMenu.java b/jdk/src/share/classes/javax/swing/JMenu.java index f00ff31a324..62b6f41e2fe 100644 --- a/jdk/src/share/classes/javax/swing/JMenu.java +++ b/jdk/src/share/classes/javax/swing/JMenu.java @@ -109,6 +109,7 @@ import java.lang.ref.WeakReference; * @see JMenuBar * @see JPopupMenu */ +@SuppressWarnings("serial") public class JMenu extends JMenuItem implements Accessible,MenuElement { /** @@ -134,13 +135,6 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement */ private MenuEvent menuEvent = null; - /* Registry of listeners created for Action-JMenuItem - * linkage. This is needed so that references can - * be cleaned up at remove time to allow garbage collection - * Default is null. - */ - private static Hashtable listenerRegistry = null; - /* * Used by the look and feel (L&F) code to handle * implementation specific menu behaviors. @@ -1111,6 +1105,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement void configureAcceleratorFromAction(Action a) { } + @SuppressWarnings("serial") class MenuChangeListener implements ChangeListener, Serializable { boolean isSelected = false; public void stateChanged(ChangeEvent e) { @@ -1158,6 +1153,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class WinListener extends WindowAdapter implements Serializable { JPopupMenu popupMenu; /** @@ -1394,6 +1390,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJMenu extends AccessibleJMenuItem implements AccessibleSelection { diff --git a/jdk/src/share/classes/javax/swing/JMenuBar.java b/jdk/src/share/classes/javax/swing/JMenuBar.java index 4f77268bc5f..0a16c865d15 100644 --- a/jdk/src/share/classes/javax/swing/JMenuBar.java +++ b/jdk/src/share/classes/javax/swing/JMenuBar.java @@ -82,6 +82,7 @@ import javax.accessibility.*; * @see JPopupMenu * @see JMenuItem */ +@SuppressWarnings("serial") public class JMenuBar extends JComponent implements Accessible,MenuElement { /** @@ -498,6 +499,7 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJMenuBar extends AccessibleJComponent implements AccessibleSelection { diff --git a/jdk/src/share/classes/javax/swing/JMenuItem.java b/jdk/src/share/classes/javax/swing/JMenuItem.java index eaecf4da013..1e616869fd2 100644 --- a/jdk/src/share/classes/javax/swing/JMenuItem.java +++ b/jdk/src/share/classes/javax/swing/JMenuItem.java @@ -87,6 +87,7 @@ import javax.accessibility.*; * @see JCheckBoxMenuItem * @see JRadioButtonMenuItem */ +@SuppressWarnings("serial") public class JMenuItem extends AbstractButton implements Accessible,MenuElement { /** @@ -829,6 +830,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJMenuItem extends AccessibleAbstractButton implements ChangeListener { private boolean isArmed = false; diff --git a/jdk/src/share/classes/javax/swing/JPopupMenu.java b/jdk/src/share/classes/javax/swing/JPopupMenu.java index 53926e4a744..286d1bb2a0f 100644 --- a/jdk/src/share/classes/javax/swing/JPopupMenu.java +++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java @@ -81,6 +81,7 @@ import java.applet.Applet; * @author David Karlton * @author Arnaud Weber */ +@SuppressWarnings("serial") public class JPopupMenu extends JComponent implements Accessible,MenuElement { /** @@ -1200,6 +1201,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { * Java Accessibility API appropriate to popup menu user-interface * elements. */ + @SuppressWarnings("serial") protected class AccessibleJPopupMenu extends AccessibleJComponent implements PropertyChangeListener { @@ -1268,7 +1270,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { private void fireActiveDescendant() { if (JPopupMenu.this instanceof BasicComboPopup) { // get the popup list - JList popupList = ((BasicComboPopup)JPopupMenu.this).getList(); + JList popupList = ((BasicComboPopup)JPopupMenu.this).getList(); if (popupList == null) { return; } @@ -1335,7 +1337,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { throws IOException, ClassNotFoundException { s.defaultReadObject(); - Vector values = (Vector)s.readObject(); + Vector values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); @@ -1519,6 +1521,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { /** * A popup menu-specific separator. */ + @SuppressWarnings("serial") static public class Separator extends JSeparator { public Separator( ) diff --git a/jdk/src/share/classes/javax/swing/JRootPane.java b/jdk/src/share/classes/javax/swing/JRootPane.java index 0b554752f5c..542f7e672e3 100644 --- a/jdk/src/share/classes/javax/swing/JRootPane.java +++ b/jdk/src/share/classes/javax/swing/JRootPane.java @@ -199,6 +199,7 @@ import sun.security.action.GetBooleanAction; * @author David Kloba */ /// PENDING(klobad) Who should be opaque in this component? +@SuppressWarnings("serial") public class JRootPane extends JComponent implements Accessible { private static final String uiClassID = "RootPaneUI"; @@ -834,6 +835,7 @@ public class JRootPane extends JComponent implements Accessible { } } + @SuppressWarnings("serial") static class DefaultAction extends AbstractAction { JButton owner; JRootPane root; @@ -900,6 +902,7 @@ public class JRootPane extends JComponent implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class RootLayout implements LayoutManager2, Serializable { /** @@ -1065,6 +1068,7 @@ public class JRootPane extends JComponent implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJRootPane extends AccessibleJComponent { /** * Get the role of this object. diff --git a/jdk/src/share/classes/javax/swing/JSeparator.java b/jdk/src/share/classes/javax/swing/JSeparator.java index 1f4793a160f..25567371875 100644 --- a/jdk/src/share/classes/javax/swing/JSeparator.java +++ b/jdk/src/share/classes/javax/swing/JSeparator.java @@ -71,6 +71,7 @@ import java.io.IOException; * @author Georges Saab * @author Jeff Shapiro */ +@SuppressWarnings("serial") public class JSeparator extends JComponent implements SwingConstants, Accessible { /** @@ -279,6 +280,7 @@ public class JSeparator extends JComponent implements SwingConstants, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJSeparator extends AccessibleJComponent { /** diff --git a/jdk/src/share/classes/javax/swing/JToolTip.java b/jdk/src/share/classes/javax/swing/JToolTip.java index 0c85d1f1213..3879d23139f 100644 --- a/jdk/src/share/classes/javax/swing/JToolTip.java +++ b/jdk/src/share/classes/javax/swing/JToolTip.java @@ -66,6 +66,7 @@ import java.io.IOException; * @author Dave Moore * @author Rich Shiavi */ +@SuppressWarnings("serial") public class JToolTip extends JComponent implements Accessible { /** * @see #getUIClassID @@ -251,6 +252,7 @@ public class JToolTip extends JComponent implements Accessible { * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJToolTip extends AccessibleJComponent { /** diff --git a/jdk/src/share/classes/javax/swing/JTree.java b/jdk/src/share/classes/javax/swing/JTree.java index c5ca4b6dc70..f4d89e00424 100644 --- a/jdk/src/share/classes/javax/swing/JTree.java +++ b/jdk/src/share/classes/javax/swing/JTree.java @@ -142,6 +142,7 @@ import static sun.swing.SwingUtilities2.Section.*; * @author Ray Ryan * @author Scott Violet */ +@SuppressWarnings("serial") public class JTree extends JComponent implements Scrollable, Accessible { /** @@ -421,6 +422,7 @@ public class JTree extends JComponent implements Scrollable, Accessible */ private int expandRow = -1; + @SuppressWarnings("serial") private class TreeTimer extends Timer { public TreeTimer() { super(2000, null); @@ -3077,7 +3079,7 @@ public class JTree extends JComponent implements Scrollable, Accessible expandedStack = new Stack>(); - Vector values = (Vector)s.readObject(); + Vector values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); @@ -3159,7 +3161,7 @@ public class JTree extends JComponent implements Scrollable, Accessible */ private void unarchiveExpandedState(Object state) { if(state instanceof Vector) { - Vector paths = (Vector)state; + Vector paths = (Vector)state; for(int counter = paths.size() - 1; counter >= 0; counter--) { Boolean eState = (Boolean)paths.elementAt(counter--); @@ -3240,6 +3242,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected static class EmptySelectionModel extends DefaultTreeSelectionModel { @@ -3361,6 +3364,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class TreeSelectionRedirector implements Serializable, TreeSelectionListener { @@ -3661,7 +3665,7 @@ public class JTree extends JComponent implements Scrollable, Accessible { if(toRemove != null) { while(toRemove.hasMoreElements()) { - Enumeration descendants = getDescendantToggledPaths + Enumeration descendants = getDescendantToggledPaths (toRemove.nextElement()); if(descendants != null) { @@ -3861,6 +3865,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") public static class DynamicUtilTreeNode extends DefaultMutableTreeNode { /** * Does the this JTree have children? @@ -3882,7 +3887,7 @@ public class JTree extends JComponent implements Scrollable, Accessible public static void createChildren(DefaultMutableTreeNode parent, Object children) { if(children instanceof Vector) { - Vector childVector = (Vector)children; + Vector childVector = (Vector)children; for(int counter = 0, maxCounter = childVector.size(); counter < maxCounter; counter++) @@ -3891,8 +3896,8 @@ public class JTree extends JComponent implements Scrollable, Accessible childVector.elementAt(counter))); } else if(children instanceof Hashtable) { - Hashtable childHT = (Hashtable)children; - Enumeration keys = childHT.keys(); + Hashtable childHT = (Hashtable)children; + Enumeration keys = childHT.keys(); Object aKey; while(keys.hasMoreElements()) { @@ -4092,6 +4097,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. */ + @SuppressWarnings("serial") protected class AccessibleJTree extends AccessibleJComponent implements AccessibleSelection, TreeSelectionListener, TreeModelListener, TreeExpansionListener { @@ -5242,6 +5248,7 @@ public class JTree extends JComponent implements Scrollable, Accessible } } + @SuppressWarnings("deprecation") public boolean isFocusTraversable() { AccessibleContext ac = getCurrentAccessibleContext(); if (ac instanceof AccessibleComponent) { diff --git a/jdk/src/share/classes/javax/swing/JWindow.java b/jdk/src/share/classes/javax/swing/JWindow.java index 9ad82c76b2a..4a12d0205fb 100644 --- a/jdk/src/share/classes/javax/swing/JWindow.java +++ b/jdk/src/share/classes/javax/swing/JWindow.java @@ -89,6 +89,7 @@ import javax.accessibility.*; * * @author David Kloba */ +@SuppressWarnings("serial") public class JWindow extends Window implements Accessible, RootPaneContainer, TransferHandler.HasGetTransferHandler @@ -663,6 +664,7 @@ public class JWindow extends Window implements Accessible, * Java Accessibility API appropriate to window user-interface * elements. */ + @SuppressWarnings("serial") protected class AccessibleJWindow extends AccessibleAWTWindow { // everything is in the new parent, AccessibleAWTWindow } diff --git a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java index 0b98a7d71cd..4de2ac804ad 100644 --- a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java +++ b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java @@ -213,7 +213,7 @@ public class MenuSelectionManager { MenuElement menuElement; MenuElement subElements[]; MenuElement path[]; - Vector tmp; + Vector tmp; int selectionSize; p = event.getPoint(); @@ -242,7 +242,7 @@ public class MenuSelectionManager { screenX = p.x; screenY = p.y; - tmp = (Vector)selection.clone(); + tmp = (Vector)selection.clone(); selectionSize = tmp.size(); boolean success = false; for (i=selectionSize - 1;i >= 0 && success == false; i--) { @@ -377,7 +377,7 @@ public class MenuSelectionManager { int cWidth,cHeight; MenuElement menuElement; MenuElement subElements[]; - Vector tmp; + Vector tmp; int selectionSize; SwingUtilities.convertPointToScreen(p,source); @@ -385,7 +385,7 @@ public class MenuSelectionManager { screenX = p.x; screenY = p.y; - tmp = (Vector)selection.clone(); + tmp = (Vector)selection.clone(); selectionSize = tmp.size(); for(i=selectionSize - 1 ; i >= 0 ; i--) { menuElement = (MenuElement) tmp.elementAt(i); diff --git a/jdk/src/share/classes/javax/swing/Popup.java b/jdk/src/share/classes/javax/swing/Popup.java index 72f9f6af321..e59d6d8c186 100644 --- a/jdk/src/share/classes/javax/swing/Popup.java +++ b/jdk/src/share/classes/javax/swing/Popup.java @@ -98,6 +98,8 @@ public class Popup { * Makes the Popup visible. If the Popup is * currently visible, this has no effect. */ + + @SuppressWarnings("deprecation") public void show() { Component component = getComponent(); @@ -114,6 +116,8 @@ public class Popup { * on a disposed Popup, indeterminate * behavior will result. */ + + @SuppressWarnings("deprecation") public void hide() { Component component = getComponent(); diff --git a/jdk/src/share/classes/javax/swing/RepaintManager.java b/jdk/src/share/classes/javax/swing/RepaintManager.java index 59749fcad08..d1ba1f4c528 100644 --- a/jdk/src/share/classes/javax/swing/RepaintManager.java +++ b/jdk/src/share/classes/javax/swing/RepaintManager.java @@ -744,7 +744,6 @@ public class RepaintManager int localBoundsY = 0; int localBoundsH; int localBoundsW; - Enumeration keys; roots = new ArrayList(count); @@ -1073,9 +1072,9 @@ public class RepaintManager } } // Clear out the VolatileImages - Iterator gcs = volatileMap.keySet().iterator(); + Iterator gcs = volatileMap.keySet().iterator(); while (gcs.hasNext()) { - GraphicsConfiguration gc = (GraphicsConfiguration)gcs.next(); + GraphicsConfiguration gc = gcs.next(); VolatileImage image = volatileMap.get(gc); if (image.getWidth() > width || image.getHeight() > height) { image.flush(); diff --git a/jdk/src/share/classes/javax/swing/Timer.java b/jdk/src/share/classes/javax/swing/Timer.java index 5ac5a3f3579..e938a9d5b15 100644 --- a/jdk/src/share/classes/javax/swing/Timer.java +++ b/jdk/src/share/classes/javax/swing/Timer.java @@ -146,6 +146,7 @@ import javax.swing.event.EventListenerList; * * @author Dave Moore */ +@SuppressWarnings("serial") public class Timer implements Serializable { /* diff --git a/jdk/src/share/classes/javax/swing/border/AbstractBorder.java b/jdk/src/share/classes/javax/swing/border/AbstractBorder.java index 4b0d7c02f07..e1d19fe3ce1 100644 --- a/jdk/src/share/classes/javax/swing/border/AbstractBorder.java +++ b/jdk/src/share/classes/javax/swing/border/AbstractBorder.java @@ -46,6 +46,7 @@ import java.io.Serializable; * * @author David Kloba */ +@SuppressWarnings("serial") public abstract class AbstractBorder implements Border, Serializable { /** diff --git a/jdk/src/share/classes/javax/swing/border/CompoundBorder.java b/jdk/src/share/classes/javax/swing/border/CompoundBorder.java index 2809ecdd1cc..56371a47a6d 100644 --- a/jdk/src/share/classes/javax/swing/border/CompoundBorder.java +++ b/jdk/src/share/classes/javax/swing/border/CompoundBorder.java @@ -54,6 +54,7 @@ import java.beans.ConstructorProperties; * * @author David Kloba */ +@SuppressWarnings("serial") public class CompoundBorder extends AbstractBorder { protected Border outsideBorder; protected Border insideBorder; diff --git a/jdk/src/share/classes/javax/swing/border/EmptyBorder.java b/jdk/src/share/classes/javax/swing/border/EmptyBorder.java index 5767c53087a..a1b74c3b3f2 100644 --- a/jdk/src/share/classes/javax/swing/border/EmptyBorder.java +++ b/jdk/src/share/classes/javax/swing/border/EmptyBorder.java @@ -46,6 +46,7 @@ import java.beans.ConstructorProperties; * * @author David Kloba */ +@SuppressWarnings("serial") public class EmptyBorder extends AbstractBorder implements Serializable { protected int left, right, top, bottom; diff --git a/jdk/src/share/classes/javax/swing/border/MatteBorder.java b/jdk/src/share/classes/javax/swing/border/MatteBorder.java index 02ca200a05f..80d49a7ed87 100644 --- a/jdk/src/share/classes/javax/swing/border/MatteBorder.java +++ b/jdk/src/share/classes/javax/swing/border/MatteBorder.java @@ -46,6 +46,7 @@ import javax.swing.Icon; * * @author Amy Fowler */ +@SuppressWarnings("serial") public class MatteBorder extends EmptyBorder { protected Color color; diff --git a/jdk/src/share/classes/javax/swing/border/TitledBorder.java b/jdk/src/share/classes/javax/swing/border/TitledBorder.java index e20c40384ec..6b5fdf543ca 100644 --- a/jdk/src/share/classes/javax/swing/border/TitledBorder.java +++ b/jdk/src/share/classes/javax/swing/border/TitledBorder.java @@ -67,6 +67,7 @@ import javax.swing.plaf.basic.BasicHTML; * @author David Kloba * @author Amy Fowler */ +@SuppressWarnings("serial") public class TitledBorder extends AbstractBorder { protected String title; diff --git a/jdk/src/share/classes/javax/swing/event/AncestorEvent.java b/jdk/src/share/classes/javax/swing/event/AncestorEvent.java index 633bb9521ab..c166c19cecd 100644 --- a/jdk/src/share/classes/javax/swing/event/AncestorEvent.java +++ b/jdk/src/share/classes/javax/swing/event/AncestorEvent.java @@ -43,6 +43,7 @@ import javax.swing.*; * * @author Dave Moore */ +@SuppressWarnings("serial") public class AncestorEvent extends AWTEvent { /** * An ancestor-component was added to the hierarchy of diff --git a/jdk/src/share/classes/javax/swing/event/ChangeEvent.java b/jdk/src/share/classes/javax/swing/event/ChangeEvent.java index 459f1d0f333..7c351c4145b 100644 --- a/jdk/src/share/classes/javax/swing/event/ChangeEvent.java +++ b/jdk/src/share/classes/javax/swing/event/ChangeEvent.java @@ -42,6 +42,7 @@ import java.util.EventObject; * * @author Jeff Dinkins */ +@SuppressWarnings("serial") public class ChangeEvent extends EventObject { /** * Constructs a ChangeEvent object. diff --git a/jdk/src/share/classes/javax/swing/event/EventListenerList.java b/jdk/src/share/classes/javax/swing/event/EventListenerList.java index f0f9ff86d6b..237bf2067b2 100644 --- a/jdk/src/share/classes/javax/swing/event/EventListenerList.java +++ b/jdk/src/share/classes/javax/swing/event/EventListenerList.java @@ -96,6 +96,7 @@ import java.lang.reflect.Array; * @author Hans Muller * @author James Gosling */ +@SuppressWarnings("serial") public class EventListenerList implements Serializable { /* A null array to be shared by all empty listener lists*/ private final static Object[] NULL_ARRAY = new Object[0]; @@ -250,7 +251,7 @@ public class EventListenerList implements Serializable { // Save the non-null event listeners: for (int i = 0; i < lList.length; i+=2) { - Class t = (Class)lList[i]; + Class t = (Class)lList[i]; EventListener l = (EventListener)lList[i+1]; if ((l!=null) && (l instanceof Serializable)) { s.writeObject(t.getName()); diff --git a/jdk/src/share/classes/javax/swing/event/ListDataEvent.java b/jdk/src/share/classes/javax/swing/event/ListDataEvent.java index 91fafc283ac..3ccf01e1a45 100644 --- a/jdk/src/share/classes/javax/swing/event/ListDataEvent.java +++ b/jdk/src/share/classes/javax/swing/event/ListDataEvent.java @@ -42,6 +42,7 @@ import java.util.EventObject; * * @author Hans Muller */ +@SuppressWarnings("serial") public class ListDataEvent extends EventObject { /** Identifies one or more changes in the lists contents. */ diff --git a/jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java b/jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java index 0ce27d3aca4..905e76d4215 100644 --- a/jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java +++ b/jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java @@ -47,6 +47,7 @@ import java.awt.Component; * * @author Georges Saab */ +@SuppressWarnings("serial") public class MenuDragMouseEvent extends MouseEvent { private MenuElement path[]; private MenuSelectionManager manager; diff --git a/jdk/src/share/classes/javax/swing/event/MenuEvent.java b/jdk/src/share/classes/javax/swing/event/MenuEvent.java index 765e40d1937..a506199fdd4 100644 --- a/jdk/src/share/classes/javax/swing/event/MenuEvent.java +++ b/jdk/src/share/classes/javax/swing/event/MenuEvent.java @@ -44,6 +44,7 @@ import java.util.EventObject; * @author Georges Saab * @author David Karlton */ +@SuppressWarnings("serial") public class MenuEvent extends EventObject { /** * Constructs a MenuEvent object. diff --git a/jdk/src/share/classes/javax/swing/event/MenuKeyEvent.java b/jdk/src/share/classes/javax/swing/event/MenuKeyEvent.java index 144b767a2fe..c932873bd47 100644 --- a/jdk/src/share/classes/javax/swing/event/MenuKeyEvent.java +++ b/jdk/src/share/classes/javax/swing/event/MenuKeyEvent.java @@ -47,6 +47,7 @@ import java.awt.Component; * * @author Georges Saab */ +@SuppressWarnings("serial") public class MenuKeyEvent extends KeyEvent { private MenuElement path[]; private MenuSelectionManager manager; diff --git a/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java b/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java index 91dbc25a9e6..ee1b28ebdda 100644 --- a/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java +++ b/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java @@ -41,6 +41,7 @@ import java.util.EventObject; * * @author Arnaud Weber */ +@SuppressWarnings("serial") public class PopupMenuEvent extends EventObject { /** * Constructs a PopupMenuEvent object. diff --git a/jdk/src/share/classes/javax/swing/plaf/ComponentUI.java b/jdk/src/share/classes/javax/swing/plaf/ComponentUI.java index 20e45e050c9..5da213aa703 100644 --- a/jdk/src/share/classes/javax/swing/plaf/ComponentUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/ComponentUI.java @@ -244,6 +244,7 @@ public abstract class ComponentUI { * @see javax.swing.JComponent#contains * @see java.awt.Component#contains */ + @SuppressWarnings("deprecation") public boolean contains(JComponent c, int x, int y) { return c.inside(x, y); } diff --git a/jdk/src/share/classes/javax/swing/text/BadLocationException.java b/jdk/src/share/classes/javax/swing/text/BadLocationException.java index 6dbbb93fb55..783996a1c7c 100644 --- a/jdk/src/share/classes/javax/swing/text/BadLocationException.java +++ b/jdk/src/share/classes/javax/swing/text/BadLocationException.java @@ -39,6 +39,7 @@ package javax.swing.text; * * @author Timothy Prinzing */ +@SuppressWarnings("serial") public class BadLocationException extends Exception { /** diff --git a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java index a6d39a785d8..6420139b067 100644 --- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java @@ -61,6 +61,7 @@ import javax.swing.DefaultListSelectionModel; * * @author Scott Violet */ +@SuppressWarnings("serial") public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeSelectionModel { /** Property name for selectionMode. */ @@ -1073,7 +1074,7 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS * @deprecated As of JDK version 1.7 */ @Deprecated - protected void notifyPathChange(Vector changedPaths, + protected void notifyPathChange(Vector changedPaths, TreePath oldLeadSelection) { int cPathCount = changedPaths.size(); boolean[] newness = new boolean[cPathCount]; diff --git a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java index 99735e77340..81e351b099c 100644 --- a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java +++ b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java @@ -26,10 +26,13 @@ package sun.awt; import java.awt.AWTEvent; + import java.util.Collections; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Map; +import java.util.Set; + import sun.util.logging.PlatformLogger; /** @@ -81,7 +84,7 @@ public final class AWTAutoShutdown implements Runnable { * new event to appear in their event queue. * Access is synchronized on the main lock object. */ - private final HashSet busyThreadSet = new HashSet(7); + private final Set busyThreadSet = new HashSet<>(7); /** * Indicates whether the toolkit thread is waiting for a new native @@ -93,7 +96,7 @@ public final class AWTAutoShutdown implements Runnable { * This is a map between components and their peers. * we should work with in under activationLock&mainLock lock. */ - private final Map peerMap = new IdentityHashMap(); + private final Map peerMap = new IdentityHashMap<>(); /** * References the alive non-daemon thread that is currently used @@ -319,8 +322,10 @@ public final class AWTAutoShutdown implements Runnable { } } + @SuppressWarnings("serial") static AWTEvent getShutdownEvent() { - return new AWTEvent(getInstance(), 0) {}; + return new AWTEvent(getInstance(), 0) { + }; } /** diff --git a/jdk/src/share/classes/sun/awt/AppContext.java b/jdk/src/share/classes/sun/awt/AppContext.java index e4b60a283d3..b42078a3e37 100644 --- a/jdk/src/share/classes/sun/awt/AppContext.java +++ b/jdk/src/share/classes/sun/awt/AppContext.java @@ -171,7 +171,7 @@ public final class AppContext { * HashMap's potentially risky methods, such as clear(), elements(), * putAll(), etc. */ - private final HashMap table = new HashMap(); + private final Map table = new HashMap<>(); private final ThreadGroup threadGroup; @@ -198,8 +198,8 @@ public final class AppContext { // On the main Thread, we get the ThreadGroup, make a corresponding // AppContext, and instantiate the Java EventQueue. This way, legacy // code is unaffected by the move to multiple AppContext ability. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup(); ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); @@ -210,7 +210,7 @@ public final class AppContext { } mainAppContext = new AppContext(currentThreadGroup); numAppContexts = 1; - return mainAppContext; + return null; } }); } @@ -342,6 +342,16 @@ public final class AppContext { return appContext; } + /** + * Returns the main ("system") AppContext. + * + * @return the main AppContext + * @since 1.8 + */ + final static AppContext getMainAppContext() { + return mainAppContext; + } + private long DISPOSAL_TIMEOUT = 5000; // Default to 5-second timeout // for disposal of all Frames // (we wait for this time twice, @@ -399,8 +409,8 @@ public final class AppContext { log.finer("exception occured while disposing app context", t); } } - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported()) { SystemTray systemTray = SystemTray.getSystemTray(); @@ -523,7 +533,7 @@ public final class AppContext { } } - static final class CreateThreadAction implements PrivilegedAction { + static final class CreateThreadAction implements PrivilegedAction { private final AppContext appContext; private final Runnable runnable; @@ -532,7 +542,7 @@ public final class AppContext { runnable = r; } - public Object run() { + public Thread run() { Thread t = new Thread(appContext.getThreadGroup(), runnable); t.setContextClassLoader(appContext.getContextClassLoader()); t.setPriority(Thread.NORM_PRIORITY + 1); @@ -552,8 +562,8 @@ public final class AppContext { if (appContext != AppContext.getAppContext()) { // Create a thread that belongs to the thread group associated // with the AppContext and invokes EventQueue.postEvent. - PrivilegedAction action = new CreateThreadAction(appContext, r); - Thread thread = (Thread)AccessController.doPrivileged(action); + PrivilegedAction action = new CreateThreadAction(appContext, r); + Thread thread = AccessController.doPrivileged(action); thread.start(); } else { r.run(); diff --git a/jdk/src/share/classes/sun/awt/CausedFocusEvent.java b/jdk/src/share/classes/sun/awt/CausedFocusEvent.java index 805cbc8a4ab..9fa100aef58 100644 --- a/jdk/src/share/classes/sun/awt/CausedFocusEvent.java +++ b/jdk/src/share/classes/sun/awt/CausedFocusEvent.java @@ -35,6 +35,7 @@ import java.awt.Component; * CausedFocusEvent class or implicitly, by calling appropriate requestFocusXXX method with "cause" * parameter. The default cause is UNKNOWN. */ +@SuppressWarnings("serial") public class CausedFocusEvent extends FocusEvent { public enum Cause { UNKNOWN, diff --git a/jdk/src/share/classes/sun/awt/DebugSettings.java b/jdk/src/share/classes/sun/awt/DebugSettings.java index 4edf43bef98..9ee9d94d7ed 100644 --- a/jdk/src/share/classes/sun/awt/DebugSettings.java +++ b/jdk/src/share/classes/sun/awt/DebugSettings.java @@ -87,9 +87,9 @@ final class DebugSettings { }; /* global instance of the settings object */ - private static DebugSettings instance = null; + private static DebugSettings instance = null; - private Properties props = new Properties(); + private Properties props = new Properties(); static void init() { if (instance != null) { @@ -102,12 +102,13 @@ final class DebugSettings { } private DebugSettings() { - new java.security.PrivilegedAction() { - public Object run() { - loadProperties(); - return null; - } - }.run(); + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { + loadProperties(); + return null; + } + }); } /* @@ -117,15 +118,14 @@ final class DebugSettings { private synchronized void loadProperties() { // setup initial properties java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() - { - public Object run() { - loadDefaultProperties(); - loadFileProperties(); - loadSystemProperties(); - return null; - } - }); + new java.security.PrivilegedAction() { + public Void run() { + loadDefaultProperties(); + loadFileProperties(); + loadSystemProperties(); + return null; + } + }); // echo the initial property settings to stdout if (log.isLoggable(PlatformLogger.FINE)) { @@ -134,12 +134,9 @@ final class DebugSettings { } public String toString() { - Enumeration enum_ = props.propertyNames(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); PrintStream pout = new PrintStream(bout); - - while (enum_.hasMoreElements()) { - String key = (String)enum_.nextElement(); + for (String key : props.stringPropertyNames()) { String value = props.getProperty(key, ""); pout.println(key + " = " + value); } @@ -198,9 +195,7 @@ final class DebugSettings { private void loadSystemProperties() { // override file properties with system properties Properties sysProps = System.getProperties(); - Enumeration enum_ = sysProps.propertyNames(); - while ( enum_.hasMoreElements() ) { - String key = (String)enum_.nextElement(); + for (String key : sysProps.stringPropertyNames()) { String value = sysProps.getProperty(key,""); // copy any "awtdebug" properties over if ( key.startsWith(PREFIX) ) { @@ -244,17 +239,14 @@ final class DebugSettings { return value; } - public synchronized Enumeration getPropertyNames() { - Vector propNames = new Vector(); - Enumeration enum_ = props.propertyNames(); - + private synchronized List getPropertyNames() { + List propNames = new LinkedList<>(); // remove global prefix from property names - while ( enum_.hasMoreElements() ) { - String propName = (String)enum_.nextElement(); + for (String propName : props.stringPropertyNames()) { propName = propName.substring(PREFIX.length()+1); - propNames.addElement(propName); + propNames.add(propName); } - return propNames.elements(); + return propNames; } private void println(Object object) { @@ -279,13 +271,11 @@ final class DebugSettings { // // Filter out file/line ctrace properties from debug settings // - Vector traces = new Vector(); - Enumeration enum_ = getPropertyNames(); + List traces = new LinkedList<>(); - while ( enum_.hasMoreElements() ) { - String key = (String)enum_.nextElement(); - if ( key.startsWith(PROP_CTRACE) && key.length() > PROP_CTRACE_LEN ) { - traces.addElement(key); + for (String key : getPropertyNames()) { + if (key.startsWith(PROP_CTRACE) && key.length() > PROP_CTRACE_LEN) { + traces.add(key); } } @@ -295,15 +285,12 @@ final class DebugSettings { // // Setup the trace points // - Enumeration enumTraces = traces.elements(); - - while ( enumTraces.hasMoreElements() ) { - String key = (String)enumTraces.nextElement(); - String trace = key.substring(PROP_CTRACE_LEN+1); + for (String key : traces) { + String trace = key.substring(PROP_CTRACE_LEN+1); String filespec; String linespec; - int delim= trace.indexOf('@'); - boolean enabled; + int delim= trace.indexOf('@'); + boolean enabled; // parse out the filename and linenumber from the property name filespec = delim != -1 ? trace.substring(0, delim) : trace; diff --git a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java index 344fae1d0e0..4cbf8919d16 100644 --- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java +++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java @@ -180,6 +180,7 @@ public abstract class EmbeddedFrame extends Frame * reference to our EmbeddedFrame forever if the Frame is no longer in use, so we * add listeners in show() and remove them in hide(). */ + @SuppressWarnings("deprecation") public void show() { if (appletKFM != null) { addTraversingOutListeners(appletKFM); @@ -193,6 +194,7 @@ public abstract class EmbeddedFrame extends Frame * reference to our EmbeddedFrame forever if the Frame is no longer in use, so we * add listeners in show() and remove them in hide(). */ + @SuppressWarnings("deprecation") public void hide() { if (appletKFM != null) { removeTraversingOutListeners(appletKFM); @@ -212,8 +214,8 @@ public abstract class EmbeddedFrame extends Frame // belongs to. That's why we can't use public methods to find current focus cycle // root. Instead, we access KFM's private field directly. if (currentCycleRoot == null) { - currentCycleRoot = (Field)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + currentCycleRoot = AccessController.doPrivileged(new PrivilegedAction() { + public Field run() { try { Field unaccessibleRoot = KeyboardFocusManager.class. getDeclaredField("currentFocusCycleRoot"); @@ -257,7 +259,7 @@ public abstract class EmbeddedFrame extends Frame } AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e); - Set toTest; + Set toTest; Component currentFocused = e.getComponent(); toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); @@ -357,6 +359,7 @@ public abstract class EmbeddedFrame extends Frame return true; } + @SuppressWarnings("deprecation") public void addNotify() { synchronized (getTreeLock()) { if (getPeer() == null) { @@ -367,6 +370,7 @@ public abstract class EmbeddedFrame extends Frame } // These three functions consitute RFE 4100710. Do not remove. + @SuppressWarnings("deprecation") public void setCursorAllowed(boolean isCursorAllowed) { this.isCursorAllowed = isCursorAllowed; getPeer().updateCursorImmediately(); @@ -380,27 +384,28 @@ public abstract class EmbeddedFrame extends Frame : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } - protected void setPeer(final ComponentPeer p){ + @SuppressWarnings("deprecation") + protected void setPeer(final ComponentPeer p){ if (fieldPeer == null) { - fieldPeer = (Field)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - try { - Field lnkPeer = Component.class.getDeclaredField("peer"); - if (lnkPeer != null) { - lnkPeer.setAccessible(true); - } - return lnkPeer; - } catch (NoSuchFieldException e) { - assert false; - } catch (SecurityException e) { - assert false; + fieldPeer = AccessController.doPrivileged(new PrivilegedAction() { + public Field run() { + try { + Field lnkPeer = Component.class.getDeclaredField("peer"); + if (lnkPeer != null) { + lnkPeer.setAccessible(true); } - return null; - }//run - }); + return lnkPeer; + } catch (NoSuchFieldException e) { + assert false; + } catch (SecurityException e) { + assert false; + } + return null; + }//run + }); } try{ - if (fieldPeer !=null){ + if (fieldPeer != null){ fieldPeer.set(EmbeddedFrame.this, p); } } catch (IllegalAccessException e) { @@ -507,6 +512,7 @@ public abstract class EmbeddedFrame extends Frame * @see #getBoundsPrivate * @since 1.5 */ + @SuppressWarnings("deprecation") protected void setBoundsPrivate(int x, int y, int width, int height) { final FramePeer peer = (FramePeer)getPeer(); if (peer != null) { @@ -538,6 +544,7 @@ public abstract class EmbeddedFrame extends Frame * @see #setBoundsPrivate * @since 1.6 */ + @SuppressWarnings("deprecation") protected Rectangle getBoundsPrivate() { final FramePeer peer = (FramePeer)getPeer(); if (peer != null) { diff --git a/jdk/src/share/classes/sun/awt/EventListenerAggregate.java b/jdk/src/share/classes/sun/awt/EventListenerAggregate.java index 26a86c90e73..b07c30ee97b 100644 --- a/jdk/src/share/classes/sun/awt/EventListenerAggregate.java +++ b/jdk/src/share/classes/sun/awt/EventListenerAggregate.java @@ -53,20 +53,15 @@ public class EventListenerAggregate { * @throws ClassCastException if listenerClass is not * assignable to java.util.EventListener */ - public EventListenerAggregate(Class listenerClass) { + public EventListenerAggregate(Class listenerClass) { if (listenerClass == null) { throw new NullPointerException("listener class is null"); } - if (!EventListener.class.isAssignableFrom(listenerClass)) { - throw new ClassCastException("listener class " + listenerClass + - " is not assignable to EventListener"); - } - listenerList = (EventListener[])Array.newInstance(listenerClass, 0); } - private Class getListenerClass() { + private Class getListenerClass() { return listenerList.getClass().getComponentType(); } @@ -80,7 +75,7 @@ public class EventListenerAggregate { * in the constructor */ public synchronized void add(EventListener listener) { - Class listenerClass = getListenerClass(); + Class listenerClass = getListenerClass(); if (!listenerClass.isInstance(listener)) { // null is not an instance of any class throw new ClassCastException("listener " + listener + " is not " + @@ -107,7 +102,7 @@ public class EventListenerAggregate { * in the constructor */ public synchronized boolean remove(EventListener listener) { - Class listenerClass = getListenerClass(); + Class listenerClass = getListenerClass(); if (!listenerClass.isInstance(listener)) { // null is not an instance of any class throw new ClassCastException("listener " + listener + " is not " + @@ -155,7 +150,7 @@ public class EventListenerAggregate { * array if there are no listeners) */ public synchronized EventListener[] getListenersCopy() { - return (listenerList.length == 0) ? listenerList : (EventListener[])listenerList.clone(); + return (listenerList.length == 0) ? listenerList : listenerList.clone(); } /** diff --git a/jdk/src/share/classes/sun/awt/FocusingTextField.java b/jdk/src/share/classes/sun/awt/FocusingTextField.java deleted file mode 100644 index efd65a80953..00000000000 --- a/jdk/src/share/classes/sun/awt/FocusingTextField.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1995, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -import java.awt.*; - -/** - * FocusingTextField: a subclass of java.awt.TextField that handles moving the - * input focus from field to field, as when the user hits 'return.' - * - * @author Herb Jellinek - */ - -public class FocusingTextField extends TextField { - - /** The field to move to on 'return' - can be null. */ - TextField next; - - /** If true, select the contents of the field when it gets the focus. */ - boolean willSelect; - - /** - * Create a FocusingTextField. - * @param cols number of columns of text. - */ - public FocusingTextField(int cols) { - super("", cols); - } - - /** - * Create a FocusingTextField. - * @param cols number of columns of text. - * @param willSelect if true, will select all contents of field when - * focus is gained. - */ - public FocusingTextField(int cols, boolean willSelect) { - this(cols); - this.willSelect = willSelect; - } - - public void setWillSelect(boolean will) { - willSelect = will; - } - - public boolean getWillSelect() { - return willSelect; - } - - /** - * Call this to set the next field to receive the input focus. - * @param next the next TextField in order - can be null. - */ - public void setNextField(TextField next) { - this.next = next; - } - - /** - * We got the focus. If willSelect is true, select everything. - */ - public boolean gotFocus(Event e, Object arg) { - if (willSelect) { - select(0, getText().length()); - } - return true; - } - - /** - * We lost the focus. If willSelect is true, deselect everything. - */ - public boolean lostFocus(Event e, Object arg) { - if (willSelect) { - select(0, 0); - } - return true; - } - - /** - * Pass the focus to the next guy, if any. - */ - public void nextFocus() { - if (next != null) { - next.requestFocus(); - } - super.nextFocus(); - } -} diff --git a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java index 8dc8a19c7e2..11926233ede 100644 --- a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java +++ b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java @@ -396,6 +396,7 @@ public class HeadlessToolkit extends Toolkit /* * Fonts */ + @SuppressWarnings("deprecation") public FontPeer getFontPeer(String name, int style) { if (componentFactory != null) { return componentFactory.getFontPeer(name, style); @@ -403,10 +404,12 @@ public class HeadlessToolkit extends Toolkit return null; } + @SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return tk.getFontMetrics(font); } + @SuppressWarnings("deprecation") public String[] getFontList() { return tk.getFontList(); } diff --git a/jdk/src/share/classes/sun/awt/HorizBagLayout.java b/jdk/src/share/classes/sun/awt/HorizBagLayout.java deleted file mode 100644 index 364d00b14d0..00000000000 --- a/jdk/src/share/classes/sun/awt/HorizBagLayout.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 1995, 2007, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -import java.awt.*; - -/** - * A horizontal 'bag' of Components. Allocates space for each Component - * from left to right. - * - * @author Herb Jellinek - */ -public class HorizBagLayout implements LayoutManager { - - int hgap; - - /** - * Constructs a new HorizBagLayout. - */ - public HorizBagLayout() { - this(0); - } - - /** - * Constructs a HorizBagLayout with the specified gaps. - * @param hgap the horizontal gap - */ - public HorizBagLayout(int hgap) { - this.hgap = hgap; - } - - /** - * Adds the specified named component to the layout. - * @param name the String name - * @param comp the component to be added - */ - public void addLayoutComponent(String name, Component comp) { - } - - /** - * Removes the specified component from the layout. - * @param comp the component to be removed - */ - public void removeLayoutComponent(Component comp) { - } - - /** - * Returns the minimum dimensions needed to lay out the components - * contained in the specified target container. - * @param target the Container on which to do the layout - * @see Container - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container target) { - Dimension dim = new Dimension(); - - for (int i = 0; i < target.countComponents(); i++) { - Component comp = target.getComponent(i); - if (comp.isVisible()) { - Dimension d = comp.minimumSize(); - dim.width += d.width + hgap; - dim.height = Math.max(d.height, dim.height); - } - } - - Insets insets = target.insets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - - /** - * Returns the preferred dimensions for this layout given the components - * in the specified target container. - * @param target the component which needs to be laid out - * @see Container - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - Dimension dim = new Dimension(); - - for (int i = 0; i < target.countComponents(); i++) { - Component comp = target.getComponent(i); - if (comp.isVisible()) { - Dimension d = comp.preferredSize(); - dim.width += d.width + hgap; - dim.height = Math.max(dim.height, d.height); - } - } - - Insets insets = target.insets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - - /** - * Lays out the specified container. This method will actually reshape the - * components in the specified target container in order to satisfy the - * constraints of the HorizBagLayout object. - * @param target the component being laid out - * @see Container - */ - public void layoutContainer(Container target) { - Insets insets = target.insets(); - int top = insets.top; - int bottom = target.size().height - insets.bottom; - int left = insets.left; - int right = target.size().width - insets.right; - - for (int i = 0; i < target.countComponents(); i++) { - Component comp = target.getComponent(i); - if (comp.isVisible()) { - int compWidth = comp.size().width; - comp.resize(compWidth, bottom - top); - Dimension d = comp.preferredSize(); - comp.reshape(left, top, d.width, bottom - top); - left += d.width + hgap; - } - } - } - - /** - * Returns the String representation of this HorizBagLayout's values. - */ - public String toString() { - return getClass().getName() + "[hgap=" + hgap + "]"; - } -} diff --git a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java index dd9ae67e931..775a7677582 100644 --- a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java +++ b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java @@ -80,6 +80,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag * 1) accepts focus on click (in general) * 2) may be a focus owner (in particular) */ + @SuppressWarnings("deprecation") public static boolean shouldFocusOnClick(Component component) { boolean acceptFocusOnClick = false; @@ -110,6 +111,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag /* * Posts proper lost/gain focus events to the event queue. */ + @SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, @@ -119,7 +121,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { - lightweightChild = (Component)target; + lightweightChild = target; } Component currentOwner = currentFocusOwner; diff --git a/jdk/src/share/classes/sun/awt/ModalityEvent.java b/jdk/src/share/classes/sun/awt/ModalityEvent.java index 1c4446f0fa0..e3fbff6f1b9 100644 --- a/jdk/src/share/classes/sun/awt/ModalityEvent.java +++ b/jdk/src/share/classes/sun/awt/ModalityEvent.java @@ -30,6 +30,7 @@ import java.awt.*; /** * Event object describing changes in AWT modality */ +@SuppressWarnings("serial") public class ModalityEvent extends AWTEvent implements ActiveEvent { public static final int MODALITY_PUSHED = 1300; diff --git a/jdk/src/share/classes/sun/awt/OrientableFlowLayout.java b/jdk/src/share/classes/sun/awt/OrientableFlowLayout.java deleted file mode 100644 index 4b0a2112bf5..00000000000 --- a/jdk/src/share/classes/sun/awt/OrientableFlowLayout.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) 1996, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package sun.awt; - -import java.awt.*; - -/** - * Extends the FlowLayout class to support both vertical and horizontal - * layout of components. Orientation can be changed dynamically after - * creation by calling either of the methods @method orientHorizontally or - * @method orientVertically. Separate values for alignment, vertical gap, - * and horizontal gap can be specified for horizontal and vertical - * orientation. - * - * @author Terry Cline - */ -public class OrientableFlowLayout extends FlowLayout { - /** - * The horizontal orientation constant. - */ - public static final int HORIZONTAL = 0; - - /** - * The vertical orientation constant. - */ - public static final int VERTICAL = 1; - - /** - * The top vertical alignment constant. - */ - public static final int TOP = 0; - - /** - * The bottom vertical alignment constant. - */ - public static final int BOTTOM = 2; // CENTER == 1 - - int orientation; - int vAlign; - int vHGap; - int vVGap; - - /** - * Constructs a new flow layout with a horizontal orientation and - * centered alignment. - */ - public OrientableFlowLayout() { - this(HORIZONTAL, CENTER, CENTER, 5, 5, 5, 5); - } - - /** - * Constructs a new flow layout with the specified orientation and - * a centered alignment. - * - * @param orientation the orientation, one of HORIZONTAL or VERTICAL. - */ - public OrientableFlowLayout(int orientation) { - this(orientation, CENTER, CENTER, 5, 5, 5, 5); - } - - /** - * Constructs a new flow layout with the specified orientation and - * alignment. - * - * @param orientation the orientation, one of HORIZONTAL or VERTICAL. - * @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT. - * @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM. - */ - public OrientableFlowLayout(int orientation, int hAlign, int vAlign) { - this(orientation, hAlign, vAlign, 5, 5, 5, 5); - } - - /** - * Constructs a new flow layout with the specified orientation, - * alignment, and gap values. - * - * @param orientation the orientation, one of HORIZONTAL or VERTICAL. - * @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT. - * @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM. - * @param hHGap the horizontal gap between components in HORIZONTAL. - * @param hVGap the vertical gap between components in HORIZONTAL. - * @param vHGap the horizontal gap between components in VERTICAL. - * @param vVGap the vertical gap between components in VERTICAL. - */ - public OrientableFlowLayout(int orientation, int hAlign, int vAlign, int hHGap, int hVGap, int vHGap, int vVGap) { - super(hAlign, hHGap, hVGap); - this.orientation = orientation; - this.vAlign = vAlign; - this.vHGap = vHGap; - this.vVGap = vVGap; - } - - /** - * Set the layout's current orientation to horizontal. - */ - public synchronized void orientHorizontally() { - orientation = HORIZONTAL; - } - - /** - * Set the layout's current orientation to vertical. - */ - public synchronized void orientVertically() { - orientation = VERTICAL; - } - - /** - * Returns the preferred dimensions for this layout given the - * components in the specified target container. - * - * @param target the component which needs to be laid out. - * @see Container - * @see FlowLayout - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - if (orientation == HORIZONTAL) { - return super.preferredLayoutSize(target); - } - else { - Dimension dim = new Dimension(0, 0); - - int n = target.countComponents(); - for (int i = 0; i < n; i++) { - Component c = target.getComponent(i); - if (c.isVisible()) { - Dimension cDim = c.preferredSize(); - dim.width = Math.max(dim.width, cDim.width); - if (i > 0) { - dim.height += vVGap; - } - dim.height += cDim.height; - } - } - - Insets insets = target.insets();; - dim.width += insets.left + insets.right + vHGap*2; - dim.height += insets.top + insets.bottom + vVGap*2; - - return dim; - } - } - - /** - * Returns the minimum dimensions needed to layout the components - * contained in the specified target container. - * - * @param target the component which needs to be laid out. - * @see #preferredLayoutSize. - */ - public Dimension minimumLayoutSize(Container target) { - if (orientation == HORIZONTAL) { - return super.minimumLayoutSize(target); - } - else { - Dimension dim = new Dimension(0, 0); - - int n = target.countComponents(); - for (int i = 0; i < n; i++) { - Component c = target.getComponent(i); - if (c.isVisible()) { - Dimension cDim = c.minimumSize(); - dim.width = Math.max(dim.width, cDim.width); - if (i > 0) { - dim.height += vVGap; - } - dim.height += cDim.height; - } - } - - Insets insets = target.insets(); - dim.width += insets.left + insets.right + vHGap*2; - dim.height += insets.top + insets.bottom + vVGap*2; - - return dim; - } - } - - /** - * Lays out the container. This method will reshape the - * components in the target to satisfy the constraints of the - * layout. - * - * @param target the specified component being laid out. - * @see Container. - */ - public void layoutContainer(Container target) { - if (orientation == HORIZONTAL) { - super.layoutContainer(target); - } - else { - Insets insets = target.insets(); - Dimension targetDim = target.size(); - int maxHeight = targetDim.height - (insets.top + insets.bottom + vVGap*2); - int x = insets.left + vHGap; - int y = 0; - int colWidth = 0; - int start = 0; - - int n = target.countComponents(); - for (int i = 0; i < n; i++) { - Component c = target.getComponent(i); - if (c.isVisible()) { - Dimension cDim = c.preferredSize(); - c.resize(cDim.width, cDim.height); - - if ((y == 0) || ((y + cDim.height) <= maxHeight)) { - if (y > 0) { - y += vVGap; - } - y += cDim.height; - colWidth = Math.max(colWidth, cDim.width); - } - else { - moveComponents(target, - x, - insets.top + vVGap, - colWidth, - maxHeight - y, - start, - i); - x += vHGap + colWidth; - y = cDim.width; - colWidth = cDim.width; - start = i; - } - } - } - - moveComponents(target, - x, - insets.top + vVGap, - colWidth, - maxHeight - y, - start, - n); - } - } - - /** - * Aligns the components vertically if there is any slack. - * - * @param target the container whose components need to be moved. - * @param x the x coordinate. - * @param y the y coordinate. - * @param width the width available. - * @param height the height available. - * @param colStart the beginning of the column. - * @param colEnd the end of the column. - */ - private void moveComponents(Container target, int x, int y, int width, int height, int colStart, int colEnd) { - switch (vAlign) { - case TOP: - break; - case CENTER: - y += height/2; - break; - case BOTTOM: - y += height; - } - - for (int i = colStart; i < colEnd; i++) { - Component c = target.getComponent(i); - Dimension cDim = c.size(); - if (c.isVisible()) { - c.move(x + (width - cDim.width)/2, y); - y += vVGap + cDim.height; - } - } - } - - /** - * Returns the String representation of this layout's values. - */ - public String toString() { - String str = ""; - switch (orientation) { - case HORIZONTAL: - str = "orientation=horizontal, "; - break; - case VERTICAL: - str = "orientation=vertical, "; - break; - } - - return getClass().getName() + "[" + str + super.toString() + "]"; - } -} diff --git a/jdk/src/share/classes/sun/awt/PaintEventDispatcher.java b/jdk/src/share/classes/sun/awt/PaintEventDispatcher.java index c6b3346ea09..248dbdb87ca 100644 --- a/jdk/src/share/classes/sun/awt/PaintEventDispatcher.java +++ b/jdk/src/share/classes/sun/awt/PaintEventDispatcher.java @@ -77,7 +77,7 @@ public class PaintEventDispatcher { public PaintEvent createPaintEvent(Component target, int x, int y, int w, int h) { - return new PaintEvent((Component)target, PaintEvent.PAINT, + return new PaintEvent(target, PaintEvent.PAINT, new Rectangle(x, y, w, h)); } diff --git a/jdk/src/share/classes/sun/awt/PeerEvent.java b/jdk/src/share/classes/sun/awt/PeerEvent.java index 5e63e138874..8e5a65af2c9 100644 --- a/jdk/src/share/classes/sun/awt/PeerEvent.java +++ b/jdk/src/share/classes/sun/awt/PeerEvent.java @@ -27,7 +27,9 @@ package sun.awt; import java.awt.event.InvocationEvent; +@SuppressWarnings("serial") public class PeerEvent extends InvocationEvent { + public static final long PRIORITY_EVENT = 0x01; public static final long ULTIMATE_PRIORITY_EVENT = 0x02; public static final long LOW_PRIORITY_EVENT = 0x04; diff --git a/jdk/src/share/classes/sun/awt/SunDisplayChanger.java b/jdk/src/share/classes/sun/awt/SunDisplayChanger.java index 80dd0db1886..c1ef6f3c61b 100644 --- a/jdk/src/share/classes/sun/awt/SunDisplayChanger.java +++ b/jdk/src/share/classes/sun/awt/SunDisplayChanger.java @@ -28,9 +28,10 @@ package sun.awt; import java.awt.IllegalComponentStateException; import java.util.Collections; import java.util.Iterator; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.HashMap; import java.util.WeakHashMap; import sun.util.logging.PlatformLogger; @@ -54,12 +55,14 @@ import sun.util.logging.PlatformLogger; * screen to another on a system equipped with multiple displays. */ public class SunDisplayChanger { + private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.multiscreen.SunDisplayChanger"); - // Create a new synchronizedMap with initial capacity of one listener. + // Create a new synchronized map with initial capacity of one listener. // It is asserted that the most common case is to have one GraphicsDevice // and one top-level Window. - private Map listeners = Collections.synchronizedMap(new WeakHashMap(1)); + private Map listeners = + Collections.synchronizedMap(new WeakHashMap(1)); public SunDisplayChanger() {} @@ -113,18 +116,15 @@ public class SunDisplayChanger { // synchronization provides no protection against modifying the listener // list while in the middle of iterating over it. -bchristi 7/10/2001 - HashMap listClone; - Set cloneSet; + Set cloneSet; synchronized(listeners) { - listClone = new HashMap(listeners); + cloneSet = new HashSet(listeners.keySet()); } - cloneSet = listClone.keySet(); - Iterator itr = cloneSet.iterator(); + Iterator itr = cloneSet.iterator(); while (itr.hasNext()) { - DisplayChangedListener current = - (DisplayChangedListener) itr.next(); + DisplayChangedListener current = itr.next(); try { if (log.isLoggable(PlatformLogger.FINEST)) { log.finest("displayChanged for listener: " + current); @@ -160,17 +160,14 @@ public class SunDisplayChanger { // synchronization provides no protection against modifying the listener // list while in the middle of iterating over it. -bchristi 7/10/2001 - HashMap listClone; - Set cloneSet; + Set cloneSet; synchronized (listeners) { - listClone = new HashMap(listeners); + cloneSet = new HashSet(listeners.keySet()); } - cloneSet = listClone.keySet(); - Iterator itr = cloneSet.iterator(); + Iterator itr = cloneSet.iterator(); while (itr.hasNext()) { - DisplayChangedListener current = - (DisplayChangedListener) itr.next(); + DisplayChangedListener current = itr.next(); try { if (log.isLoggable(PlatformLogger.FINEST)) { log.finest("paletteChanged for listener: " + current); diff --git a/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java b/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java index 1e49bd7398f..69d21084542 100644 --- a/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java +++ b/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java @@ -47,6 +47,7 @@ public abstract class SunGraphicsCallback { g.clipRect(0, 0, bounds.width, bounds.height); } + @SuppressWarnings("deprecation") public final void runOneComponent(Component comp, Rectangle bounds, Graphics g, Shape clip, int weightFlags) { diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java index e3e6ff36c37..95ff33a66f3 100644 --- a/jdk/src/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/share/classes/sun/awt/SunToolkit.java @@ -101,30 +101,28 @@ public abstract class SunToolkit extends Toolkit */ public final static int MAX_BUTTONS_SUPPORTED = 20; + private static void initEQ(AppContext appContext) { + EventQueue eventQueue; + + String eqName = System.getProperty("AWT.EventQueueClass", + "java.awt.EventQueue"); + + try { + eventQueue = (EventQueue)Class.forName(eqName).newInstance(); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Failed loading " + eqName + ": " + e); + eventQueue = new EventQueue(); + } + appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); + + PostEventQueue postEventQueue = new PostEventQueue(eventQueue); + appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); + } + public SunToolkit() { - Runnable initEQ = new Runnable() { - public void run () { - EventQueue eventQueue; - - String eqName = System.getProperty("AWT.EventQueueClass", - "java.awt.EventQueue"); - - try { - eventQueue = (EventQueue)Class.forName(eqName).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - System.err.println("Failed loading " + eqName + ": " + e); - eventQueue = new EventQueue(); - } - AppContext appContext = AppContext.getAppContext(); - appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); - - PostEventQueue postEventQueue = new PostEventQueue(eventQueue); - appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); - } - }; - - initEQ.run(); + // 7122796: Always create an EQ for the main AppContext + initEQ(AppContext.getMainAppContext()); } public boolean useBufferPerWindow() { @@ -197,6 +195,7 @@ public abstract class SunToolkit extends Toolkit public abstract boolean isTraySupported(); + @SuppressWarnings("deprecation") public abstract FontPeer getFontPeer(String name, int style); public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen) @@ -288,24 +287,12 @@ public abstract class SunToolkit extends Toolkit // return correct values AppContext appContext = new AppContext(threadGroup); - EventQueue eventQueue; - String eqName = System.getProperty("AWT.EventQueueClass", - "java.awt.EventQueue"); - try { - eventQueue = (EventQueue)Class.forName(eqName).newInstance(); - } catch (Exception e) { - System.err.println("Failed loading " + eqName + ": " + e); - eventQueue = new EventQueue(); - } - appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); - - PostEventQueue postEventQueue = new PostEventQueue(eventQueue); - appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); + initEQ(appContext); return appContext; } - public static Field getField(final Class klass, final String fieldName) { + public static Field getField(final Class klass, final String fieldName) { return AccessController.doPrivileged(new PrivilegedAction() { public Field run() { try { @@ -325,8 +312,8 @@ public abstract class SunToolkit extends Toolkit static void wakeupEventQueue(EventQueue q, boolean isShutdown){ if (wakeupMethod == null){ - wakeupMethod = (Method)AccessController.doPrivileged(new PrivilegedAction(){ - public Object run(){ + wakeupMethod = AccessController.doPrivileged(new PrivilegedAction() { + public Method run() { try { Method method = EventQueue.class.getDeclaredMethod("wakeup",new Class [] {Boolean.TYPE} ); if (method != null) { @@ -386,8 +373,8 @@ public abstract class SunToolkit extends Toolkit // Maps from non-Component/MenuComponent to AppContext. // WeakHashMap - private static final Map appContextMap = - Collections.synchronizedMap(new WeakHashMap()); + private static final Map appContextMap = + Collections.synchronizedMap(new WeakHashMap()); /** * Sets the appContext field of target. If target is not a Component or @@ -437,7 +424,7 @@ public abstract class SunToolkit extends Toolkit if (context == null) { // target is not a Component/MenuComponent, try the // appContextMap. - context = (AppContext)appContextMap.get(target); + context = appContextMap.get(target); } return context; } @@ -519,9 +506,9 @@ public abstract class SunToolkit extends Toolkit private static FocusTraversalPolicy createLayoutPolicy() { FocusTraversalPolicy policy = null; try { - Class layoutPolicyClass = + Class layoutPolicyClass = Class.forName("javax.swing.LayoutFocusTraversalPolicy"); - policy = (FocusTraversalPolicy) layoutPolicyClass.newInstance(); + policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance(); } catch (ClassNotFoundException e) { assert false; @@ -642,11 +629,13 @@ public abstract class SunToolkit extends Toolkit * Fixed 5064013: the InvocationEvent time should be equals * the time of the ActionEvent */ + @SuppressWarnings("serial") public static void executeOnEventHandlerThread(Object target, Runnable runnable, final long when) { - executeOnEventHandlerThread(new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT){ - public long getWhen(){ + executeOnEventHandlerThread( + new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT) { + public long getWhen() { return when; } }); @@ -727,10 +716,12 @@ public abstract class SunToolkit extends Toolkit protected abstract int getScreenWidth(); protected abstract int getScreenHeight(); + @SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); } + @SuppressWarnings("deprecation") public String[] getFontList() { String[] hardwiredFontList = { Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED, @@ -1156,10 +1147,10 @@ public abstract class SunToolkit extends Toolkit public static Locale getStartupLocale() { if (startupLocale == null) { String language, region, country, variant; - language = (String) AccessController.doPrivileged( + language = AccessController.doPrivileged( new GetPropertyAction("user.language", "en")); // for compatibility, check for old user.region property - region = (String) AccessController.doPrivileged( + region = AccessController.doPrivileged( new GetPropertyAction("user.region")); if (region != null) { // region can be of form country, country_variant, or _variant @@ -1172,9 +1163,9 @@ public abstract class SunToolkit extends Toolkit variant = ""; } } else { - country = (String) AccessController.doPrivileged( + country = AccessController.doPrivileged( new GetPropertyAction("user.country", "")); - variant = (String) AccessController.doPrivileged( + variant = AccessController.doPrivileged( new GetPropertyAction("user.variant", "")); } startupLocale = new Locale(language, country, variant); @@ -1254,7 +1245,7 @@ public abstract class SunToolkit extends Toolkit * @return true, if XEmbed is needed, false otherwise */ public static boolean needsXEmbed() { - String noxembed = (String) AccessController. + String noxembed = AccessController. doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false")); if ("true".equals(noxembed)) { return false; @@ -1466,7 +1457,7 @@ public abstract class SunToolkit extends Toolkit || comp instanceof Window); } - public static Method getMethod(final Class clz, final String methodName, final Class[] params) { + public static Method getMethod(final Class clz, final String methodName, final Class[] params) { Method res = null; try { res = AccessController.doPrivileged(new PrivilegedExceptionAction() { @@ -1482,6 +1473,7 @@ public abstract class SunToolkit extends Toolkit return res; } + @SuppressWarnings("serial") public static class OperationTimedOut extends RuntimeException { public OperationTimedOut(String msg) { super(msg); @@ -1489,9 +1481,12 @@ public abstract class SunToolkit extends Toolkit public OperationTimedOut() { } } + + @SuppressWarnings("serial") public static class InfiniteLoop extends RuntimeException { } + @SuppressWarnings("serial") public static class IllegalThreadException extends RuntimeException { public IllegalThreadException(String msg) { super(msg); @@ -1648,6 +1643,7 @@ public abstract class SunToolkit extends Toolkit * Should return true if more processing is * necessary, false otherwise. */ + @SuppressWarnings("serial") protected final boolean waitForIdle(final long timeout) { flushPendingEvents(); boolean queueWasEmpty = isEQEmpty(); @@ -1831,7 +1827,7 @@ public abstract class SunToolkit extends Toolkit Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { systemAAFonts = - (String)AccessController.doPrivileged( + AccessController.doPrivileged( new GetPropertyAction("awt.useSystemAAFontSettings")); } if (systemAAFonts != null) { @@ -1898,7 +1894,7 @@ public abstract class SunToolkit extends Toolkit if (consumeNextKeyTypedMethod == null) { consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class, "consumeNextKeyTyped", - new Class[] {KeyEvent.class}); + new Class[] {KeyEvent.class}); } try { consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(), @@ -1930,8 +1926,8 @@ public abstract class SunToolkit extends Toolkit * Returns the value of the system property indicated by the specified key. */ public static String getSystemProperty(final String key) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged(new PrivilegedAction() { + public String run() { return System.getProperty(key); } }); @@ -1941,8 +1937,7 @@ public abstract class SunToolkit extends Toolkit * Returns the boolean value of the system property indicated by the specified key. */ protected static Boolean getBooleanSystemProperty(String key) { - return Boolean.valueOf(AccessController. - doPrivileged(new GetBooleanAction(key))); + return AccessController.doPrivileged(new GetBooleanAction(key)); } private static Boolean sunAwtDisableMixing = null; @@ -2015,7 +2010,7 @@ public abstract class SunToolkit extends Toolkit */ public static boolean isContainingTopLevelTranslucent(Component c) { Window w = getContainingWindow(c); - return w != null && ((Window)w).getOpacity() < 1.0f; + return w != null && w.getOpacity() < 1.0f; } /** @@ -2057,14 +2052,14 @@ public abstract class SunToolkit extends Toolkit return isInstanceOf(obj.getClass(), type); } - private static boolean isInstanceOf(Class cls, String type) { + private static boolean isInstanceOf(Class cls, String type) { if (cls == null) return false; if (cls.getName().equals(type)) { return true; } - for (Class c : cls.getInterfaces()) { + for (Class c : cls.getInterfaces()) { if (c.getName().equals(type)) { return true; } diff --git a/jdk/src/share/classes/sun/awt/UngrabEvent.java b/jdk/src/share/classes/sun/awt/UngrabEvent.java index 460a46f804e..ee898ce538c 100644 --- a/jdk/src/share/classes/sun/awt/UngrabEvent.java +++ b/jdk/src/share/classes/sun/awt/UngrabEvent.java @@ -39,7 +39,9 @@ import java.awt.Component; *

Notice that this event is not generated on mouse click inside of the window area. *

To listen for this event, install AWTEventListener with {@value sun.awt.SunToolkit#GRAB_EVENT_MASK} */ +@SuppressWarnings("serial") public class UngrabEvent extends AWTEvent { + private final static int UNGRAB_EVENT_ID = 1998; public UngrabEvent(Component source) { diff --git a/jdk/src/share/classes/sun/awt/VariableGridLayout.java b/jdk/src/share/classes/sun/awt/VariableGridLayout.java deleted file mode 100644 index 4ca299303bd..00000000000 --- a/jdk/src/share/classes/sun/awt/VariableGridLayout.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 1995, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -import java.awt.*; -import java.util.BitSet; - - -/** - * A layout manager for a container that lays out grids. Allows setting - * the relative sizes of rows and columns. - * - * @author Herb Jellinek - */ - - -public class VariableGridLayout extends GridLayout { - - BitSet rowsSet = new BitSet(); - double rowFractions[] = null; - - BitSet colsSet = new BitSet(); - double colFractions[] = null; - - int rows; - int cols; - int hgap; - int vgap; - - /** - * Creates a grid layout with the specified rows and specified columns. - * @param rows the rows - * @param cols the columns - */ - public VariableGridLayout(int rows, int cols) { - this(rows, cols, 0, 0); - - if (rows != 0) { - rowsSet = new BitSet(rows); - stdRowFractions(rows); - } - - if (cols != 0) { - colsSet = new BitSet(cols); - stdColFractions(cols); - } - } - - /** - * Creates a grid layout with the specified rows, columns, - * horizontal gap, and vertical gap. - * @param rows the rows - * @param cols the columns - * @param hgap the horizontal gap variable - * @param vgap the vertical gap variable - * @exception IllegalArgumentException If the rows and columns are invalid. - */ - public VariableGridLayout(int rows, int cols, int hgap, int vgap) { - super(rows, cols, hgap, vgap); - - this.rows = rows; - this.cols = cols; - this.hgap = hgap; - this.vgap = vgap; - - if (rows != 0) { - rowsSet = new BitSet(rows); - stdRowFractions(rows); - } - - if (cols != 0) { - colsSet = new BitSet(cols); - stdColFractions(cols); - } - } - - void stdRowFractions(int nrows) { - rowFractions = new double[nrows]; - for (int i = 0; i < nrows; i++) { - rowFractions[i] = 1.0 / nrows; - } - } - - void stdColFractions(int ncols) { - colFractions = new double[ncols]; - for (int i = 0; i < ncols; i++) { - colFractions[i] = 1.0 / ncols; - } - } - - public void setRowFraction(int rowNum, double fraction) { - rowsSet.set(rowNum); - rowFractions[rowNum] = fraction; - } - - public void setColFraction(int colNum, double fraction) { - colsSet.set(colNum); - colFractions[colNum] = fraction; - } - - public double getRowFraction(int rowNum) { - return rowFractions[rowNum]; - } - - public double getColFraction(int colNum) { - return colFractions[colNum]; - } - - void allocateExtraSpace(double vec[], BitSet userSet) { - // collect the space that's been explicitly allocated... - double total = 0.0; - int unallocated = 0; - int i; - for (i = 0; i < vec.length; i++) { - if (userSet.get(i)) { - total += vec[i]; - } else { - unallocated++; - } - } - - // ... then spread the extra space - if (unallocated != 0) { - double space = (1.0 - total) / unallocated; - for (i = 0; i < vec.length; i++) { - if (!userSet.get(i)) { - vec[i] = space; - userSet.set(i); - } - } - } - } - - - void allocateExtraSpace() { - allocateExtraSpace(rowFractions, rowsSet); - allocateExtraSpace(colFractions, colsSet); - } - - /** - * Lays out the container in the specified panel. - * @param parent the specified component being laid out - * @see Container - */ - public void layoutContainer(Container parent) { - Insets insets = parent.insets(); - int ncomponents = parent.countComponents(); - int nrows = rows; - int ncols = cols; - - if (nrows > 0) { - ncols = (ncomponents + nrows - 1) / nrows; - } else { - nrows = (ncomponents + ncols - 1) / ncols; - } - - if (rows == 0) { - stdRowFractions(nrows); - } - if (cols == 0) { - stdColFractions(ncols); - } - - Dimension size = parent.size(); - int w = size.width - (insets.left + insets.right); - int h = size.height - (insets.top + insets.bottom); - - w = (w - (ncols - 1) * hgap); - h = (h - (nrows - 1) * vgap); - - allocateExtraSpace(); - - for (int c = 0, x = insets.left ; c < ncols ; c++) { - int colWidth = (int)(getColFraction(c) * w); - for (int r = 0, y = insets.top ; r < nrows ; r++) { - int i = r * ncols + c; - int rowHeight = (int)(getRowFraction(r) * h); - - if (i < ncomponents) { - parent.getComponent(i).reshape(x, y, colWidth, rowHeight); - } - y += rowHeight + vgap; - } - x += colWidth + hgap; - } - } - - static String fracsToString(double array[]) { - String result = "["+array.length+"]"; - - for (int i = 0; i < array.length; i++) { - result += "<"+array[i]+">"; - } - return result; - } - - /** - * Returns the String representation of this VariableGridLayout's values. - */ - public String toString() { - return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + - ",rows=" + rows + ",cols=" + cols + - ",rowFracs=" + - fracsToString(rowFractions) + - ",colFracs=" + - fracsToString(colFractions) + "]"; - } -} diff --git a/jdk/src/share/classes/sun/awt/VerticalBagLayout.java b/jdk/src/share/classes/sun/awt/VerticalBagLayout.java deleted file mode 100644 index fcc3e784b5c..00000000000 --- a/jdk/src/share/classes/sun/awt/VerticalBagLayout.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 1995, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -import java.awt.*; - - -/** - * A vertical 'bag' of Components. Allocates space for each Component from - * top to bottom. - * - * @author Herb Jellinek - */ -public class VerticalBagLayout implements LayoutManager { - - int vgap; - - /** - * Constructs a new VerticalBagLayout. - */ - public VerticalBagLayout() { - this(0); - } - - /** - * Constructs a VerticalBagLayout with the specified gaps. - * @param vgap the vertical gap - */ - public VerticalBagLayout(int vgap) { - this.vgap = vgap; - } - - /** - * Adds the specified named component to the layout. - * @param name the String name - * @param comp the component to be added - */ - public void addLayoutComponent(String name, Component comp) { - } - - /** - * Removes the specified component from the layout. - * @param comp the component to be removed - */ - public void removeLayoutComponent(Component comp) { - } - - /** - * Returns the minimum dimensions needed to lay out the components - * contained in the specified target container. - * @param target the Container on which to do the layout - * @see Container - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container target) { - Dimension dim = new Dimension(); - int nmembers = target.countComponents(); - - for (int i = 0; i < nmembers; i++) { - Component comp = target.getComponent(i); - if (comp.isVisible()) { - Dimension d = comp.minimumSize(); - dim.width = Math.max(d.width, dim.width); - dim.height += d.height + vgap; - } - } - - Insets insets = target.insets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - - /** - * Returns the preferred dimensions for this layout given the components - * in the specified target container. - * @param target the component which needs to be laid out - * @see Container - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - Dimension dim = new Dimension(); - int nmembers = target.countComponents(); - - for (int i = 0; i < nmembers; i++) { - Component comp = target.getComponent(i); - if (true || comp.isVisible()) { - Dimension d = comp.preferredSize(); - dim.width = Math.max(d.width, dim.width); - dim.height += d.height + vgap; - } - } - - Insets insets = target.insets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - - /** - * Lays out the specified container. This method will actually reshape the - * components in the specified target container in order to satisfy the - * constraints of the VerticalBagLayout object. - * @param target the component being laid out - * @see Container - */ - public void layoutContainer(Container target) { - Insets insets = target.insets(); - int top = insets.top; - int bottom = target.size().height - insets.bottom; - int left = insets.left; - int right = target.size().width - insets.right; - int nmembers = target.countComponents(); - - for (int i = 0; i < nmembers; i++) { - Component comp = target.getComponent(i); - if (comp.isVisible()) { - int compHeight = comp.size().height; - comp.resize(right - left, compHeight); - Dimension d = comp.preferredSize(); - comp.reshape(left, top, right - left, d.height); - top += d.height + vgap; - } - } - } - - /** - * Returns the String representation of this VerticalBagLayout's values. - */ - public String toString() { - return getClass().getName() + "[vgap=" + vgap + "]"; - } -} diff --git a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java index 82ff8899349..f8dd9dfc380 100644 --- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java +++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java @@ -649,8 +649,9 @@ public abstract class DataTransferer { * The map keys are sorted according to the native formats preference * order. */ - public SortedMap getFormatsForTransferable(Transferable contents, - FlavorTable map) { + public SortedMap getFormatsForTransferable( + Transferable contents, FlavorTable map) + { DataFlavor[] flavors = contents.getTransferDataFlavors(); if (flavors == null) { return new TreeMap(); @@ -686,9 +687,13 @@ public abstract class DataTransferer { * DataFlavors and data formats * @throws NullPointerException if flavors or map is null */ - public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) { - Map formatMap = new HashMap(flavors.length); - Map textPlainMap = new HashMap(flavors.length); + public SortedMap getFormatsForFlavors( + DataFlavor[] flavors, FlavorTable map) + { + Map formatMap = + new HashMap <> (flavors.length); + Map textPlainMap = + new HashMap <> (flavors.length); // Maps formats to indices that will be used to sort the formats // according to the preference order. // Larger index value corresponds to the more preferable format. diff --git a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java index 78dc3413156..cfc2405ef63 100644 --- a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java +++ b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java @@ -52,6 +52,7 @@ import java.util.SortedMap; import sun.awt.SunToolkit; import sun.awt.datatransfer.DataTransferer; +import java.awt.datatransfer.DataFlavor; /** *

@@ -126,9 +127,9 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer dragImageOffset = p; Transferable transferable = getDragSourceContext().getTransferable(); - SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable - (transferable, DataTransferer.adaptFlavorMap - (getTrigger().getDragSource().getFlavorMap())); + SortedMap formatMap = DataTransferer.getInstance(). + getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap + (getTrigger().getDragSource().getFlavorMap())); long[] formats = DataTransferer.getInstance(). keysToLongArray(formatMap); startDrag(transferable, formats, formatMap); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java index 9a0a6c938de..44ee617783b 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java @@ -26,6 +26,7 @@ package sun.awt.X11; import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.DataFlavor; import java.util.SortedMap; import java.io.IOException; import java.security.AccessController; @@ -83,7 +84,8 @@ public final class XClipboard extends SunClipboard implements OwnershipListener } protected synchronized void setContentsNative(Transferable contents) { - SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable + SortedMap formatMap = + DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(flavorMap)); long[] formats = DataTransferer.keysToLongArray(formatMap); diff --git a/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java b/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java index f744ee2c74b..8a6106ad57b 100644 --- a/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java +++ b/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java @@ -40,6 +40,7 @@ import sun.java2d.DestSurfaceProvider; import sun.java2d.InvalidPipeException; import sun.java2d.Surface; import sun.java2d.pipe.RenderQueue; +import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.hw.AccelGraphicsConfig; import sun.java2d.pipe.hw.AccelSurface; import sun.security.action.GetPropertyAction; @@ -310,7 +311,7 @@ public abstract class TranslucentWindowPainter { RenderQueue rq = as.getContext().getRenderQueue(); rq.lock(); try { - as.getContext().validateContext(as); + BufferedContext.validateContext(as); rq.flushAndInvokeNow(new Runnable() { public void run() { long psdops = as.getNativeOps(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WBufferStrategy.java b/jdk/src/windows/classes/sun/awt/windows/WBufferStrategy.java index 5a4ce2a18bb..4b346ca80a8 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WBufferStrategy.java +++ b/jdk/src/windows/classes/sun/awt/windows/WBufferStrategy.java @@ -37,7 +37,7 @@ import java.awt.Component; */ public class WBufferStrategy { - private static native void initIDs(Class componentClass); + private static native void initIDs(Class componentClass); static { initIDs(Component.class); diff --git a/jdk/src/windows/classes/sun/awt/windows/WChoicePeer.java b/jdk/src/windows/classes/sun/awt/windows/WChoicePeer.java index 28a2a05d2bc..8ecc83ed866 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WChoicePeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WChoicePeer.java @@ -84,6 +84,7 @@ class WChoicePeer extends WComponentPeer implements ChoicePeer { native void create(WComponentPeer parent); + @SuppressWarnings("deprecation") void initialize() { Choice opt = (Choice)target; int itemCount = opt.getItemCount(); @@ -116,6 +117,7 @@ class WChoicePeer extends WComponentPeer implements ChoicePeer { super.initialize(); } + @SuppressWarnings("deprecation") protected void disposeImpl() { // TODO: we should somehow reset the listener when the choice // is moved to another toplevel without destroying its peer. diff --git a/jdk/src/windows/classes/sun/awt/windows/WClipboard.java b/jdk/src/windows/classes/sun/awt/windows/WClipboard.java index 62570ac6632..602d228f342 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WClipboard.java +++ b/jdk/src/windows/classes/sun/awt/windows/WClipboard.java @@ -71,17 +71,14 @@ public class WClipboard extends SunClipboard { // Get all of the target formats into which the Transferable can be // translated. Then, for each format, translate the data and post // it to the Clipboard. - Map formatMap = WDataTransferer.getInstance(). + Map formatMap = WDataTransferer.getInstance(). getFormatsForTransferable(contents, flavorMap); openClipboard(this); try { - for (Iterator iter = formatMap.keySet().iterator(); - iter.hasNext(); ) { - Long lFormat = (Long)iter.next(); - long format = lFormat.longValue(); - DataFlavor flavor = (DataFlavor)formatMap.get(lFormat); + for (Long format : formatMap.keySet()) { + DataFlavor flavor = formatMap.get(format); try { byte[] bytes = WDataTransferer.getInstance(). diff --git a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java index a482fd9ca86..6f788c2ac5d 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java @@ -222,7 +222,7 @@ public abstract class WComponentPeer extends WObjectPeer updateWindow(); // make sure paint events are transferred to main event queue // for coalescing - WToolkit.getWToolkit().flushPendingEvents(); + SunToolkit.flushPendingEvents(); // paint the damaged area paintArea.paint(target, shouldClearRectBeforePaint()); } @@ -320,6 +320,7 @@ public abstract class WComponentPeer extends WObjectPeer native void nativeHandleEvent(AWTEvent e); + @SuppressWarnings("fallthrough") public void handleEvent(AWTEvent e) { int id = e.getID(); @@ -549,6 +550,7 @@ public abstract class WComponentPeer extends WObjectPeer // fallback default font object final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); + @SuppressWarnings("deprecation") public Graphics getGraphics() { if (isDisposed()) { return null; @@ -656,6 +658,7 @@ public abstract class WComponentPeer extends WObjectPeer } // TODO: consider moving it to KeyboardFocusManagerPeerImpl + @SuppressWarnings("deprecation") public boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) @@ -1058,6 +1061,7 @@ public abstract class WComponentPeer extends WObjectPeer // in the browser on Vista when DWM is enabled. // @return true if the toplevel container is not an EmbeddedFrame or // if this EmbeddedFrame is acceleration capable, false otherwise + @SuppressWarnings("deprecation") private static final boolean isContainingTopLevelAccelCapable(Component c) { while (c != null && !(c instanceof WEmbeddedFrame)) { c = c.getParent(); @@ -1072,6 +1076,7 @@ public abstract class WComponentPeer extends WObjectPeer * Applies the shape to the native component window. * @since 1.7 */ + @SuppressWarnings("deprecation") public void applyShape(Region shape) { if (shapeLog.isLoggable(PlatformLogger.FINER)) { shapeLog.finer( diff --git a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java index 47dcf275430..10888ed6e2b 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java @@ -107,13 +107,15 @@ public class WDataTransferer extends DataTransferer { "DIBV5" }; - private static final Map predefinedClipboardNameMap; + private static final Map predefinedClipboardNameMap; static { - Map tempMap = new HashMap(predefinedClipboardNames.length, 1.0f); + Map tempMap = + new HashMap <> (predefinedClipboardNames.length, 1.0f); for (int i = 1; i < predefinedClipboardNames.length; i++) { tempMap.put(predefinedClipboardNames[i], Long.valueOf(i)); } - predefinedClipboardNameMap = Collections.synchronizedMap(tempMap); + predefinedClipboardNameMap = + Collections.synchronizedMap(tempMap); } /** @@ -135,7 +137,7 @@ public class WDataTransferer extends DataTransferer { public static final long CF_FILEGROUPDESCRIPTORA = registerClipboardFormat("FileGroupDescriptor"); //CF_FILECONTENTS supported as mandatory associated clipboard - private static final Long L_CF_LOCALE = (Long) + private static final Long L_CF_LOCALE = predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]); private static final DirectColorModel directColorModel = @@ -168,8 +170,11 @@ public class WDataTransferer extends DataTransferer { return transferer; } - public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) { - SortedMap retval = super.getFormatsForFlavors(flavors, map); + public SortedMap getFormatsForFlavors( + DataFlavor[] flavors, FlavorTable map) + { + SortedMap retval = + super.getFormatsForFlavors(flavors, map); // The Win32 native code does not support exporting LOCALE data, nor // should it. @@ -266,7 +271,7 @@ public class WDataTransferer extends DataTransferer { } protected Long getFormatForNativeAsLong(String str) { - Long format = (Long)predefinedClipboardNameMap.get(str); + Long format = predefinedClipboardNameMap.get(str); if (format == null) { format = Long.valueOf(registerClipboardFormat(str)); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WDesktopProperties.java b/jdk/src/windows/classes/sun/awt/windows/WDesktopProperties.java index 525d42966bd..3c8f8c0f101 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WDesktopProperties.java +++ b/jdk/src/windows/classes/sun/awt/windows/WDesktopProperties.java @@ -238,6 +238,7 @@ class WDesktopProperties { * Called by WToolkit when Windows settings change-- we (re)load properties and * set new values. */ + @SuppressWarnings("unchecked") synchronized Map getProperties() { ThemeReader.flush(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WDialogPeer.java index a5d2c2742b8..716a77f1591 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WDialogPeer.java @@ -87,6 +87,7 @@ class WDialogPeer extends WWindowPeer implements DialogPeer { } } + @SuppressWarnings("deprecation") public void hide() { Dialog dlg = (Dialog)target; if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) { diff --git a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java index 4e4e3838da5..b0f9cd3279d 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java +++ b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java @@ -27,14 +27,12 @@ package sun.awt.windows; import sun.awt.*; import java.awt.*; -import java.awt.event.*; import java.awt.peer.ComponentPeer; -import java.util.*; -import java.awt.color.*; import java.awt.image.*; import sun.awt.image.ByteInterleavedRaster; import sun.security.action.GetPropertyAction; -import java.lang.reflect.*; +import java.security.PrivilegedAction; +import java.security.AccessController; public class WEmbeddedFrame extends EmbeddedFrame { @@ -52,8 +50,8 @@ public class WEmbeddedFrame extends EmbeddedFrame { private static int pScale = 0; private static final int MAX_BAND_SIZE = (1024*30); - private static String printScale = (String) java.security.AccessController - .doPrivileged(new GetPropertyAction("sun.java2d.print.pluginscalefactor")); + private static String printScale = AccessController.doPrivileged( + new GetPropertyAction("sun.java2d.print.pluginscalefactor")); public WEmbeddedFrame() { this((long)0); @@ -75,6 +73,7 @@ public class WEmbeddedFrame extends EmbeddedFrame { } } + @SuppressWarnings("deprecation") public void addNotify() { if (getPeer() == null) { WToolkit toolkit = (WToolkit)Toolkit.getDefaultToolkit(); @@ -134,8 +133,8 @@ public class WEmbeddedFrame extends EmbeddedFrame { bandHeight = Math.min(MAX_BAND_SIZE/bandWidth, frameHeight); - imgWid = (int)(bandWidth * xscale); - imgHgt = (int)(bandHeight * yscale); + imgWid = bandWidth * xscale; + imgHgt = bandHeight * yscale; bandImage = new BufferedImage(imgWid, imgHgt, BufferedImage.TYPE_3BYTE_BGR); } @@ -159,7 +158,7 @@ public class WEmbeddedFrame extends EmbeddedFrame { if ((bandTop+bandHeight) > frameHeight) { // last band currBandHeight = frameHeight - bandTop; - currImgHeight = (int)(currBandHeight*yscale); + currImgHeight = currBandHeight*yscale; // multiply by 3 because the image is a 3 byte BGR imageOffset = imgWid*(imgHgt-currImgHeight)*3; @@ -179,9 +178,9 @@ public class WEmbeddedFrame extends EmbeddedFrame { if (printScale == null) { // if no system property is specified, // check for environment setting - printScale = (String) java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + printScale = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { return System.getenv("JAVA2D_PLUGIN_PRINT_SCALE"); } } @@ -226,6 +225,7 @@ public class WEmbeddedFrame extends EmbeddedFrame { public void activateEmbeddingTopLevel() { } + @SuppressWarnings("deprecation") public void synthesizeWindowActivation(final boolean doActivate) { if (!doActivate || EventQueue.isDispatchThread()) { ((WEmbeddedFramePeer)getPeer()).synthesizeWmActivate(doActivate); diff --git a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java index ed216c00d2c..56568dcf3a1 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java @@ -167,7 +167,7 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() { public void run() { - fileDialog.hide(); + fileDialog.setVisible(false); } }); } // handleSelected() @@ -182,16 +182,16 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() { public void run() { - fileDialog.hide(); + fileDialog.setVisible(false); } }); } // handleCancel() //This whole static block is a part of 4152317 fix static { - String filterString = (String) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + String filterString = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { try { ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); return rb.getString("allFiles"); diff --git a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java index 94cde03850f..368b8f60696 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -24,25 +24,12 @@ */ package sun.awt.windows; -import java.util.Vector; - import java.awt.*; import java.awt.peer.*; -import java.awt.image.ImageObserver; - -import java.awt.image.Raster; -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferInt; -import java.awt.image.BufferedImage; - -import java.awt.image.ColorModel; - -import sun.awt.image.ImageRepresentation; -import sun.awt.image.IntegerComponentRaster; -import sun.awt.image.ToolkitImage; -import sun.awt.im.*; -import sun.awt.Win32GraphicsDevice; import sun.awt.AWTAccessor; +import sun.awt.im.InputMethodManager; +import java.security.AccessController; +import sun.security.action.GetPropertyAction; class WFramePeer extends WWindowPeer implements FramePeer { @@ -71,9 +58,9 @@ class WFramePeer extends WWindowPeer implements FramePeer { private native void clearMaximizedBounds(); private static final boolean keepOnMinimize = "true".equals( - (String)java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.awt.keepWorkingSetOnMinimize"))); + AccessController.doPrivileged( + new GetPropertyAction( + "sun.awt.keepWorkingSetOnMinimize"))); public void setMaximizedBounds(Rectangle b) { if (b == null) { diff --git a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java index d1423a31af5..dbecc230de0 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java +++ b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java @@ -82,12 +82,12 @@ public class WInputMethod extends InputMethodAdapter private final static boolean COMMIT_INPUT = true; private final static boolean DISCARD_INPUT = false; - private static Map[] highlightStyles; + private static Map [] highlightStyles; // Initialize highlight mapping table static { - Map styles[] = new Map[4]; - HashMap map; + Map styles[] = new Map[4]; + HashMap map; // UNSELECTED_RAW_TEXT_HIGHLIGHT map = new HashMap(1); @@ -410,7 +410,7 @@ public class WInputMethod extends InputMethodAdapter /** * @see java.awt.Toolkit#mapInputMethodHighlight */ - static Map mapInputMethodHighlight(InputMethodHighlight highlight) { + static Map mapInputMethodHighlight(InputMethodHighlight highlight) { int index; int state = highlight.getState(); if (state == InputMethodHighlight.RAW_TEXT) { diff --git a/jdk/src/windows/classes/sun/awt/windows/WMenuItemPeer.java b/jdk/src/windows/classes/sun/awt/windows/WMenuItemPeer.java index 1c71b62903f..716ab5dd26c 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -158,9 +158,9 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { private static Font defaultMenuFont; static { - defaultMenuFont = (Font) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + defaultMenuFont = AccessController.doPrivileged( + new PrivilegedAction () { + public Font run() { try { ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); return Font.decode(rb.getString("menuFont")); diff --git a/jdk/src/windows/classes/sun/awt/windows/WPageDialog.java b/jdk/src/windows/classes/sun/awt/windows/WPageDialog.java index 6beda8b4809..08e73c56825 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPageDialog.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPageDialog.java @@ -55,6 +55,7 @@ public class WPageDialog extends WPrintDialog { this.painter = painter; } + @SuppressWarnings("deprecation") public void addNotify() { synchronized(getTreeLock()) { Container parent = getParent(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WPageDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPageDialogPeer.java index e1fb9b022e6..707bc3f683a 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPageDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPageDialogPeer.java @@ -49,7 +49,7 @@ public class WPageDialogPeer extends WPrintDialogPeer { // but if it is we need to trap it so the thread does // not hide is called and the thread doesn't hang. } - ((WPrintDialog)target).hide(); + ((WPrintDialog)target).setVisible(false); } }).start(); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrintDialog.java b/jdk/src/windows/classes/sun/awt/windows/WPrintDialog.java index 0708d921ae1..af1a5dcb83e 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialog.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialog.java @@ -53,6 +53,7 @@ public class WPrintDialog extends Dialog { // Use native code to circumvent access restrictions on Component.peer protected native void setPeer(ComponentPeer peer); + @SuppressWarnings("deprecation") public void addNotify() { synchronized(getTreeLock()) { Container parent = getParent(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java index 769e73a6828..988098eb648 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java @@ -73,7 +73,7 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer { // but if it is we need to trap it so the thread does // not hide is called and the thread doesn't hang. } - ((WPrintDialog)target).hide(); + ((WPrintDialog)target).setVisible(false); } }).start(); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java index 26b234f1a9d..0c0cdd47aa7 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java @@ -74,7 +74,7 @@ public class WToolkit extends SunToolkit implements Runnable { WClipboard clipboard; // cache of font peers - private Hashtable cacheFontPeer; + private Hashtable cacheFontPeer; // Windows properties private WDesktopProperties wprops; @@ -110,10 +110,10 @@ public class WToolkit extends SunToolkit implements Runnable { log.fine("Win version: " + getWindowsVersion()); } - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() + AccessController.doPrivileged( + new PrivilegedAction () { - public Object run() { + public Void run() { String browserProp = System.getProperty("browser"); if (browserProp != null && browserProp.equals("sun.plugin")) { disableCustomPalette(); @@ -261,8 +261,8 @@ public class WToolkit extends SunToolkit implements Runnable { } private final void registerShutdownHook() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); ThreadGroup parentTG = currentTG.getParent(); @@ -399,6 +399,7 @@ public class WToolkit extends SunToolkit implements Runnable { return peer; } + @SuppressWarnings("deprecation") public void disableBackgroundErase(Canvas canvas) { WCanvasPeer peer = (WCanvasPeer)canvas.getPeer(); if (peer == null) { @@ -592,7 +593,7 @@ public class WToolkit extends SunToolkit implements Runnable { FontPeer retval = null; String lcName = name.toLowerCase(); if (null != cacheFontPeer) { - retval = (FontPeer)cacheFontPeer.get(lcName + style); + retval = cacheFontPeer.get(lcName + style); if (null != retval) { return retval; } @@ -600,7 +601,7 @@ public class WToolkit extends SunToolkit implements Runnable { retval = new WFontPeer(name, style); if (retval != null) { if (null == cacheFontPeer) { - cacheFontPeer = new Hashtable(5, (float)0.9); + cacheFontPeer = new Hashtable<>(5, 0.9f); } if (null != cacheFontPeer) { cacheFontPeer.put(lcName + style, retval); @@ -698,7 +699,9 @@ public class WToolkit extends SunToolkit implements Runnable { /** * Returns a style map for the input method highlight. */ - public Map mapInputMethodHighlight(InputMethodHighlight highlight) { + public Map mapInputMethodHighlight( + InputMethodHighlight highlight) + { return WInputMethod.mapInputMethodHighlight(highlight); } @@ -968,12 +971,14 @@ public class WToolkit extends SunToolkit implements Runnable { return !Win32GraphicsEnvironment.isDWMCompositionEnabled(); } + @SuppressWarnings("deprecation") public void grab(Window w) { if (w.getPeer() != null) { ((WWindowPeer)w.getPeer()).grab(); } } + @SuppressWarnings("deprecation") public void ungrab(Window w) { if (w.getPeer() != null) { ((WWindowPeer)w.getPeer()).ungrab(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java index cdd46edc9be..450535e7d72 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java @@ -92,7 +92,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, } // WComponentPeer overrides - + @SuppressWarnings("unchecked") protected void disposeImpl() { AppContext appContext = SunToolkit.targetToAppContext(target); synchronized (appContext) { @@ -378,6 +378,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, return modalBlocker != null; } + @SuppressWarnings("deprecation") public void setModalBlocked(Dialog dialog, boolean blocked) { synchronized (((Component)getTarget()).getTreeLock()) // State lock should always be after awtLock { @@ -417,6 +418,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, * The list is sorted by the time of activation, so the latest * active window is always at the end. */ + @SuppressWarnings("unchecked") public static long[] getActiveWindowHandles() { AppContext appContext = AppContext.getAppContext(); synchronized (appContext) { @@ -571,6 +573,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, super.print(g); } + @SuppressWarnings("deprecation") private void replaceSurfaceDataRecursively(Component c) { if (c instanceof Container) { for (Component child : ((Container)c).getComponents()) { @@ -691,13 +694,13 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, // its shape only. To restore the correct visual appearance // of the window (i.e. w/ the correct shape) we have to reset // the shape. - Shape shape = ((Window)target).getShape(); + Shape shape = target.getShape(); if (shape != null) { - ((Window)target).setShape(shape); + target.setShape(shape); } } - if (((Window)target).isVisible()) { + if (target.isVisible()) { updateWindow(true); } } @@ -730,6 +733,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, * then the method registers ActiveWindowListener, GuiDisposedListener listeners; * it executes the initilialization only once per AppContext. */ + @SuppressWarnings("unchecked") private static void initActiveWindowsTracking(Window w) { AppContext appContext = AppContext.getAppContext(); synchronized (appContext) { @@ -774,6 +778,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, * updates the list of active windows per AppContext, so the latest active * window is always at the end of the list. The list is stored in AppContext. */ + @SuppressWarnings( value = {"deprecation", "unchecked"}) private static class ActiveWindowListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent e) { Window w = (Window)e.getNewValue(); diff --git a/jdk/test/java/awt/EventQueue/MainAppContext/MainAppContext.java b/jdk/test/java/awt/EventQueue/MainAppContext/MainAppContext.java new file mode 100644 index 00000000000..2a203208366 --- /dev/null +++ b/jdk/test/java/awt/EventQueue/MainAppContext/MainAppContext.java @@ -0,0 +1,36 @@ +/* + * @test + * @bug 7122796 + * @summary Tests 7122796 + * @author anthony.petrov@oracle.com + */ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import sun.awt.*; + +public class MainAppContext { + + public static void main(String[] args) { + ThreadGroup secondGroup = new ThreadGroup("test"); + new Thread(secondGroup, new Runnable() { + public void run() { + SunToolkit.createNewAppContext(); + test(true); + } + }).start(); + + // Sleep on the main thread so that the AWT Toolkit is initialized + // in a user AppContext first + try { Thread.sleep(2000); } catch (Exception e) {} + + test(false); + } + + private static void test(boolean userAppContext) { + if (Toolkit.getDefaultToolkit().getSystemEventQueue() == null) { + throw new RuntimeException("No EventQueue for the current app context! userAppContext: " + userAppContext); + } + } +} diff --git a/jdk/test/javax/swing/JScrollBar/4708809/bug4708809.java b/jdk/test/javax/swing/JScrollBar/4708809/bug4708809.java new file mode 100644 index 00000000000..d8d34ec001e --- /dev/null +++ b/jdk/test/javax/swing/JScrollBar/4708809/bug4708809.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2011, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4708809 + * @summary JScrollBar functionality slightly different from native scrollbar + * @author Andrey Pikalev + * @run main bug4708809 + */ +import javax.swing.*; +import java.awt.*; +import java.awt.Point; +import java.awt.event.*; +import sun.awt.SunToolkit; + +public class bug4708809 { + + private static volatile boolean do_test = false; + private static volatile boolean passed = true; + private static JScrollPane spane; + private static JScrollBar sbar; + + public static void main(String[] args) throws Exception { + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); + robot.setAutoDelay(350); + + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + createAndShowGUI(); + } + }); + + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + spane.requestFocus(); + sbar.setValue(sbar.getMaximum()); + } + }); + + toolkit.realSync(); + + Point point = getClickPoint(0.5, 0.5); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + final int oldValue = sbar.getValue(); + sbar.addAdjustmentListener(new AdjustmentListener() { + + public void adjustmentValueChanged(AdjustmentEvent e) { + if (e.getValue() >= oldValue) { + passed = false; + } + do_test = true; + } + }); + + } + }); + + toolkit.realSync(); + + point = getClickPoint(0.5, 0.2); + robot.mouseMove(point.x, point.y); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + if (!do_test || !passed) { + throw new Exception("The scrollbar moved with incorrect direction"); + } + + } + + private static Point getClickPoint(final double scaleX, final double scaleY) throws Exception { + final Point[] result = new Point[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + Point p = sbar.getLocationOnScreen(); + Rectangle rect = sbar.getBounds(); + result[0] = new Point((int) (p.x + scaleX * rect.width), + (int) (p.y + scaleY * rect.height)); + } + }); + + return result[0]; + + } + + private static void createAndShowGUI() { + JFrame fr = new JFrame("Test"); + + JLabel label = new JLabel("picture"); + label.setPreferredSize(new Dimension(500, 500)); + spane = new JScrollPane(label); + fr.getContentPane().add(spane); + sbar = spane.getVerticalScrollBar(); + + fr.setSize(200, 200); + fr.setVisible(true); + } +} \ No newline at end of file diff --git a/jdk/test/javax/swing/JTabbedPane/6416920/bug6416920.java b/jdk/test/javax/swing/JTabbedPane/6416920/bug6416920.java new file mode 100644 index 00000000000..c1188ce9929 --- /dev/null +++ b/jdk/test/javax/swing/JTabbedPane/6416920/bug6416920.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6416920 + * @summary Ensures that selected tab is painted properly in the scroll tab layout + * under WindowsLookAndFeel in Windows' "Windows XP" theme. + * @author Mikhail Lapshin + * @run main bug6416920 + */ + +import javax.swing.plaf.basic.BasicTabbedPaneUI; +import javax.swing.JTabbedPane; +import javax.swing.SwingConstants; +import java.awt.Rectangle; +import java.awt.Insets; +import sun.awt.OSInfo; + +public class bug6416920 extends BasicTabbedPaneUI { + public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout(); + + public static void main(String[] args) { + + if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){ + return; + } + + bug6416920 test = new bug6416920(); + test.layout.padSelectedTab(SwingConstants.TOP, 0); + if (test.rects[0].width < 0) { + throw new RuntimeException("A selected tab isn't painted properly " + + "in the scroll tab layout under WindowsLookAndFeel " + + "in Windows' \"Windows XP\" theme."); + } + } + + public bug6416920() { + super(); + + // Set parameters for the padSelectedTab() method + selectedTabPadInsets = new Insets(0, 0, 0, 0); + + tabPane = new JTabbedPane(); + tabPane.setSize(100, 0); + tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); + + rects = new Rectangle[1]; + rects[0] = new Rectangle(150, 0, 0, 0); + } + + public class AccessibleTabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout { + public void padSelectedTab(int tabPlacement, int selectedIndex) { + super.padSelectedTab(tabPlacement, selectedIndex); + } + } +}