提交 f7a6ec10 编写于 作者: L lana

Merge

...@@ -176,8 +176,9 @@ public class EventSetDescriptor extends FeatureDescriptor { ...@@ -176,8 +176,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1)); setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1));
// Be more forgiving of not finding the getListener method. // Be more forgiving of not finding the getListener method.
if (getListenerMethodName != null) { Method method = Introspector.findMethod(sourceClass, getListenerMethodName, 0);
setGetListenerMethod(Introspector.findInstanceMethod(sourceClass, getListenerMethodName)); if (method != null) {
setGetListenerMethod(method);
} }
} }
......
...@@ -189,11 +189,13 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { ...@@ -189,11 +189,13 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); 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) { if (indexedReadMethod == null) {
// no "is" method, so look for a "get" method. // no "is" method, so look for a "get" method.
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); indexedReadMethodName = Introspector.GET_PREFIX + getBaseName();
indexedReadMethod = Introspector.findInstanceMethod(cls, indexedReadMethodName, int.class); indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args);
} }
setIndexedReadMethod0(indexedReadMethod); setIndexedReadMethod0(indexedReadMethod);
} }
...@@ -265,7 +267,9 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { ...@@ -265,7 +267,9 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
if (indexedWriteMethodName == null) { if (indexedWriteMethodName == null) {
indexedWriteMethodName = Introspector.SET_PREFIX + getBaseName(); 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 != null) {
if (!indexedWriteMethod.getReturnType().equals(void.class)) { if (!indexedWriteMethod.getReturnType().equals(void.class)) {
indexedWriteMethod = null; indexedWriteMethod = null;
......
...@@ -28,7 +28,6 @@ package java.beans; ...@@ -28,7 +28,6 @@ package java.beans;
import com.sun.beans.WeakCache; import com.sun.beans.WeakCache;
import com.sun.beans.finder.BeanInfoFinder; import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder; import com.sun.beans.finder.ClassFinder;
import com.sun.beans.finder.MethodFinder;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
...@@ -843,8 +842,8 @@ public class Introspector { ...@@ -843,8 +842,8 @@ public class Introspector {
Method read = result.getReadMethod(); Method read = result.getReadMethod();
if (read == null && write != null) { if (read == null && write != null) {
read = findInstanceMethod(result.getClass0(), read = findMethod(result.getClass0(),
GET_PREFIX + NameGenerator.capitalize(result.getName())); GET_PREFIX + NameGenerator.capitalize(result.getName()), 0);
if (read != null) { if (read != null) {
try { try {
result.setReadMethod(read); result.setReadMethod(read);
...@@ -854,9 +853,9 @@ public class Introspector { ...@@ -854,9 +853,9 @@ public class Introspector {
} }
} }
if (write == null && read != null) { if (write == null && read != null) {
write = findInstanceMethod(result.getClass0(), write = findMethod(result.getClass0(),
SET_PREFIX + NameGenerator.capitalize(result.getName()), SET_PREFIX + NameGenerator.capitalize(result.getName()), 1,
FeatureDescriptor.getReturnType(result.getClass0(), read)); new Class[] { FeatureDescriptor.getReturnType(result.getClass0(), read) });
if (write != null) { if (write != null) {
try { try {
result.setWriteMethod(write); result.setWriteMethod(write);
...@@ -1280,27 +1279,90 @@ public class Introspector { ...@@ -1280,27 +1279,90 @@ public class Introspector {
// Package private support methods. // Package private support methods.
//====================================================================== //======================================================================
static Method findMethod(Class<?> type, String name, int args) { /**
for (Method method : type.getMethods()) { * Internal support for finding a target methodName with a given
if (method.getName().equals(name) && (args == method.getParameterTypes().length)) { * parameter list on a given class.
try { */
return MethodFinder.findAccessibleMethod(method); 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 { * Find a target methodName on a given class.
return MethodFinder.findInstanceMethod(type, name, args); */
} static Method findMethod(Class cls, String methodName, int argCount) {
catch (NoSuchMethodException exception) { return findMethod(cls, methodName, argCount, null);
}
/**
* Find a target methodName with specific parameter list on a given class.
* <p>
* Used in the contructors of the EventSetDescriptor,
* PropertyDescriptor and the IndexedPropertyDescriptor.
* <p>
* @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 null;
} }
return internalFindMethod(cls, methodName, argCount, args);
} }
/** /**
......
...@@ -90,13 +90,13 @@ public class MethodDescriptor extends FeatureDescriptor { ...@@ -90,13 +90,13 @@ public class MethodDescriptor extends FeatureDescriptor {
// Find methods for up to 2 params. We are guessing here. // Find methods for up to 2 params. We are guessing here.
// This block should never execute unless the classloader // This block should never execute unless the classloader
// that loaded the argument classes disappears. // that loaded the argument classes disappears.
method = Introspector.findMethod(cls, name, i); method = Introspector.findMethod(cls, name, i, null);
if (method != null) { if (method != null) {
break; break;
} }
} }
} else { } else {
method = Statement.getMethod(cls, name, params); method = Introspector.findMethod(cls, name, params.length, params);
} }
setMethod(method); setMethod(method);
} }
......
...@@ -112,7 +112,8 @@ public class PropertyDescriptor extends FeatureDescriptor { ...@@ -112,7 +112,8 @@ public class PropertyDescriptor extends FeatureDescriptor {
// If this class or one of its base classes allow PropertyChangeListener, // If this class or one of its base classes allow PropertyChangeListener,
// then we assume that any properties we discover are "bound". // then we assume that any properties we discover are "bound".
// See Introspector.getTargetPropertyInfo() method. // 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 { ...@@ -223,10 +224,10 @@ public class PropertyDescriptor extends FeatureDescriptor {
// property type is. For booleans, there can be "is" and "get" // property type is. For booleans, there can be "is" and "get"
// methods. If an "is" method exists, this is the official // methods. If an "is" method exists, this is the official
// reader method so look for this one first. // reader method so look for this one first.
readMethod = Introspector.findInstanceMethod(cls, readMethodName); readMethod = Introspector.findMethod(cls, readMethodName, 0);
if (readMethod == null) { if (readMethod == null) {
readMethodName = Introspector.GET_PREFIX + getBaseName(); readMethodName = Introspector.GET_PREFIX + getBaseName();
readMethod = Introspector.findInstanceMethod(cls, readMethodName); readMethod = Introspector.findMethod(cls, readMethodName, 0);
} }
try { try {
setReadMethod(readMethod); setReadMethod(readMethod);
...@@ -291,7 +292,8 @@ public class PropertyDescriptor extends FeatureDescriptor { ...@@ -291,7 +292,8 @@ public class PropertyDescriptor extends FeatureDescriptor {
writeMethodName = Introspector.SET_PREFIX + getBaseName(); 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 != null) {
if (!writeMethod.getReturnType().equals(void.class)) { if (!writeMethod.getReturnType().equals(void.class)) {
writeMethod = null; writeMethod = null;
......
...@@ -569,6 +569,9 @@ public final class Locale implements Cloneable, Serializable { ...@@ -569,6 +569,9 @@ public final class Locale implements Cloneable, Serializable {
* @exception NullPointerException thrown if any argument is null. * @exception NullPointerException thrown if any argument is null.
*/ */
public Locale(String language, String country, String variant) { 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); _baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
_extensions = getCompatibilityExtensions(language, "", country, variant); _extensions = getCompatibilityExtensions(language, "", country, variant);
} }
......
...@@ -292,16 +292,6 @@ public abstract class ResourceBundle { ...@@ -292,16 +292,6 @@ public abstract class ResourceBundle {
private static final ConcurrentMap<CacheKey, BundleReference> cacheList private static final ConcurrentMap<CacheKey, BundleReference> cacheList
= new ConcurrentHashMap<CacheKey, BundleReference>(INITIAL_CACHE_SIZE); = new ConcurrentHashMap<CacheKey, BundleReference>(INITIAL_CACHE_SIZE);
/**
* This ConcurrentMap is used to keep multiple threads from loading the
* same bundle concurrently. The table entries are <CacheKey, Thread>
* 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<CacheKey, Thread> underConstruction
= new ConcurrentHashMap<CacheKey, Thread>();
/** /**
* Queue for reference objects referring to class loaders or bundles. * Queue for reference objects referring to class loaders or bundles.
*/ */
...@@ -1381,7 +1371,7 @@ public abstract class ResourceBundle { ...@@ -1381,7 +1371,7 @@ public abstract class ResourceBundle {
boolean expiredBundle = false; boolean expiredBundle = false;
// First, look up the cache to see if it's in the cache, without // First, look up the cache to see if it's in the cache, without
// declaring beginLoading. // attempting to load bundle.
cacheKey.setLocale(targetLocale); cacheKey.setLocale(targetLocale);
ResourceBundle bundle = findBundleInCache(cacheKey, control); ResourceBundle bundle = findBundleInCache(cacheKey, control);
if (isValidBundle(bundle)) { if (isValidBundle(bundle)) {
...@@ -1408,56 +1398,25 @@ public abstract class ResourceBundle { ...@@ -1408,56 +1398,25 @@ public abstract class ResourceBundle {
CacheKey constKey = (CacheKey) cacheKey.clone(); CacheKey constKey = (CacheKey) cacheKey.clone();
try { try {
// Try declaring loading. If beginLoading() returns true, bundle = loadBundle(cacheKey, formats, control, expiredBundle);
// then we can proceed. Otherwise, we need to take a look if (bundle != null) {
// at the cache again to see if someone else has loaded if (bundle.parent == null) {
// the bundle and put it in the cache while we've been bundle.setParent(parent);
// 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.locale = targetLocale;
bundle = putBundleInCache(cacheKey, bundle, control);
return bundle;
} }
try { // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle
bundle = loadBundle(cacheKey, formats, control, expiredBundle); // instance for the locale.
if (bundle != null) { putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control);
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);
}
} finally { } finally {
if (constKey.getCause() instanceof InterruptedException) { if (constKey.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
} }
assert underConstruction.get(cacheKey) != Thread.currentThread();
return parent; return parent;
} }
...@@ -1465,7 +1424,6 @@ public abstract class ResourceBundle { ...@@ -1465,7 +1424,6 @@ public abstract class ResourceBundle {
List<String> formats, List<String> formats,
Control control, Control control,
boolean reload) { boolean reload) {
assert underConstruction.get(cacheKey) == Thread.currentThread();
// Here we actually load the bundle in the order of formats // Here we actually load the bundle in the order of formats
// specified by the getFormats() value. // specified by the getFormats() value.
...@@ -1498,7 +1456,6 @@ public abstract class ResourceBundle { ...@@ -1498,7 +1456,6 @@ public abstract class ResourceBundle {
break; break;
} }
} }
assert underConstruction.get(cacheKey) == Thread.currentThread();
return bundle; return bundle;
} }
...@@ -1529,57 +1486,6 @@ public abstract class ResourceBundle { ...@@ -1529,57 +1486,6 @@ public abstract class ResourceBundle {
return true; 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 * Throw a MissingResourceException with proper message
*/ */
......
...@@ -1464,8 +1464,8 @@ public class GroupLayout implements LayoutManager2 { ...@@ -1464,8 +1464,8 @@ public class GroupLayout implements LayoutManager2 {
* &lt;= {@code pref} &lt;= {@code max}. * &lt;= {@code pref} &lt;= {@code max}.
* <p> * <p>
* Similarly any methods that take a {@code Component} throw a * Similarly any methods that take a {@code Component} throw a
* {@code NullPointerException} if passed {@code null} and any methods * {@code IllegalArgumentException} if passed {@code null} and any methods
* that take a {@code Group} throw an {@code IllegalArgumentException} if * that take a {@code Group} throw an {@code NullPointerException} if
* passed {@code null}. * passed {@code null}.
* *
* @see #createSequentialGroup * @see #createSequentialGroup
......
...@@ -4787,6 +4787,17 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -4787,6 +4787,17 @@ public abstract class JComponent extends Container implements Serializable,
* @see RepaintManager#addDirtyRegion * @see RepaintManager#addDirtyRegion
*/ */
public void repaint(long tm, int x, int y, int width, int height) { 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); RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height);
} }
......
...@@ -215,7 +215,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible ...@@ -215,7 +215,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible
/** /**
* Sets the <code>DesktopManger</code> that will handle * Sets the <code>DesktopManger</code> that will handle
* desktop-specific UI actions. * desktop-specific UI actions. This may be overridden by
* {@code LookAndFeel}.
* *
* @param d the <code>DesktopManager</code> to use * @param d the <code>DesktopManager</code> to use
* *
......
...@@ -25,17 +25,17 @@ ...@@ -25,17 +25,17 @@
package javax.swing; package javax.swing;
import sun.awt.AWTAccessor;
import javax.swing.plaf.LayerUI; import javax.swing.plaf.LayerUI;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
...@@ -156,8 +156,6 @@ public final class JLayer<V extends Component> ...@@ -156,8 +156,6 @@ public final class JLayer<V extends Component>
private LayerUI<? super V> layerUI; private LayerUI<? super V> layerUI;
private JPanel glassPane; private JPanel glassPane;
private boolean isPainting; private boolean isPainting;
private static final DefaultLayerLayout sharedLayoutInstance =
new DefaultLayerLayout();
private long eventMask; private long eventMask;
private static final LayerEventController eventController = private static final LayerEventController eventController =
...@@ -165,7 +163,7 @@ public final class JLayer<V extends Component> ...@@ -165,7 +163,7 @@ public final class JLayer<V extends Component>
/** /**
* Creates a new {@code JLayer} object with a {@code null} view component * 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 #setView
* @see #setUI * @see #setUI
...@@ -176,14 +174,14 @@ public final class JLayer<V extends Component> ...@@ -176,14 +174,14 @@ public final class JLayer<V extends Component>
/** /**
* Creates a new {@code JLayer} object * 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} * @param view the component to be decorated by this {@code JLayer}
* *
* @see #setUI * @see #setUI
*/ */
public JLayer(V view) { public JLayer(V view) {
this(view, null); this(view, new LayerUI<V>());
} }
/** /**
...@@ -195,7 +193,6 @@ public final class JLayer<V extends Component> ...@@ -195,7 +193,6 @@ public final class JLayer<V extends Component>
* to be used by this {@code JLayer} * to be used by this {@code JLayer}
*/ */
public JLayer(V view, LayerUI<V> ui) { public JLayer(V view, LayerUI<V> ui) {
setLayout(sharedLayoutInstance);
setGlassPane(createGlassPane()); setGlassPane(createGlassPane());
setView(view); setView(view);
setUI(ui); setUI(ui);
...@@ -279,10 +276,15 @@ public final class JLayer<V extends Component> ...@@ -279,10 +276,15 @@ public final class JLayer<V extends Component>
*/ */
public void setGlassPane(JPanel glassPane) { public void setGlassPane(JPanel glassPane) {
Component oldGlassPane = getGlassPane(); Component oldGlassPane = getGlassPane();
boolean isGlassPaneVisible = false;
if (oldGlassPane != null) { if (oldGlassPane != null) {
isGlassPaneVisible = oldGlassPane.isVisible();
super.remove(oldGlassPane); super.remove(oldGlassPane);
} }
if (glassPane != null) { if (glassPane != null) {
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glassPane,
new Rectangle());
glassPane.setVisible(isGlassPaneVisible);
super.addImpl(glassPane, null, 0); super.addImpl(glassPane, null, 0);
} }
this.glassPane = glassPane; this.glassPane = glassPane;
...@@ -302,6 +304,40 @@ public final class JLayer<V extends Component> ...@@ -302,6 +304,40 @@ public final class JLayer<V extends Component>
return new DefaultLayerGlassPane(); return new DefaultLayerGlassPane();
} }
/**
* Sets the layout manager for this container. This method is
* overridden to prevent the layout manager from being set.
* <p/>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.
* <p/>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} * This method is not supported by {@code JLayer}
* and always throws {@code UnsupportedOperationException} * and always throws {@code UnsupportedOperationException}
...@@ -340,6 +376,32 @@ public final class JLayer<V extends Component> ...@@ -340,6 +376,32 @@ public final class JLayer<V extends Component>
setGlassPane(null); 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. * Delegates all painting to the {@link javax.swing.plaf.LayerUI} object.
* *
...@@ -364,14 +426,18 @@ public final class JLayer<V extends Component> ...@@ -364,14 +426,18 @@ public final class JLayer<V extends Component>
} }
/** /**
* To enable the correct painting of the {@code glassPane} and view component, * The {@code JLayer} overrides the default implementation of
* the {@code JLayer} overrides the default implementation of * this method (in {@code JComponent}) to return {@code false}.
* this method to return {@code false} when the {@code glassPane} is visible. * This ensures
* * that the drawing machinery will call the {@code JLayer}'s
* @return false if {@code JLayer}'s {@code glassPane} is visible * {@code paint}
* implementation rather than messaging the {@code JLayer}'s
* children directly.
*
* @return false
*/ */
public boolean isOptimizedDrawingEnabled() { public boolean isOptimizedDrawingEnabled() {
return glassPane == null || !glassPane.isVisible(); return false;
} }
/** /**
...@@ -461,17 +527,16 @@ public final class JLayer<V extends Component> ...@@ -461,17 +527,16 @@ public final class JLayer<V extends Component>
/** /**
* Returns the preferred size of the viewport for a view component. * Returns the preferred size of the viewport for a view component.
* <p/> * <p/>
* If the ui delegate of this layer is not {@code null}, this method delegates its * If the view component of this layer implements {@link Scrollable}, this method delegates its
* implementation to the {@code LayerUI.getPreferredScrollableViewportSize(JLayer)} * implementation to the view component.
* *
* @return the preferred size of the viewport for a view component * @return the preferred size of the viewport for a view component
* *
* @see Scrollable * @see Scrollable
* @see LayerUI#getPreferredScrollableViewportSize(JLayer)
*/ */
public Dimension getPreferredScrollableViewportSize() { public Dimension getPreferredScrollableViewportSize() {
if (getUI() != null) { if (getView() instanceof Scrollable) {
return getUI().getPreferredScrollableViewportSize(this); return ((Scrollable)getView()).getPreferredScrollableViewportSize();
} }
return getPreferredSize(); return getPreferredSize();
} }
...@@ -481,18 +546,17 @@ public final class JLayer<V extends Component> ...@@ -481,18 +546,17 @@ public final class JLayer<V extends Component>
* that display logical rows or columns in order to completely expose * that display logical rows or columns in order to completely expose
* one block of rows or columns, depending on the value of orientation. * one block of rows or columns, depending on the value of orientation.
* <p/> * <p/>
* If the ui delegate of this layer is not {@code null}, this method delegates its * If the view component of this layer implements {@link Scrollable}, this method delegates its
* implementation to the {@code LayerUI.getScrollableBlockIncrement(JLayer,Rectangle,int,int)} * implementation to the view component.
* *
* @return the "block" increment for scrolling in the specified direction * @return the "block" increment for scrolling in the specified direction
* *
* @see Scrollable * @see Scrollable
* @see LayerUI#getScrollableBlockIncrement(JLayer, Rectangle, int, int)
*/ */
public int getScrollableBlockIncrement(Rectangle visibleRect, public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction) { int orientation, int direction) {
if (getUI() != null) { if (getView() instanceof Scrollable) {
return getUI().getScrollableBlockIncrement(this, visibleRect, return ((Scrollable)getView()).getScrollableBlockIncrement(visibleRect,
orientation, direction); orientation, direction);
} }
return (orientation == SwingConstants.VERTICAL) ? visibleRect.height : return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
...@@ -504,17 +568,16 @@ public final class JLayer<V extends Component> ...@@ -504,17 +568,16 @@ public final class JLayer<V extends Component>
* determine the height of the layer, unless the preferred height * determine the height of the layer, unless the preferred height
* of the layer is smaller than the height of the viewport. * of the layer is smaller than the height of the viewport.
* <p/> * <p/>
* If the ui delegate of this layer is not null, this method delegates its * If the view component of this layer implements {@link Scrollable}, this method delegates its
* implementation to the {@code LayerUI.getScrollableTracksViewportHeight(JLayer)} * implementation to the view component.
* *
* @return whether the layer should track the height of the viewport * @return whether the layer should track the height of the viewport
* *
* @see Scrollable * @see Scrollable
* @see LayerUI#getScrollableTracksViewportHeight(JLayer)
*/ */
public boolean getScrollableTracksViewportHeight() { public boolean getScrollableTracksViewportHeight() {
if (getUI() != null) { if (getView() instanceof Scrollable) {
return getUI().getScrollableTracksViewportHeight(this); return ((Scrollable)getView()).getScrollableTracksViewportHeight();
} }
return false; return false;
} }
...@@ -524,17 +587,16 @@ public final class JLayer<V extends Component> ...@@ -524,17 +587,16 @@ public final class JLayer<V extends Component>
* determine the width of the layer, unless the preferred width * determine the width of the layer, unless the preferred width
* of the layer is smaller than the width of the viewport. * of the layer is smaller than the width of the viewport.
* <p/> * <p/>
* If the ui delegate of this layer is not null, this method delegates its * If the view component of this layer implements {@link Scrollable}, this method delegates its
* implementation to the {@code LayerUI.getScrollableTracksViewportWidth(JLayer)} * implementation to the view component.
* *
* @return whether the layer should track the width of the viewport * @return whether the layer should track the width of the viewport
* *
* @see Scrollable * @see Scrollable
* @see LayerUI#getScrollableTracksViewportWidth(JLayer)
*/ */
public boolean getScrollableTracksViewportWidth() { public boolean getScrollableTracksViewportWidth() {
if (getUI() != null) { if (getView() instanceof Scrollable) {
return getUI().getScrollableTracksViewportWidth(this); return ((Scrollable)getView()).getScrollableTracksViewportWidth();
} }
return false; return false;
} }
...@@ -549,20 +611,19 @@ public final class JLayer<V extends Component> ...@@ -549,20 +611,19 @@ public final class JLayer<V extends Component>
* Scrolling containers, like {@code JScrollPane}, will use this method * Scrolling containers, like {@code JScrollPane}, will use this method
* each time the user requests a unit scroll. * each time the user requests a unit scroll.
* <p/> * <p/>
* If the ui delegate of this layer is not {@code null}, this method delegates its * If the view component of this layer implements {@link Scrollable}, this method delegates its
* implementation to the {@code LayerUI.getScrollableUnitIncrement(JLayer,Rectangle,int,int)} * implementation to the view component.
* *
* @return The "unit" increment for scrolling in the specified direction. * @return The "unit" increment for scrolling in the specified direction.
* This value should always be positive. * This value should always be positive.
* *
* @see Scrollable * @see Scrollable
* @see LayerUI#getScrollableUnitIncrement(JLayer, Rectangle, int, int)
*/ */
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
int direction) { int direction) {
if (getUI() != null) { if (getView() instanceof Scrollable) {
return getUI().getScrollableUnitIncrement( return ((Scrollable) getView()).getScrollableUnitIncrement(
this, visibleRect, orientation, direction); visibleRect, orientation, direction);
} }
return 1; return 1;
} }
...@@ -594,6 +655,16 @@ public final class JLayer<V extends Component> ...@@ -594,6 +655,16 @@ public final class JLayer<V extends Component>
eventController.updateAWTEventListener(eventMask, 0); 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 * static AWTEventListener to be shared with all AbstractLayerUIs
*/ */
...@@ -625,8 +696,8 @@ public final class JLayer<V extends Component> ...@@ -625,8 +696,8 @@ public final class JLayer<V extends Component>
JLayer l = (JLayer) component; JLayer l = (JLayer) component;
LayerUI ui = l.getUI(); LayerUI ui = l.getUI();
if (ui != null && if (ui != null &&
isEventEnabled(l.getLayerEventMask(), isEventEnabled(l.getLayerEventMask(), event.getID()) &&
event.getID())) { (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
ui.eventDispatched(event, l); ui.eventDispatched(event, l);
} }
} }
...@@ -758,82 +829,4 @@ public final class JLayer<V extends Component> ...@@ -758,82 +829,4 @@ public final class JLayer<V extends Component>
return super.contains(x, y); return super.contains(x, y);
} }
} }
/**
* The default layout manager for the {@link javax.swing.JLayer}.<br/>
* 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<br/>
*/
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) {
}
}
} }
...@@ -4574,9 +4574,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -4574,9 +4574,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see TableColumnModelListener * @see TableColumnModelListener
*/ */
public void columnMoved(TableColumnModelEvent e) { public void columnMoved(TableColumnModelEvent e) {
// If I'm currently editing, then I should stop editing if (isEditing() && !getCellEditor().stopCellEditing()) {
if (isEditing()) { getCellEditor().cancelCellEditing();
removeEditor();
} }
repaint(); repaint();
} }
...@@ -4593,8 +4592,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -4593,8 +4592,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see TableColumnModelListener * @see TableColumnModelListener
*/ */
public void columnMarginChanged(ChangeEvent e) { public void columnMarginChanged(ChangeEvent e) {
if (isEditing()) { if (isEditing() && !getCellEditor().stopCellEditing()) {
removeEditor(); getCellEditor().cancelCellEditing();
} }
TableColumn resizingColumn = getResizingColumn(); TableColumn resizingColumn = getResizingColumn();
// Need to do this here, before the parent's // Need to do this here, before the parent's
......
...@@ -459,7 +459,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener ...@@ -459,7 +459,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
if (insideComponent == null) { if (insideComponent == null) {
// Drag exit // 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 // if we get an exit and have a heavy window
// we need to check if it if overlapping the inside component // we need to check if it if overlapping the inside component
Container insideComponentWindow = insideComponent.getTopLevelAncestor(); Container insideComponentWindow = insideComponent.getTopLevelAncestor();
......
...@@ -600,136 +600,124 @@ public class LayerUI<V extends Component> ...@@ -600,136 +600,124 @@ public class LayerUI<V extends Component>
} }
/** /**
* 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 * @param c {@code JLayer} to return baseline resize behavior for
* @return the preferred size of the viewport for a view component * @param width the width to get the baseline for
* @see Scrollable#getPreferredScrollableViewportSize() * @param height the height to get the baseline for
* @return baseline or a value &lt; 0 indicating there is no reasonable
* baseline
*/ */
public Dimension getPreferredScrollableViewportSize(JLayer<? extends V> l) { public int getBaseline(JComponent c, int width, int height) {
if (l.getView() instanceof Scrollable) { JLayer l = (JLayer) c;
return ((Scrollable)l.getView()).getPreferredScrollableViewportSize(); 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 * If the {@code JLayer}'s view component is not {@code null},
* that display logical rows or columns in order to completely expose * this returns the result of the view's {@code getBaselineResizeBehavior()} method.
* one block of rows or columns, depending on the value of orientation. * Otherwise, the default implementation is called.
* *
* @param l the {@code JLayer} component where this UI delegate is being installed * @param c {@code JLayer} to return baseline resize behavior for
* @param visibleRect The view area visible within the viewport * @return an enum indicating how the baseline changes as the component
* @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL. * size changes
* @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)
*/ */
public int getScrollableBlockIncrement(JLayer<? extends V> l, public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
Rectangle visibleRect, JLayer l = (JLayer) c;
int orientation, int direction) { if (l.getView() != null) {
if (l.getView() instanceof Scrollable) { return l.getView().getBaselineResizeBehavior();
return ((Scrollable)l.getView()).getScrollableBlockIncrement(
visibleRect,orientation, direction);
} }
return (orientation == SwingConstants.VERTICAL) ? visibleRect.height : return super.getBaselineResizeBehavior(c);
visibleRect.width;
} }
/** /**
* Returns {@code false} to indicate that the height of the viewport does not * Causes the passed instance of {@code JLayer} to lay out its components.
* determine the height of the layer, unless the preferred height
* of the layer is smaller than the height of the viewport.
* *
* @param l the {@code JLayer} component where this UI delegate is being installed * @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<? extends V> l) { public void doLayout(JLayer<? extends V> l) {
if (l.getView() instanceof Scrollable) { Component view = l.getView();
return ((Scrollable)l.getView()).getScrollableTracksViewportHeight(); 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 * If the {@code JLayer}'s view component is not {@code null},
* determine the width of the layer, unless the preferred width * this returns the result of the view's {@code getPreferredSize()} method.
* of the layer is smaller than the width of the viewport. * Otherwise, the default implementation is used.
* *
* @param l the {@code JLayer} component where this UI delegate is being installed * @param c {@code JLayer} to return preferred size for
* @return whether the layer should track the width of the viewport * @return preferred size for the passed {@code JLayer}
* @see Scrollable
* @see LayerUI#getScrollableTracksViewportWidth(JLayer)
*/ */
public boolean getScrollableTracksViewportWidth(JLayer<? extends V> l) { public Dimension getPreferredSize(JComponent c) {
if (l.getView() instanceof Scrollable) { JLayer l = (JLayer) c;
return ((Scrollable)l.getView()).getScrollableTracksViewportWidth(); 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 * If the {@code JLayer}'s view component is not {@code null},
* that display logical rows or columns in order to completely expose * this returns the result of the view's {@code getMinimalSize()} method.
* one new row or column, depending on the value of orientation. * Otherwise, the default implementation is used.
* Ideally, components should handle a partially exposed row or column
* by returning the distance required to completely expose the item.
* <p>
* Scrolling containers, like JScrollPane, will use this method
* each time the user requests a unit scroll.
* *
* @param l the {@code JLayer} component where this UI delegate is being installed * @param c {@code JLayer} to return preferred size for
* @param visibleRect The view area visible within the viewport * @return minimal size for the passed {@code JLayer}
* @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)
*/ */
public int getScrollableUnitIncrement(JLayer<? extends V> l, public Dimension getMinimumSize(JComponent c) {
Rectangle visibleRect, JLayer l = (JLayer) c;
int orientation, int direction) { Component view = l.getView();
if (l.getView() instanceof Scrollable) { if (view != null) {
return ((Scrollable)l.getView()).getScrollableUnitIncrement( return view.getMinimumSize();
visibleRect, orientation, direction);
} }
return 1; return super.getMinimumSize(c);
} }
/** /**
* If the {@code JLayer}'s view component is not {@code null}, * If the {@code JLayer}'s view component is not {@code null},
* this calls the view's {@code getBaseline()} method. * this returns the result of the view's {@code getMaximumSize()} method.
* Otherwise, the default implementation is called. * Otherwise, the default implementation is used.
* *
* @param c {@code JLayer} to return baseline resize behavior for * @param c {@code JLayer} to return preferred size for
* @param width the width to get the baseline for * @return maximun size for the passed {@code JLayer}
* @param height the height to get the baseline for
* @return baseline or a value &lt; 0 indicating there is no reasonable
* baseline
*/ */
public int getBaseline(JComponent c, int width, int height) { public Dimension getMaximumSize(JComponent c) {
JLayer l = (JLayer) c; JLayer l = (JLayer) c;
if (l.getView() != null) { Component view = l.getView();
return l.getView().getBaseline(width, height); 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}, * Adds the specified region to the dirty region list if the component
* this calls the view's {@code getBaselineResizeBehavior()} method. * is showing. The component will be repainted after all of the
* Otherwise, the default implementation is called. * currently pending events have been dispatched.
* * <p/>
* @param c {@code JLayer} to return baseline resize behavior for * This method is to be overridden when the dirty region needs to be changed.
* @return an enum indicating how the baseline changes as the component *
* size changes * @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) { public void repaint(long tm, int x, int y, int width, int height, JLayer<? extends V> l) {
JLayer l = (JLayer) c; RepaintManager.currentManager(l).addDirtyRegion(l, x, y, width, height);
if (l.getView() != null) {
return l.getView().getBaselineResizeBehavior();
}
return super.getBaselineResizeBehavior(c);
} }
} }
...@@ -1603,6 +1603,7 @@ public class BasicScrollBarUI ...@@ -1603,6 +1603,7 @@ public class BasicScrollBarUI
BoundedRangeModel newModel = (BoundedRangeModel)e.getNewValue(); BoundedRangeModel newModel = (BoundedRangeModel)e.getNewValue();
oldModel.removeChangeListener(modelListener); oldModel.removeChangeListener(modelListener);
newModel.addChangeListener(modelListener); newModel.addChangeListener(modelListener);
scrollBarValue = scrollbar.getValue();
scrollbar.repaint(); scrollbar.repaint();
scrollbar.revalidate(); scrollbar.revalidate();
} else if ("orientation" == propertyName) { } else if ("orientation" == propertyName) {
......
...@@ -144,7 +144,7 @@ public class MetalComboBoxUI extends BasicComboBoxUI { ...@@ -144,7 +144,7 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
*/ */
public int getBaseline(JComponent c, int width, int height) { public int getBaseline(JComponent c, int width, int height) {
int baseline; int baseline;
if (MetalLookAndFeel.usingOcean()) { if (MetalLookAndFeel.usingOcean() && height >= 4) {
height -= 4; height -= 4;
baseline = super.getBaseline(c, width, height); baseline = super.getBaseline(c, width, height);
if (baseline >= 0) { if (baseline >= 0) {
......
...@@ -115,6 +115,9 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI ...@@ -115,6 +115,9 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
return new SynthTabbedPaneUI(); return new SynthTabbedPaneUI();
} }
private SynthTabbedPaneUI() {
}
private boolean scrollableTabLayoutEnabled() { private boolean scrollableTabLayoutEnabled() {
return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT); return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT);
} }
......
...@@ -64,12 +64,14 @@ public final class BaseLocale { ...@@ -64,12 +64,14 @@ public final class BaseLocale {
public static BaseLocale getInstance(String language, String script, String region, String variant) { public static BaseLocale getInstance(String language, String script, String region, String variant) {
// JDK uses deprecated ISO639.1 language codes for he, yi and id // JDK uses deprecated ISO639.1 language codes for he, yi and id
if (AsciiUtil.caseIgnoreMatch(language, "he")) { if (language != null) {
language = "iw"; if (AsciiUtil.caseIgnoreMatch(language, "he")) {
} else if (AsciiUtil.caseIgnoreMatch(language, "yi")) { language = "iw";
language = "ji"; } else if (AsciiUtil.caseIgnoreMatch(language, "yi")) {
} else if (AsciiUtil.caseIgnoreMatch(language, "id")) { language = "ji";
language = "in"; } else if (AsciiUtil.caseIgnoreMatch(language, "id")) {
language = "in";
}
} }
Key key = new Key(language, script, region, variant); Key key = new Key(language, script, region, variant);
......
...@@ -1473,6 +1473,10 @@ static void OpenXIMCallback(Display *display, XPointer client_data, XPointer cal ...@@ -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) { static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) {
/* mark that XIM server was destroyed */ /* mark that XIM server was destroyed */
X11im = NULL; 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);
} }
/* /*
......
# #
#
# This file describes mapping information between Windows and Java # This file describes mapping information between Windows and Java
# time zones. # time zones.
# Format: Each line should include a colon separated fields of Windows # Format: Each line should include a colon separated fields of Windows
...@@ -11,7 +10,7 @@ ...@@ -11,7 +10,7 @@
# NOTE # NOTE
# This table format is not a public interface of any Java # This table format is not a public interface of any Java
# platforms. No applications should depend on this file in any form. # platforms. No applications should depend on this file in any form.
# #
# This table has been generated by a program and should not be edited # This table has been generated by a program and should not be edited
# manually. # manually.
# #
...@@ -84,8 +83,8 @@ Ekaterinburg:10,11::Asia/Yekaterinburg: ...@@ -84,8 +83,8 @@ Ekaterinburg:10,11::Asia/Yekaterinburg:
Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg: Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg:
West Asia:10,11:UZ:Asia/Tashkent: West Asia:10,11:UZ:Asia/Tashkent:
West Asia Standard Time:10,11:UZ:Asia/Tashkent: West Asia Standard Time:10,11:UZ:Asia/Tashkent:
Central Asia:12,13::Asia/Dhaka: Central Asia:12,13::Asia/Almaty:
Central Asia Standard Time:12,13::Asia/Dhaka: Central Asia Standard Time:12,13::Asia/Almaty:
N. Central Asia Standard Time:12,13::Asia/Novosibirsk: N. Central Asia Standard Time:12,13::Asia/Novosibirsk:
Bangkok:14,15::Asia/Bangkok: Bangkok:14,15::Asia/Bangkok:
Bangkok Standard Time:14,15::Asia/Bangkok: Bangkok Standard Time:14,15::Asia/Bangkok:
...@@ -167,22 +166,27 @@ Greenwich:88,89::GMT: ...@@ -167,22 +166,27 @@ Greenwich:88,89::GMT:
Greenwich Standard Time:88,89::GMT: Greenwich Standard Time:88,89::GMT:
Argentina Standard Time:900,900::America/Buenos_Aires: Argentina Standard Time:900,900::America/Buenos_Aires:
Azerbaijan Standard Time:901,901:AZ:Asia/Baku: Azerbaijan Standard Time:901,901:AZ:Asia/Baku:
Central Brazilian Standard Time:902,902:BR:America/Manaus: Bangladesh Standard Time:902,902::Asia/Dhaka:
Central Standard Time (Mexico):903,903::America/Mexico_City: Central Brazilian Standard Time:903,903:BR:America/Manaus:
Georgian Standard Time:904,904:GE:Asia/Tbilisi: Central Standard Time (Mexico):904,904::America/Mexico_City:
Jordan Standard Time:905,905:JO:Asia/Amman: Georgian Standard Time:905,905:GE:Asia/Tbilisi:
Mauritius Standard Time:906,906:MU:Indian/Mauritius: Jordan Standard Time:906,906:JO:Asia/Amman:
Middle East Standard Time:907,907:LB:Asia/Beirut: Kamchatka Standard Time:907,907:RU:Asia/Kamchatka:
Montevideo Standard Time:908,908:UY:America/Montevideo: Mauritius Standard Time:908,908:MU:Indian/Mauritius:
Morocco Standard Time:909,909:MA:Africa/Casablanca: Middle East Standard Time:909,909:LB:Asia/Beirut:
Mountain Standard Time (Mexico):910,910:MX:America/Chihuahua: Montevideo Standard Time:910,910:UY:America/Montevideo:
Namibia Standard Time:911,911:NA:Africa/Windhoek: Morocco Standard Time:911,911:MA:Africa/Casablanca:
Pacific Standard Time (Mexico):912,912:MX:America/Tijuana: Mountain Standard Time (Mexico):912,912:MX:America/Chihuahua:
Pakistan Standard Time:913,913::Asia/Karachi: Namibia Standard Time:913,913:NA:Africa/Windhoek:
UTC:914,914::UTC: Pacific Standard Time (Mexico):914,914:MX:America/Tijuana:
Venezuela Standard Time:915,915::America/Caracas: Pakistan Standard Time:915,915::Asia/Karachi:
Kamchatka Standard Time:916,916:RU:Asia/Kamchatka: Paraguay Standard Time:916,916:PY:America/Asuncion:
Paraguay Standard Time:917,917:PY:America/Asuncion: Syria Standard Time:917,917:SY:Asia/Damascus:
Western Brazilian Standard Time:918,918:BR:America/Rio_Branco: UTC:918,918::UTC:
Ulaanbaatar Standard Time:919,919::Asia/Ulaanbaatar: UTC+12:919,919::GMT+1200:
Armenian Standard Time:920,920:AM:Asia/Yerevan: 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:
/*
* 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");
}
}
}
}
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;
}
}
/*
* 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);
}
}
/*
* 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();
}
}
}
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -71,14 +71,14 @@ public class Test6888156 { ...@@ -71,14 +71,14 @@ public class Test6888156 {
table = new JTable(model); table = new JTable(model);
} }
public void test(final LookAndFeel laf) throws Exception { public void test(final String laf) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() { @Override public void run() {
try { try {
System.out.println(laf);
UIManager.setLookAndFeel(laf); UIManager.setLookAndFeel(laf);
} catch (UnsupportedLookAndFeelException e) { } catch (Exception e) {
System.err.println(laf.getDescription() + System.err.println(laf + " is unsupported; continuing");
" is unsupported; continuing");
return; return;
} }
SwingUtilities.updateComponentTreeUI(table); SwingUtilities.updateComponentTreeUI(table);
...@@ -92,8 +92,10 @@ public class Test6888156 { ...@@ -92,8 +92,10 @@ public class Test6888156 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Test6888156 t = new Test6888156(); Test6888156 t = new Test6888156();
t.test(new javax.swing.plaf.nimbus.NimbusLookAndFeel()); t.test("javax.swing.plaf.nimbus.NimbusLookAndFeel");
t.test(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel()); t.test("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
t.test(laf.getClassName());
}
} }
} }
...@@ -56,6 +56,7 @@ public class bug6940863 { ...@@ -56,6 +56,7 @@ public class bug6940863 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
System.out.println("The test is suitable only for Windows OS. Skipped"); System.out.println("The test is suitable only for Windows OS. Skipped");
return;
} }
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册