diff --git a/src/share/classes/java/beans/EventSetDescriptor.java b/src/share/classes/java/beans/EventSetDescriptor.java index db592aa8e3e9886092f868e7079758372aa6c441..83b5e0d8f1cba791150e7120e5d5c78073eb394f 100644 --- a/src/share/classes/java/beans/EventSetDescriptor.java +++ b/src/share/classes/java/beans/EventSetDescriptor.java @@ -176,8 +176,9 @@ public class EventSetDescriptor extends FeatureDescriptor { setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1)); // Be more forgiving of not finding the getListener method. - if (getListenerMethodName != null) { - setGetListenerMethod(Introspector.findInstanceMethod(sourceClass, getListenerMethodName)); + Method method = Introspector.findMethod(sourceClass, getListenerMethodName, 0); + if (method != null) { + setGetListenerMethod(method); } } diff --git a/src/share/classes/java/beans/IndexedPropertyDescriptor.java b/src/share/classes/java/beans/IndexedPropertyDescriptor.java index de439c7f9115b3388915fd404252b9a81cdfc50b..5764bf49b760b27e0d1221399362c142672dde65 100644 --- a/src/share/classes/java/beans/IndexedPropertyDescriptor.java +++ b/src/share/classes/java/beans/IndexedPropertyDescriptor.java @@ -189,11 +189,13 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); } } - indexedReadMethod = Introspector.findInstanceMethod(cls, indexedReadMethodName, int.class); + + Class[] args = { int.class }; + indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); if (indexedReadMethod == null) { // no "is" method, so look for a "get" method. indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); - indexedReadMethod = Introspector.findInstanceMethod(cls, indexedReadMethodName, int.class); + indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); } setIndexedReadMethod0(indexedReadMethod); } @@ -265,7 +267,9 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { if (indexedWriteMethodName == null) { indexedWriteMethodName = Introspector.SET_PREFIX + getBaseName(); } - indexedWriteMethod = Introspector.findInstanceMethod(cls, indexedWriteMethodName, int.class, type); + + Class[] args = (type == null) ? null : new Class[] { int.class, type }; + indexedWriteMethod = Introspector.findMethod(cls, indexedWriteMethodName, 2, args); if (indexedWriteMethod != null) { if (!indexedWriteMethod.getReturnType().equals(void.class)) { indexedWriteMethod = null; diff --git a/src/share/classes/java/beans/Introspector.java b/src/share/classes/java/beans/Introspector.java index d7669bb7fd98ebf8138d5c7288725666e9b529e1..23e91d98b3cc54a6256e84c51bafde0862fdfe6f 100644 --- a/src/share/classes/java/beans/Introspector.java +++ b/src/share/classes/java/beans/Introspector.java @@ -28,7 +28,6 @@ package java.beans; import com.sun.beans.WeakCache; import com.sun.beans.finder.BeanInfoFinder; import com.sun.beans.finder.ClassFinder; -import com.sun.beans.finder.MethodFinder; import java.lang.ref.Reference; import java.lang.ref.SoftReference; @@ -843,8 +842,8 @@ public class Introspector { Method read = result.getReadMethod(); if (read == null && write != null) { - read = findInstanceMethod(result.getClass0(), - GET_PREFIX + NameGenerator.capitalize(result.getName())); + read = findMethod(result.getClass0(), + GET_PREFIX + NameGenerator.capitalize(result.getName()), 0); if (read != null) { try { result.setReadMethod(read); @@ -854,9 +853,9 @@ public class Introspector { } } if (write == null && read != null) { - write = findInstanceMethod(result.getClass0(), - SET_PREFIX + NameGenerator.capitalize(result.getName()), - FeatureDescriptor.getReturnType(result.getClass0(), read)); + write = findMethod(result.getClass0(), + SET_PREFIX + NameGenerator.capitalize(result.getName()), 1, + new Class[] { FeatureDescriptor.getReturnType(result.getClass0(), read) }); if (write != null) { try { result.setWriteMethod(write); @@ -1280,27 +1279,90 @@ public class Introspector { // Package private support methods. //====================================================================== - static Method findMethod(Class type, String name, int args) { - for (Method method : type.getMethods()) { - if (method.getName().equals(name) && (args == method.getParameterTypes().length)) { - try { - return MethodFinder.findAccessibleMethod(method); + /** + * Internal support for finding a target methodName with a given + * parameter list on a given class. + */ + private static Method internalFindMethod(Class start, String methodName, + int argCount, Class args[]) { + // For overriden methods we need to find the most derived version. + // So we start with the given class and walk up the superclass chain. + + Method method = null; + + for (Class cl = start; cl != null; cl = cl.getSuperclass()) { + Method methods[] = getPublicDeclaredMethods(cl); + for (int i = 0; i < methods.length; i++) { + method = methods[i]; + if (method == null) { + continue; } - catch (NoSuchMethodException exception) { - // continue search for a method with the specified count of parameters + + // make sure method signature matches. + Class params[] = FeatureDescriptor.getParameterTypes(start, method); + if (method.getName().equals(methodName) && + params.length == argCount) { + if (args != null) { + boolean different = false; + if (argCount > 0) { + for (int j = 0; j < argCount; j++) { + if (params[j] != args[j]) { + different = true; + continue; + } + } + if (different) { + continue; + } + } + } + return method; } } } - return null; + method = null; + + // Now check any inherited interfaces. This is necessary both when + // the argument class is itself an interface, and when the argument + // class is an abstract class. + Class ifcs[] = start.getInterfaces(); + for (int i = 0 ; i < ifcs.length; i++) { + // Note: The original implementation had both methods calling + // the 3 arg method. This is preserved but perhaps it should + // pass the args array instead of null. + method = internalFindMethod(ifcs[i], methodName, argCount, null); + if (method != null) { + break; + } + } + return method; } - static Method findInstanceMethod(Class type, String name, Class... args) { - try { - return MethodFinder.findInstanceMethod(type, name, args); - } - catch (NoSuchMethodException exception) { + /** + * Find a target methodName on a given class. + */ + static Method findMethod(Class cls, String methodName, int argCount) { + return findMethod(cls, methodName, argCount, null); + } + + /** + * Find a target methodName with specific parameter list on a given class. + *

+ * Used in the contructors of the EventSetDescriptor, + * PropertyDescriptor and the IndexedPropertyDescriptor. + *

+ * @param cls The Class object on which to retrieve the method. + * @param methodName Name of the method. + * @param argCount Number of arguments for the desired method. + * @param args Array of argument types for the method. + * @return the method or null if not found + */ + static Method findMethod(Class cls, String methodName, int argCount, + Class args[]) { + if (methodName == null) { return null; } + return internalFindMethod(cls, methodName, argCount, args); } /** diff --git a/src/share/classes/java/beans/MethodDescriptor.java b/src/share/classes/java/beans/MethodDescriptor.java index 74a7a16782d704a73246ae1b667971eaf0082a45..d9e78be516f80be7fd5bb67048d2c7f8b1c31e1a 100644 --- a/src/share/classes/java/beans/MethodDescriptor.java +++ b/src/share/classes/java/beans/MethodDescriptor.java @@ -90,13 +90,13 @@ public class MethodDescriptor extends FeatureDescriptor { // Find methods for up to 2 params. We are guessing here. // This block should never execute unless the classloader // that loaded the argument classes disappears. - method = Introspector.findMethod(cls, name, i); + method = Introspector.findMethod(cls, name, i, null); if (method != null) { break; } } } else { - method = Statement.getMethod(cls, name, params); + method = Introspector.findMethod(cls, name, params.length, params); } setMethod(method); } diff --git a/src/share/classes/java/beans/PropertyDescriptor.java b/src/share/classes/java/beans/PropertyDescriptor.java index c7524e3026fcdf354c3278b85aca30d27782fbb1..429d2b4079b3d1d933a9fff10d90fe279acf36fd 100644 --- a/src/share/classes/java/beans/PropertyDescriptor.java +++ b/src/share/classes/java/beans/PropertyDescriptor.java @@ -112,7 +112,8 @@ public class PropertyDescriptor extends FeatureDescriptor { // If this class or one of its base classes allow PropertyChangeListener, // then we assume that any properties we discover are "bound". // See Introspector.getTargetPropertyInfo() method. - this.bound = null != Introspector.findInstanceMethod(beanClass, "addPropertyChangeListener", PropertyChangeListener.class); + Class[] args = { PropertyChangeListener.class }; + this.bound = null != Introspector.findMethod(beanClass, "addPropertyChangeListener", args.length, args); } /** @@ -223,10 +224,10 @@ public class PropertyDescriptor extends FeatureDescriptor { // property type is. For booleans, there can be "is" and "get" // methods. If an "is" method exists, this is the official // reader method so look for this one first. - readMethod = Introspector.findInstanceMethod(cls, readMethodName); + readMethod = Introspector.findMethod(cls, readMethodName, 0); if (readMethod == null) { readMethodName = Introspector.GET_PREFIX + getBaseName(); - readMethod = Introspector.findInstanceMethod(cls, readMethodName); + readMethod = Introspector.findMethod(cls, readMethodName, 0); } try { setReadMethod(readMethod); @@ -291,7 +292,8 @@ public class PropertyDescriptor extends FeatureDescriptor { writeMethodName = Introspector.SET_PREFIX + getBaseName(); } - writeMethod = Introspector.findInstanceMethod(cls, writeMethodName, type); + Class[] args = (type == null) ? null : new Class[] { type }; + writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args); if (writeMethod != null) { if (!writeMethod.getReturnType().equals(void.class)) { writeMethod = null; diff --git a/src/share/classes/java/util/Locale.java b/src/share/classes/java/util/Locale.java index 49b85866ed32dedec295cf541c5b467d24998ef8..1043c8792c426bd292f1939b988051344c602ca0 100644 --- a/src/share/classes/java/util/Locale.java +++ b/src/share/classes/java/util/Locale.java @@ -569,6 +569,9 @@ public final class Locale implements Cloneable, Serializable { * @exception NullPointerException thrown if any argument is null. */ public Locale(String language, String country, String variant) { + if (language== null || country == null || variant == null) { + throw new NullPointerException(); + } _baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant); _extensions = getCompatibilityExtensions(language, "", country, variant); } diff --git a/src/share/classes/java/util/ResourceBundle.java b/src/share/classes/java/util/ResourceBundle.java index e645fe91439aefd4bcdeb38afc59488e2d5e9b22..9fbdbe1626d2d7df3763ef266c1b748716c8ccfe 100644 --- a/src/share/classes/java/util/ResourceBundle.java +++ b/src/share/classes/java/util/ResourceBundle.java @@ -292,16 +292,6 @@ public abstract class ResourceBundle { private static final ConcurrentMap cacheList = new ConcurrentHashMap(INITIAL_CACHE_SIZE); - /** - * This ConcurrentMap is used to keep multiple threads from loading the - * same bundle concurrently. The table entries are - * where CacheKey is the key for the bundle that is under construction - * and Thread is the thread that is constructing the bundle. - * This list is manipulated in findBundleInCache and putBundleInCache. - */ - private static final ConcurrentMap underConstruction - = new ConcurrentHashMap(); - /** * Queue for reference objects referring to class loaders or bundles. */ @@ -1381,7 +1371,7 @@ public abstract class ResourceBundle { boolean expiredBundle = false; // First, look up the cache to see if it's in the cache, without - // declaring beginLoading. + // attempting to load bundle. cacheKey.setLocale(targetLocale); ResourceBundle bundle = findBundleInCache(cacheKey, control); if (isValidBundle(bundle)) { @@ -1408,56 +1398,25 @@ public abstract class ResourceBundle { CacheKey constKey = (CacheKey) cacheKey.clone(); try { - // Try declaring loading. If beginLoading() returns true, - // then we can proceed. Otherwise, we need to take a look - // at the cache again to see if someone else has loaded - // the bundle and put it in the cache while we've been - // waiting for other loading work to complete. - while (!beginLoading(constKey)) { - bundle = findBundleInCache(cacheKey, control); - if (bundle == null) { - continue; - } - if (bundle == NONEXISTENT_BUNDLE) { - // If the bundle is NONEXISTENT_BUNDLE, the bundle doesn't exist. - return parent; - } - expiredBundle = bundle.expired; - if (!expiredBundle) { - if (bundle.parent == parent) { - return bundle; - } - BundleReference bundleRef = cacheList.get(cacheKey); - if (bundleRef != null && bundleRef.get() == bundle) { - cacheList.remove(cacheKey, bundleRef); - } + bundle = loadBundle(cacheKey, formats, control, expiredBundle); + if (bundle != null) { + if (bundle.parent == null) { + bundle.setParent(parent); } + bundle.locale = targetLocale; + bundle = putBundleInCache(cacheKey, bundle, control); + return bundle; } - try { - bundle = loadBundle(cacheKey, formats, control, expiredBundle); - if (bundle != null) { - if (bundle.parent == null) { - bundle.setParent(parent); - } - bundle.locale = targetLocale; - bundle = putBundleInCache(cacheKey, bundle, control); - return bundle; - } - - // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle - // instance for the locale. - putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); - } finally { - endLoading(constKey); - } + // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle + // instance for the locale. + putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); } finally { if (constKey.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); } } } - assert underConstruction.get(cacheKey) != Thread.currentThread(); return parent; } @@ -1465,7 +1424,6 @@ public abstract class ResourceBundle { List formats, Control control, boolean reload) { - assert underConstruction.get(cacheKey) == Thread.currentThread(); // Here we actually load the bundle in the order of formats // specified by the getFormats() value. @@ -1498,7 +1456,6 @@ public abstract class ResourceBundle { break; } } - assert underConstruction.get(cacheKey) == Thread.currentThread(); return bundle; } @@ -1529,57 +1486,6 @@ public abstract class ResourceBundle { return true; } - /** - * Declares the beginning of actual resource bundle loading. This method - * returns true if the declaration is successful and the current thread has - * been put in underConstruction. If someone else has already begun - * loading, this method waits until that loading work is complete and - * returns false. - */ - private static final boolean beginLoading(CacheKey constKey) { - Thread me = Thread.currentThread(); - Thread worker; - // We need to declare by putting the current Thread (me) to - // underConstruction that we are working on loading the specified - // resource bundle. If we are already working the loading, it means - // that the resource loading requires a recursive call. In that case, - // we have to proceed. (4300693) - if (((worker = underConstruction.putIfAbsent(constKey, me)) == null) - || worker == me) { - return true; - } - - // If someone else is working on the loading, wait until - // the Thread finishes the bundle loading. - synchronized (worker) { - while (underConstruction.get(constKey) == worker) { - try { - worker.wait(); - } catch (InterruptedException e) { - // record the interruption - constKey.setCause(e); - } - } - } - return false; - } - - /** - * Declares the end of the bundle loading. This method calls notifyAll - * for those who are waiting for this completion. - */ - private static final void endLoading(CacheKey constKey) { - // Remove this Thread from the underConstruction map and wake up - // those who have been waiting for me to complete this bundle - // loading. - Thread me = Thread.currentThread(); - assert (underConstruction.get(constKey) == me); - underConstruction.remove(constKey); - synchronized (me) { - me.notifyAll(); - } - } - /** * Throw a MissingResourceException with proper message */ diff --git a/src/share/classes/javax/swing/GroupLayout.java b/src/share/classes/javax/swing/GroupLayout.java index a343b7bc8a19e93d125e1ea06ada5b7cd6541c83..7628076a99473e2a368b816f09d82aea90967220 100644 --- a/src/share/classes/javax/swing/GroupLayout.java +++ b/src/share/classes/javax/swing/GroupLayout.java @@ -1464,8 +1464,8 @@ public class GroupLayout implements LayoutManager2 { * <= {@code pref} <= {@code max}. *

* Similarly any methods that take a {@code Component} throw a - * {@code NullPointerException} if passed {@code null} and any methods - * that take a {@code Group} throw an {@code IllegalArgumentException} if + * {@code IllegalArgumentException} if passed {@code null} and any methods + * that take a {@code Group} throw an {@code NullPointerException} if * passed {@code null}. * * @see #createSequentialGroup diff --git a/src/share/classes/javax/swing/JComponent.java b/src/share/classes/javax/swing/JComponent.java index ae3bddf11826a64be493f299ceeabc63af3925de..f94a797ae6c695113bf43e54a8a88d2fb1bf2d7b 100644 --- a/src/share/classes/javax/swing/JComponent.java +++ b/src/share/classes/javax/swing/JComponent.java @@ -4787,6 +4787,17 @@ public abstract class JComponent extends Container implements Serializable, * @see RepaintManager#addDirtyRegion */ public void repaint(long tm, int x, int y, int width, int height) { + Container p = this; + while ((p = p.getParent()) instanceof JComponent) { + JComponent jp = (JComponent) p; + if (jp.isPaintingOrigin()) { + Rectangle rectangle = SwingUtilities.convertRectangle( + this, new Rectangle(x, y, width, height), jp); + jp.repaint(tm, + rectangle.x, rectangle.y, rectangle.width, rectangle.height); + return; + } + } RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height); } diff --git a/src/share/classes/javax/swing/JDesktopPane.java b/src/share/classes/javax/swing/JDesktopPane.java index 1193cc574fef14971680541ae83eab8b4cb583c2..7ad6753d5e0011ac32a42955a0d1b3efc41c4f11 100644 --- a/src/share/classes/javax/swing/JDesktopPane.java +++ b/src/share/classes/javax/swing/JDesktopPane.java @@ -215,7 +215,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible /** * Sets the DesktopManger that will handle - * desktop-specific UI actions. + * desktop-specific UI actions. This may be overridden by + * {@code LookAndFeel}. * * @param d the DesktopManager to use * diff --git a/src/share/classes/javax/swing/JLayer.java b/src/share/classes/javax/swing/JLayer.java index dd7874c3e70ede40828d8f339a1293a95f3a3485..eab0bf4ab2f9171fff5fd23c06e4f425b207311c 100644 --- a/src/share/classes/javax/swing/JLayer.java +++ b/src/share/classes/javax/swing/JLayer.java @@ -25,17 +25,17 @@ package javax.swing; +import sun.awt.AWTAccessor; + import javax.swing.plaf.LayerUI; +import javax.swing.border.Border; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; import java.io.ObjectInputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.Iterator; import java.security.AccessController; import java.security.PrivilegedAction; @@ -156,8 +156,6 @@ public final class JLayer private LayerUI layerUI; private JPanel glassPane; private boolean isPainting; - private static final DefaultLayerLayout sharedLayoutInstance = - new DefaultLayerLayout(); private long eventMask; private static final LayerEventController eventController = @@ -165,7 +163,7 @@ public final class JLayer /** * Creates a new {@code JLayer} object with a {@code null} view component - * and {@code null} {@link javax.swing.plaf.LayerUI}. + * and default {@link javax.swing.plaf.LayerUI}. * * @see #setView * @see #setUI @@ -176,14 +174,14 @@ public final class JLayer /** * Creates a new {@code JLayer} object - * with {@code null} {@link javax.swing.plaf.LayerUI}. + * with default {@link javax.swing.plaf.LayerUI}. * * @param view the component to be decorated by this {@code JLayer} * * @see #setUI */ public JLayer(V view) { - this(view, null); + this(view, new LayerUI()); } /** @@ -195,7 +193,6 @@ public final class JLayer * to be used by this {@code JLayer} */ public JLayer(V view, LayerUI ui) { - setLayout(sharedLayoutInstance); setGlassPane(createGlassPane()); setView(view); setUI(ui); @@ -279,10 +276,15 @@ public final class JLayer */ public void setGlassPane(JPanel glassPane) { Component oldGlassPane = getGlassPane(); + boolean isGlassPaneVisible = false; if (oldGlassPane != null) { + isGlassPaneVisible = oldGlassPane.isVisible(); super.remove(oldGlassPane); } if (glassPane != null) { + AWTAccessor.getComponentAccessor().setMixingCutoutShape(glassPane, + new Rectangle()); + glassPane.setVisible(isGlassPaneVisible); super.addImpl(glassPane, null, 0); } this.glassPane = glassPane; @@ -302,6 +304,40 @@ public final class JLayer return new DefaultLayerGlassPane(); } + /** + * Sets the layout manager for this container. This method is + * overridden to prevent the layout manager from being set. + *

Note: If {@code mgr} is non-{@code null}, this + * method will throw an exception as layout managers are not supported on + * a {@code JLayer}. + * + * @param mgr the specified layout manager + * @exception IllegalArgumentException this method is not supported + */ + public void setLayout(LayoutManager mgr) { + if (mgr != null) { + throw new IllegalArgumentException("JLayer.setLayout() not supported"); + } + } + + /** + * A non-{@code null] border, or non-zero insets, isn't supported, to prevent the geometry + * of this component from becoming complex enough to inhibit + * subclassing of {@code LayerUI} class. To create a {@code JLayer} with a border, + * add it to a {@code JPanel} that has a border. + *

Note: If {@code border} is non-{@code null}, this + * method will throw an exception as borders are not supported on + * a {@code JLayer}. + * + * @param border the {@code Border} to set + * @exception IllegalArgumentException this method is not supported + */ + public void setBorder(Border border) { + if (border != null) { + throw new IllegalArgumentException("JLayer.setBorder() not supported"); + } + } + /** * This method is not supported by {@code JLayer} * and always throws {@code UnsupportedOperationException} @@ -340,6 +376,32 @@ public final class JLayer setGlassPane(null); } + /** + * Always returns {@code true} to cause painting to originate from {@code JLayer}, + * or one of its ancestors. + * + * @return true + * @see JComponent#isPaintingOrigin() + */ + boolean isPaintingOrigin() { + return true; + } + + /** + * Delegates repainting to {@link javax.swing.plaf.LayerUI#repaint} method. + * + * @param tm this parameter is not used + * @param x the x value of the dirty region + * @param y the y value of the dirty region + * @param width the width of the dirty region + * @param height the height of the dirty region + */ + public void repaint(long tm, int x, int y, int width, int height) { + if (getUI() != null) { + getUI().repaint(tm, x, y, width, height, this); + } + } + /** * Delegates all painting to the {@link javax.swing.plaf.LayerUI} object. * @@ -364,14 +426,18 @@ public final class JLayer } /** - * To enable the correct painting of the {@code glassPane} and view component, - * the {@code JLayer} overrides the default implementation of - * this method to return {@code false} when the {@code glassPane} is visible. - * - * @return false if {@code JLayer}'s {@code glassPane} is visible + * The {@code JLayer} overrides the default implementation of + * this method (in {@code JComponent}) to return {@code false}. + * This ensures + * that the drawing machinery will call the {@code JLayer}'s + * {@code paint} + * implementation rather than messaging the {@code JLayer}'s + * children directly. + * + * @return false */ public boolean isOptimizedDrawingEnabled() { - return glassPane == null || !glassPane.isVisible(); + return false; } /** @@ -461,17 +527,16 @@ public final class JLayer /** * Returns the preferred size of the viewport for a view component. *

- * If the ui delegate of this layer is not {@code null}, this method delegates its - * implementation to the {@code LayerUI.getPreferredScrollableViewportSize(JLayer)} + * If the view component of this layer implements {@link Scrollable}, this method delegates its + * implementation to the view component. * * @return the preferred size of the viewport for a view component * * @see Scrollable - * @see LayerUI#getPreferredScrollableViewportSize(JLayer) */ public Dimension getPreferredScrollableViewportSize() { - if (getUI() != null) { - return getUI().getPreferredScrollableViewportSize(this); + if (getView() instanceof Scrollable) { + return ((Scrollable)getView()).getPreferredScrollableViewportSize(); } return getPreferredSize(); } @@ -481,18 +546,17 @@ public final class JLayer * that display logical rows or columns in order to completely expose * one block of rows or columns, depending on the value of orientation. *

- * If the ui delegate of this layer is not {@code null}, this method delegates its - * implementation to the {@code LayerUI.getScrollableBlockIncrement(JLayer,Rectangle,int,int)} + * If the view component of this layer implements {@link Scrollable}, this method delegates its + * implementation to the view component. * * @return the "block" increment for scrolling in the specified direction * * @see Scrollable - * @see LayerUI#getScrollableBlockIncrement(JLayer, Rectangle, int, int) */ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { - if (getUI() != null) { - return getUI().getScrollableBlockIncrement(this, visibleRect, + if (getView() instanceof Scrollable) { + return ((Scrollable)getView()).getScrollableBlockIncrement(visibleRect, orientation, direction); } return (orientation == SwingConstants.VERTICAL) ? visibleRect.height : @@ -504,17 +568,16 @@ public final class JLayer * determine the height of the layer, unless the preferred height * of the layer is smaller than the height of the viewport. *

- * If the ui delegate of this layer is not null, this method delegates its - * implementation to the {@code LayerUI.getScrollableTracksViewportHeight(JLayer)} + * If the view component of this layer implements {@link Scrollable}, this method delegates its + * implementation to the view component. * * @return whether the layer should track the height of the viewport * * @see Scrollable - * @see LayerUI#getScrollableTracksViewportHeight(JLayer) */ public boolean getScrollableTracksViewportHeight() { - if (getUI() != null) { - return getUI().getScrollableTracksViewportHeight(this); + if (getView() instanceof Scrollable) { + return ((Scrollable)getView()).getScrollableTracksViewportHeight(); } return false; } @@ -524,17 +587,16 @@ public final class JLayer * determine the width of the layer, unless the preferred width * of the layer is smaller than the width of the viewport. *

- * If the ui delegate of this layer is not null, this method delegates its - * implementation to the {@code LayerUI.getScrollableTracksViewportWidth(JLayer)} + * If the view component of this layer implements {@link Scrollable}, this method delegates its + * implementation to the view component. * * @return whether the layer should track the width of the viewport * * @see Scrollable - * @see LayerUI#getScrollableTracksViewportWidth(JLayer) */ public boolean getScrollableTracksViewportWidth() { - if (getUI() != null) { - return getUI().getScrollableTracksViewportWidth(this); + if (getView() instanceof Scrollable) { + return ((Scrollable)getView()).getScrollableTracksViewportWidth(); } return false; } @@ -549,20 +611,19 @@ public final class JLayer * Scrolling containers, like {@code JScrollPane}, will use this method * each time the user requests a unit scroll. *

- * If the ui delegate of this layer is not {@code null}, this method delegates its - * implementation to the {@code LayerUI.getScrollableUnitIncrement(JLayer,Rectangle,int,int)} + * If the view component of this layer implements {@link Scrollable}, this method delegates its + * implementation to the view component. * * @return The "unit" increment for scrolling in the specified direction. * This value should always be positive. * * @see Scrollable - * @see LayerUI#getScrollableUnitIncrement(JLayer, Rectangle, int, int) */ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { - if (getUI() != null) { - return getUI().getScrollableUnitIncrement( - this, visibleRect, orientation, direction); + if (getView() instanceof Scrollable) { + return ((Scrollable) getView()).getScrollableUnitIncrement( + visibleRect, orientation, direction); } return 1; } @@ -594,6 +655,16 @@ public final class JLayer eventController.updateAWTEventListener(eventMask, 0); } + /** + * Delegates its functionality to the {@link javax.swing.plaf.LayerUI#doLayout(JLayer)} method, + * if {@code LayerUI} is set. + */ + public void doLayout() { + if (getUI() != null) { + getUI().doLayout(this); + } + } + /** * static AWTEventListener to be shared with all AbstractLayerUIs */ @@ -625,8 +696,8 @@ public final class JLayer JLayer l = (JLayer) component; LayerUI ui = l.getUI(); if (ui != null && - isEventEnabled(l.getLayerEventMask(), - event.getID())) { + isEventEnabled(l.getLayerEventMask(), event.getID()) && + (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) { ui.eventDispatched(event, l); } } @@ -758,82 +829,4 @@ public final class JLayer return super.contains(x, y); } } - - /** - * The default layout manager for the {@link javax.swing.JLayer}.
- * It places the glassPane on top of the view component - * and makes it the same size as {@code JLayer}, - * it also makes the view component the same size but minus layer's insets
- */ - private static class DefaultLayerLayout implements LayoutManager, Serializable { - /** - * {@inheritDoc} - */ - public void layoutContainer(Container parent) { - JLayer layer = (JLayer) parent; - Component view = layer.getView(); - Component glassPane = layer.getGlassPane(); - if (view != null) { - Insets insets = layer.getInsets(); - view.setLocation(insets.left, insets.top); - view.setSize(layer.getWidth() - insets.left - insets.right, - layer.getHeight() - insets.top - insets.bottom); - } - if (glassPane != null) { - glassPane.setLocation(0, 0); - glassPane.setSize(layer.getWidth(), layer.getHeight()); - } - } - - /** - * {@inheritDoc} - */ - public Dimension minimumLayoutSize(Container parent) { - JLayer layer = (JLayer) parent; - Insets insets = layer.getInsets(); - Dimension ret = new Dimension(insets.left + insets.right, - insets.top + insets.bottom); - Component view = layer.getView(); - if (view != null) { - Dimension size = view.getMinimumSize(); - ret.width += size.width; - ret.height += size.height; - } - if (ret.width == 0 || ret.height == 0) { - ret.width = ret.height = 4; - } - return ret; - } - - /** - * {@inheritDoc} - */ - public Dimension preferredLayoutSize(Container parent) { - JLayer layer = (JLayer) parent; - Insets insets = layer.getInsets(); - Dimension ret = new Dimension(insets.left + insets.right, - insets.top + insets.bottom); - Component view = layer.getView(); - if (view != null) { - Dimension size = view.getPreferredSize(); - if (size.width > 0 && size.height > 0) { - ret.width += size.width; - ret.height += size.height; - } - } - return ret; - } - - /** - * {@inheritDoc} - */ - public void addLayoutComponent(String name, Component comp) { - } - - /** - * {@inheritDoc} - */ - public void removeLayoutComponent(Component comp) { - } - } } diff --git a/src/share/classes/javax/swing/JTable.java b/src/share/classes/javax/swing/JTable.java index bcf00a37547994701c288ee1bd899c3d30dba878..7842410e772acb225a438fdae0f111210b252baa 100644 --- a/src/share/classes/javax/swing/JTable.java +++ b/src/share/classes/javax/swing/JTable.java @@ -4574,9 +4574,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * @see TableColumnModelListener */ public void columnMoved(TableColumnModelEvent e) { - // If I'm currently editing, then I should stop editing - if (isEditing()) { - removeEditor(); + if (isEditing() && !getCellEditor().stopCellEditing()) { + getCellEditor().cancelCellEditing(); } repaint(); } @@ -4593,8 +4592,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * @see TableColumnModelListener */ public void columnMarginChanged(ChangeEvent e) { - if (isEditing()) { - removeEditor(); + if (isEditing() && !getCellEditor().stopCellEditing()) { + getCellEditor().cancelCellEditing(); } TableColumn resizingColumn = getResizingColumn(); // Need to do this here, before the parent's diff --git a/src/share/classes/javax/swing/ToolTipManager.java b/src/share/classes/javax/swing/ToolTipManager.java index 17bda0fdcff02a50fefe68dfe9d9288e2a1634f1..ff4aa2c2ac93396fec63122fdb9267440b77d885 100644 --- a/src/share/classes/javax/swing/ToolTipManager.java +++ b/src/share/classes/javax/swing/ToolTipManager.java @@ -459,7 +459,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener if (insideComponent == null) { // Drag exit } - if (window != null && event.getSource() == window) { + if (window != null && event.getSource() == window && insideComponent != null) { // if we get an exit and have a heavy window // we need to check if it if overlapping the inside component Container insideComponentWindow = insideComponent.getTopLevelAncestor(); diff --git a/src/share/classes/javax/swing/plaf/LayerUI.java b/src/share/classes/javax/swing/plaf/LayerUI.java index 2cfa8e185ccceb33ecf94ab803b2a2ef27d2be69..1fb757313a4db0b1a8d31fc084b30041f1e11ff9 100644 --- a/src/share/classes/javax/swing/plaf/LayerUI.java +++ b/src/share/classes/javax/swing/plaf/LayerUI.java @@ -600,136 +600,124 @@ public class LayerUI } /** - * Returns the preferred size of the viewport for a view component. + * If the {@code JLayer}'s view component is not {@code null}, + * this calls the view's {@code getBaseline()} method. + * Otherwise, the default implementation is called. * - * @param l the {@code JLayer} component where this UI delegate is being installed - * @return the preferred size of the viewport for a view component - * @see Scrollable#getPreferredScrollableViewportSize() + * @param c {@code JLayer} to return baseline resize behavior for + * @param width the width to get the baseline for + * @param height the height to get the baseline for + * @return baseline or a value < 0 indicating there is no reasonable + * baseline */ - public Dimension getPreferredScrollableViewportSize(JLayer l) { - if (l.getView() instanceof Scrollable) { - return ((Scrollable)l.getView()).getPreferredScrollableViewportSize(); + public int getBaseline(JComponent c, int width, int height) { + JLayer l = (JLayer) c; + if (l.getView() != null) { + return l.getView().getBaseline(width, height); } - return l.getPreferredSize(); - } + return super.getBaseline(c, width, height); + } /** - * Returns a scroll increment, which is required for components - * that display logical rows or columns in order to completely expose - * one block of rows or columns, depending on the value of orientation. + * If the {@code JLayer}'s view component is not {@code null}, + * this returns the result of the view's {@code getBaselineResizeBehavior()} method. + * Otherwise, the default implementation is called. * - * @param l the {@code JLayer} component where this UI delegate is being installed - * @param visibleRect The view area visible within the viewport - * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL. - * @param direction Less than zero to scroll up/left, greater than zero for down/right. - * @return the "block" increment for scrolling in the specified direction - * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int) + * @param c {@code JLayer} to return baseline resize behavior for + * @return an enum indicating how the baseline changes as the component + * size changes */ - public int getScrollableBlockIncrement(JLayer l, - Rectangle visibleRect, - int orientation, int direction) { - if (l.getView() instanceof Scrollable) { - return ((Scrollable)l.getView()).getScrollableBlockIncrement( - visibleRect,orientation, direction); + public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) { + JLayer l = (JLayer) c; + if (l.getView() != null) { + return l.getView().getBaselineResizeBehavior(); } - return (orientation == SwingConstants.VERTICAL) ? visibleRect.height : - visibleRect.width; + return super.getBaselineResizeBehavior(c); } /** - * Returns {@code false} to indicate that the height of the viewport does not - * determine the height of the layer, unless the preferred height - * of the layer is smaller than the height of the viewport. + * Causes the passed instance of {@code JLayer} to lay out its components. * * @param l the {@code JLayer} component where this UI delegate is being installed - * @return whether the layer should track the height of the viewport - * @see Scrollable#getScrollableTracksViewportHeight() */ - public boolean getScrollableTracksViewportHeight(JLayer l) { - if (l.getView() instanceof Scrollable) { - return ((Scrollable)l.getView()).getScrollableTracksViewportHeight(); + public void doLayout(JLayer l) { + Component view = l.getView(); + if (view != null) { + view.setBounds(0, 0, l.getWidth(), l.getHeight()); + } + Component glassPane = l.getGlassPane(); + if (glassPane != null) { + glassPane.setBounds(0, 0, l.getWidth(), l.getHeight()); } - return false; } /** - * Returns {@code false} to indicate that the width of the viewport does not - * determine the width of the layer, unless the preferred width - * of the layer is smaller than the width of the viewport. + * If the {@code JLayer}'s view component is not {@code null}, + * this returns the result of the view's {@code getPreferredSize()} method. + * Otherwise, the default implementation is used. * - * @param l the {@code JLayer} component where this UI delegate is being installed - * @return whether the layer should track the width of the viewport - * @see Scrollable - * @see LayerUI#getScrollableTracksViewportWidth(JLayer) + * @param c {@code JLayer} to return preferred size for + * @return preferred size for the passed {@code JLayer} */ - public boolean getScrollableTracksViewportWidth(JLayer l) { - if (l.getView() instanceof Scrollable) { - return ((Scrollable)l.getView()).getScrollableTracksViewportWidth(); + public Dimension getPreferredSize(JComponent c) { + JLayer l = (JLayer) c; + Component view = l.getView(); + if (view != null) { + return view.getPreferredSize(); } - return false; + return super.getPreferredSize(c); } /** - * Returns a scroll increment, which is required for components - * that display logical rows or columns in order to completely expose - * one new row or column, depending on the value of orientation. - * Ideally, components should handle a partially exposed row or column - * by returning the distance required to completely expose the item. - *

- * Scrolling containers, like JScrollPane, will use this method - * each time the user requests a unit scroll. + * If the {@code JLayer}'s view component is not {@code null}, + * this returns the result of the view's {@code getMinimalSize()} method. + * Otherwise, the default implementation is used. * - * @param l the {@code JLayer} component where this UI delegate is being installed - * @param visibleRect The view area visible within the viewport - * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL. - * @param direction Less than zero to scroll up/left, greater than zero for down/right. - * @return The "unit" increment for scrolling in the specified direction. - * This value should always be positive. - * @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int) + * @param c {@code JLayer} to return preferred size for + * @return minimal size for the passed {@code JLayer} */ - public int getScrollableUnitIncrement(JLayer l, - Rectangle visibleRect, - int orientation, int direction) { - if (l.getView() instanceof Scrollable) { - return ((Scrollable)l.getView()).getScrollableUnitIncrement( - visibleRect, orientation, direction); + public Dimension getMinimumSize(JComponent c) { + JLayer l = (JLayer) c; + Component view = l.getView(); + if (view != null) { + return view.getMinimumSize(); } - return 1; + return super.getMinimumSize(c); } /** * If the {@code JLayer}'s view component is not {@code null}, - * this calls the view's {@code getBaseline()} method. - * Otherwise, the default implementation is called. + * this returns the result of the view's {@code getMaximumSize()} method. + * Otherwise, the default implementation is used. * - * @param c {@code JLayer} to return baseline resize behavior for - * @param width the width to get the baseline for - * @param height the height to get the baseline for - * @return baseline or a value < 0 indicating there is no reasonable - * baseline + * @param c {@code JLayer} to return preferred size for + * @return maximun size for the passed {@code JLayer} */ - public int getBaseline(JComponent c, int width, int height) { + public Dimension getMaximumSize(JComponent c) { JLayer l = (JLayer) c; - if (l.getView() != null) { - return l.getView().getBaseline(width, height); + Component view = l.getView(); + if (view != null) { + return view.getMaximumSize(); } - return super.getBaseline(c, width, height); - } + return super.getMaximumSize(c); + } /** - * If the {@code JLayer}'s view component is not {@code null}, - * this calls the view's {@code getBaselineResizeBehavior()} method. - * Otherwise, the default implementation is called. - * - * @param c {@code JLayer} to return baseline resize behavior for - * @return an enum indicating how the baseline changes as the component - * size changes + * Adds the specified region to the dirty region list if the component + * is showing. The component will be repainted after all of the + * currently pending events have been dispatched. + *

+ * This method is to be overridden when the dirty region needs to be changed. + * + * @param tm this parameter is not used + * @param x the x value of the dirty region + * @param y the y value of the dirty region + * @param width the width of the dirty region + * @param height the height of the dirty region + * @see java.awt.Component#isShowing + * @see RepaintManager#addDirtyRegion */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) { - JLayer l = (JLayer) c; - if (l.getView() != null) { - return l.getView().getBaselineResizeBehavior(); - } - return super.getBaselineResizeBehavior(c); + public void repaint(long tm, int x, int y, int width, int height, JLayer l) { + RepaintManager.currentManager(l).addDirtyRegion(l, x, y, width, height); } } diff --git a/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java b/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java index deba91beff3af44b6e3fc5e9438a6a0aad2d32c2..52204916ce5498fedeb044b14252fcbd5634714a 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java @@ -1603,6 +1603,7 @@ public class BasicScrollBarUI BoundedRangeModel newModel = (BoundedRangeModel)e.getNewValue(); oldModel.removeChangeListener(modelListener); newModel.addChangeListener(modelListener); + scrollBarValue = scrollbar.getValue(); scrollbar.repaint(); scrollbar.revalidate(); } else if ("orientation" == propertyName) { diff --git a/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java b/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java index 77742db410f7086898512496bd840fac030cc0a2..e7c811b0c2214bd3b6c3298409a1913b6adf9860 100644 --- a/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java +++ b/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java @@ -144,7 +144,7 @@ public class MetalComboBoxUI extends BasicComboBoxUI { */ public int getBaseline(JComponent c, int width, int height) { int baseline; - if (MetalLookAndFeel.usingOcean()) { + if (MetalLookAndFeel.usingOcean() && height >= 4) { height -= 4; baseline = super.getBaseline(c, width, height); if (baseline >= 0) { diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java index 4c6b446be08ee12b53ff76cde21057c653fd5b2a..ea67ac038527198933137e6e127ef410693d0ef2 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java @@ -115,6 +115,9 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI return new SynthTabbedPaneUI(); } + private SynthTabbedPaneUI() { + } + private boolean scrollableTabLayoutEnabled() { return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT); } diff --git a/src/share/classes/sun/util/locale/BaseLocale.java b/src/share/classes/sun/util/locale/BaseLocale.java index a3314826f6b5b7213786c2d470ea1594e4e35ac8..2137dbd86918d6e9430460653cdffdc6370862c0 100644 --- a/src/share/classes/sun/util/locale/BaseLocale.java +++ b/src/share/classes/sun/util/locale/BaseLocale.java @@ -64,12 +64,14 @@ public final class BaseLocale { public static BaseLocale getInstance(String language, String script, String region, String variant) { // JDK uses deprecated ISO639.1 language codes for he, yi and id - if (AsciiUtil.caseIgnoreMatch(language, "he")) { - language = "iw"; - } else if (AsciiUtil.caseIgnoreMatch(language, "yi")) { - language = "ji"; - } else if (AsciiUtil.caseIgnoreMatch(language, "id")) { - language = "in"; + if (language != null) { + if (AsciiUtil.caseIgnoreMatch(language, "he")) { + language = "iw"; + } else if (AsciiUtil.caseIgnoreMatch(language, "yi")) { + language = "ji"; + } else if (AsciiUtil.caseIgnoreMatch(language, "id")) { + language = "in"; + } } Key key = new Key(language, script, region, variant); diff --git a/src/solaris/native/sun/awt/awt_InputMethod.c b/src/solaris/native/sun/awt/awt_InputMethod.c index fbaf35cfff32c139cf3fd627446c20b9fce1f589..549e51986f61bf50875b1ee121209fcb634ecefd 100644 --- a/src/solaris/native/sun/awt/awt_InputMethod.c +++ b/src/solaris/native/sun/awt/awt_InputMethod.c @@ -1473,6 +1473,10 @@ static void OpenXIMCallback(Display *display, XPointer client_data, XPointer cal static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) { /* mark that XIM server was destroyed */ X11im = NULL; + JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); + /* free the old pX11IMData and set it to null. this also avoids crashing + * the jvm if the XIM server reappears */ + X11InputMethodData *pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance); } /* diff --git a/src/windows/lib/tzmappings b/src/windows/lib/tzmappings index 05309c9aef8f3f3d067d873e18a4168a88421d51..bbc3ca09ce23c0baebc929c26bbd0ddc05a628ee 100644 --- a/src/windows/lib/tzmappings +++ b/src/windows/lib/tzmappings @@ -1,5 +1,4 @@ # -# # This file describes mapping information between Windows and Java # time zones. # Format: Each line should include a colon separated fields of Windows @@ -11,7 +10,7 @@ # NOTE # This table format is not a public interface of any Java # platforms. No applications should depend on this file in any form. -# +# # This table has been generated by a program and should not be edited # manually. # @@ -84,8 +83,8 @@ Ekaterinburg:10,11::Asia/Yekaterinburg: Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg: West Asia:10,11:UZ:Asia/Tashkent: West Asia Standard Time:10,11:UZ:Asia/Tashkent: -Central Asia:12,13::Asia/Dhaka: -Central Asia Standard Time:12,13::Asia/Dhaka: +Central Asia:12,13::Asia/Almaty: +Central Asia Standard Time:12,13::Asia/Almaty: N. Central Asia Standard Time:12,13::Asia/Novosibirsk: Bangkok:14,15::Asia/Bangkok: Bangkok Standard Time:14,15::Asia/Bangkok: @@ -167,22 +166,27 @@ Greenwich:88,89::GMT: Greenwich Standard Time:88,89::GMT: Argentina Standard Time:900,900::America/Buenos_Aires: Azerbaijan Standard Time:901,901:AZ:Asia/Baku: -Central Brazilian Standard Time:902,902:BR:America/Manaus: -Central Standard Time (Mexico):903,903::America/Mexico_City: -Georgian Standard Time:904,904:GE:Asia/Tbilisi: -Jordan Standard Time:905,905:JO:Asia/Amman: -Mauritius Standard Time:906,906:MU:Indian/Mauritius: -Middle East Standard Time:907,907:LB:Asia/Beirut: -Montevideo Standard Time:908,908:UY:America/Montevideo: -Morocco Standard Time:909,909:MA:Africa/Casablanca: -Mountain Standard Time (Mexico):910,910:MX:America/Chihuahua: -Namibia Standard Time:911,911:NA:Africa/Windhoek: -Pacific Standard Time (Mexico):912,912:MX:America/Tijuana: -Pakistan Standard Time:913,913::Asia/Karachi: -UTC:914,914::UTC: -Venezuela Standard Time:915,915::America/Caracas: -Kamchatka Standard Time:916,916:RU:Asia/Kamchatka: -Paraguay Standard Time:917,917:PY:America/Asuncion: -Western Brazilian Standard Time:918,918:BR:America/Rio_Branco: -Ulaanbaatar Standard Time:919,919::Asia/Ulaanbaatar: -Armenian Standard Time:920,920:AM:Asia/Yerevan: +Bangladesh Standard Time:902,902::Asia/Dhaka: +Central Brazilian Standard Time:903,903:BR:America/Manaus: +Central Standard Time (Mexico):904,904::America/Mexico_City: +Georgian Standard Time:905,905:GE:Asia/Tbilisi: +Jordan Standard Time:906,906:JO:Asia/Amman: +Kamchatka Standard Time:907,907:RU:Asia/Kamchatka: +Mauritius Standard Time:908,908:MU:Indian/Mauritius: +Middle East Standard Time:909,909:LB:Asia/Beirut: +Montevideo Standard Time:910,910:UY:America/Montevideo: +Morocco Standard Time:911,911:MA:Africa/Casablanca: +Mountain Standard Time (Mexico):912,912:MX:America/Chihuahua: +Namibia Standard Time:913,913:NA:Africa/Windhoek: +Pacific Standard Time (Mexico):914,914:MX:America/Tijuana: +Pakistan Standard Time:915,915::Asia/Karachi: +Paraguay Standard Time:916,916:PY:America/Asuncion: +Syria Standard Time:917,917:SY:Asia/Damascus: +UTC:918,918::UTC: +UTC+12:919,919::GMT+1200: +UTC-02:920,920::GMT-0200: +UTC-11:921,921::GMT-1100: +Ulaanbaatar Standard Time:922,922::Asia/Ulaanbaatar: +Venezuela Standard Time:923,923::America/Caracas: +Western Brazilian Standard Time:924,924:BR:America/Rio_Branco: +Armenian Standard Time:925,925:AM:Asia/Yerevan: diff --git a/test/java/beans/Introspector/6976577/Test6976577.java b/test/java/beans/Introspector/6976577/Test6976577.java new file mode 100644 index 0000000000000000000000000000000000000000..61e1771231fb6aad0895bfd15a320c5420aa121c --- /dev/null +++ b/test/java/beans/Introspector/6976577/Test6976577.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2010, 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 6976577 + * @summary Tests public methods in non-public beans + * @author Sergey Malenkov + */ + +import test.Accessor; + +import java.beans.EventSetDescriptor; +import java.beans.IndexedPropertyDescriptor; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; + +public class Test6976577 { + + public static void main(String[] args) throws Exception { + Class bt = Accessor.getBeanType(); + Class lt = Accessor.getListenerType(); + + // test PropertyDescriptor + PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); + test(pd.getReadMethod()); + test(pd.getWriteMethod()); + + // test IndexedPropertyDescriptor + IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); + test(ipd.getReadMethod()); + test(ipd.getWriteMethod()); + test(ipd.getIndexedReadMethod()); + test(ipd.getIndexedWriteMethod()); + + // test EventSetDescriptor + EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); + test(esd.getAddListenerMethod()); + test(esd.getRemoveListenerMethod()); + test(esd.getGetListenerMethod()); + test(esd.getListenerMethods()); + } + + private static void test(Method... methods) { + for (Method method : methods) { + if (method == null) { + throw new Error("public method is not found"); + } + } + } +} diff --git a/test/java/beans/Introspector/6976577/test/Accessor.java b/test/java/beans/Introspector/6976577/test/Accessor.java new file mode 100644 index 0000000000000000000000000000000000000000..a7a7090bc114ed7f300f0847c7b32791c664c14b --- /dev/null +++ b/test/java/beans/Introspector/6976577/test/Accessor.java @@ -0,0 +1,81 @@ +package test; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.EventListener; +import java.util.TooManyListenersException; + +public class Accessor { + + public static Class getBeanType() { + return Bean.class; + } + + public static Class getListenerType() { + return TestListener.class; + } +} + +interface TestEvent { +} + +interface TestListener extends EventListener { + void process(TestEvent event); +} + +class Bean { + + private boolean b; + private int[] indexed; + private TestListener listener; + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public void addPropertyChangeListener(PropertyChangeListener listener) { + this.pcs.addPropertyChangeListener(listener); + } + + public void addTestListener(TestListener listener) throws TooManyListenersException { + if (listener != null) { + if (this.listener != null) { + throw new TooManyListenersException(); + } + this.listener = listener; + } + } + + public void removeTestListener(TestListener listener) { + if (this.listener == listener) { + this.listener = null; + } + } + + public TestListener[] getTestListeners() { + return (this.listener != null) + ? new TestListener[] { this.listener } + : new TestListener[0]; + } + + public boolean isBoolean() { + return this.b; + } + + public void setBoolean(boolean b) { + this.b = b; + } + + public int[] getIndexed() { + return this.indexed; + } + + public void setIndexed(int[] values) { + this.indexed = values; + } + + public int getIndexed(int index) { + return this.indexed[index]; + } + + public void setIndexed(int index, int value) { + this.indexed[index] = value; + } +} diff --git a/test/javax/swing/JComboBox/6632953/bug6632953.java b/test/javax/swing/JComboBox/6632953/bug6632953.java new file mode 100644 index 0000000000000000000000000000000000000000..90352765eb7a19f7e71d1c8c49b154f16d41570d --- /dev/null +++ b/test/javax/swing/JComboBox/6632953/bug6632953.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2010, 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 6632953 + * @summary MetalComboBoxUI.getBaseline(JComponent, int, int) throws IAE for valid width/height + * @author Alexander Potochkin + */ + +import javax.swing.JComboBox; +import javax.swing.plaf.metal.MetalComboBoxUI; + +public class bug6632953 { + + public static void main(String... args) throws Exception { + MetalComboBoxUI ui = new MetalComboBoxUI(); + ui.installUI(new JComboBox()); + ui.getBaseline(new JComboBox(), 0, 0); + ui.getBaseline(new JComboBox(), 1, 1); + ui.getBaseline(new JComboBox(), 2, 2); + ui.getBaseline(new JComboBox(), 3, 3); + ui.getBaseline(new JComboBox(), 4, 4); + } +} diff --git a/test/javax/swing/JScrollBar/6542335/bug6542335.java b/test/javax/swing/JScrollBar/6542335/bug6542335.java new file mode 100644 index 0000000000000000000000000000000000000000..33e95d8ecac74a6c9c3963b5fc6f1566ef8e5c9b --- /dev/null +++ b/test/javax/swing/JScrollBar/6542335/bug6542335.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2010, 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 6542335 + @summary different behavior on knob of scroll bar between 1.4.2 and 5.0 + @author Alexander Potochkin + @run main bug6542335 +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.plaf.basic.BasicScrollBarUI; +import java.awt.*; +import java.awt.event.InputEvent; + +public class bug6542335 { + private static JScrollBar sb; + private static MyScrollBarUI ui; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(10); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final JFrame frame = new JFrame("bug6542335"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + sb = new JScrollBar(0, 0, 1, 0, 1); + + ui = new MyScrollBarUI(); + sb.setUI(ui); + + sb.setPreferredSize(new Dimension(200, 17)); + DefaultBoundedRangeModel rangeModel = new DefaultBoundedRangeModel(); + rangeModel.setMaximum(100); + rangeModel.setMinimum(0); + rangeModel.setExtent(50); + rangeModel.setValue(50); + + sb.setModel(rangeModel); + frame.add(sb); + + frame.setSize(200, 100); + frame.setVisible(true); + } + }); + + Rectangle thumbBounds = new Rectangle(ui.getThumbBounds()); + + toolkit.realSync(); + Point l = sb.getLocationOnScreen(); + robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight()/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + if (!thumbBounds.equals(ui.getThumbBounds())) { + throw new RuntimeException("Test failed"); + } + } + + static class MyScrollBarUI extends BasicScrollBarUI { + public Rectangle getThumbBounds() { + return super.getThumbBounds(); + } + } +} diff --git a/test/javax/swing/JTable/Test6888156.java b/test/javax/swing/JTable/Test6888156.java index 79809e582a1604de51d498b4a43cda74d20e11b3..f82d8026be40270fed4dfbf2dfc7cd2a9ed03bc3 100644 --- a/test/javax/swing/JTable/Test6888156.java +++ b/test/javax/swing/JTable/Test6888156.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2010, 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 @@ -71,14 +71,14 @@ public class Test6888156 { table = new JTable(model); } - public void test(final LookAndFeel laf) throws Exception { + public void test(final String laf) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { try { + System.out.println(laf); UIManager.setLookAndFeel(laf); - } catch (UnsupportedLookAndFeelException e) { - System.err.println(laf.getDescription() + - " is unsupported; continuing"); + } catch (Exception e) { + System.err.println(laf + " is unsupported; continuing"); return; } SwingUtilities.updateComponentTreeUI(table); @@ -92,8 +92,10 @@ public class Test6888156 { public static void main(String[] args) throws Exception { Test6888156 t = new Test6888156(); - t.test(new javax.swing.plaf.nimbus.NimbusLookAndFeel()); - t.test(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel()); + t.test("javax.swing.plaf.nimbus.NimbusLookAndFeel"); + t.test("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + t.test(laf.getClassName()); + } } } - diff --git a/test/javax/swing/JTextArea/6940863/bug6940863.java b/test/javax/swing/JTextArea/6940863/bug6940863.java index ffcd2d44aa54f64de278470acf51cc945933faf1..b868d41adfc10b7afae40f650d8e8d1ad49b2d04 100644 --- a/test/javax/swing/JTextArea/6940863/bug6940863.java +++ b/test/javax/swing/JTextArea/6940863/bug6940863.java @@ -56,6 +56,7 @@ public class bug6940863 { public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { System.out.println("The test is suitable only for Windows OS. Skipped"); + return; } UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");