--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -146,6 +146,8 @@
* @param out The code output stream.
* @return An expression whose value is <code>oldInstance</code>.
*
+ * @throws NullPointerException if {@code out} is {@code null}
+ *
* @see #DefaultPersistenceDelegate(String[])
*/
protected Expression instantiate(Object oldInstance, Encoder out) {
@@ -367,6 +369,8 @@
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
*
+ * @throws NullPointerException if {@code out} is {@code null}
+ *
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.PropertyDescriptor
*/
--- a/jdk/src/share/classes/java/beans/Encoder.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Encoder.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -112,54 +112,82 @@
/**
* Returns the persistence delegate for the given type.
- * The persistence delegate is calculated
- * by applying the following of rules in order:
- * <ul>
+ * The persistence delegate is calculated by applying
+ * the following rules in order:
+ * <ol>
+ * <li>
+ * If a persistence delegate is associated with the given type
+ * by using the {@link #setPersistenceDelegate} method
+ * it is returned.
* <li>
- * If the type is an array, an internal persistence
- * delegate is returned which will instantiate an
- * array of the appropriate type and length, initializing
- * each of its elements as if they are properties.
+ * A persistence delegate is then looked up by the name
+ * composed of the the fully qualified name of the given type
+ * and the "PersistenceDelegate" postfix.
+ * For example, a persistence delegate for the {@code Bean} class
+ * should be named {@code BeanPersistenceDelegate}
+ * and located in the same package.
+ * <pre>
+ * public class Bean { ... }
+ * public class BeanPersistenceDelegate { ... }</pre>
+ * The instance of the {@code BeanPersistenceDelegate} class
+ * is returned for the {@code Bean} class.
+ * <li>
+ * If the type is {@code null},
+ * a shared internal persistence delegate is returned
+ * that encodes {@code null} value.
* <li>
- * If the type is a proxy, an internal persistence
- * delegate is returned which will instantiate a
- * new proxy instance using the static
- * "newProxyInstance" method defined in the
- * Proxy class.
+ * If the type is a {@code enum} declaration,
+ * a shared internal persistence delegate is returned
+ * that encodes constants of this enumeration
+ * by their names.
+ * <li>
+ * If the type is a primitive type or the corresponding wrapper,
+ * a shared internal persistence delegate is returned
+ * that encodes values of the given type.
+ * <li>
+ * If the type is an array,
+ * a shared internal persistence delegate is returned
+ * that encodes an array of the appropriate type and length,
+ * and each of its elements as if they are properties.
* <li>
- * If the BeanInfo for this type has a <code>BeanDescriptor</code>
- * which defined a "persistenceDelegate" property, this
- * value is returned.
+ * If the type is a proxy,
+ * a shared internal persistence delegate is returned
+ * that encodes a proxy instance by using
+ * the {@link java.lang.reflect.Proxy#newProxyInstance} method.
* <li>
- * In all other cases the default persistence delegate
- * is returned. The default persistence delegate assumes
- * the type is a <em>JavaBean</em>, implying that it has a default constructor
- * and that its state may be characterized by the matching pairs
- * of "setter" and "getter" methods returned by the Introspector.
+ * If the {@link BeanInfo} for this type has a {@link BeanDescriptor}
+ * which defined a "persistenceDelegate" attribute,
+ * the value of this named attribute is returned.
+ * <li>
+ * In all other cases the default persistence delegate is returned.
+ * The default persistence delegate assumes the type is a <em>JavaBean</em>,
+ * implying that it has a default constructor and that its state
+ * may be characterized by the matching pairs of "setter" and "getter"
+ * methods returned by the {@link Introspector} class.
* The default constructor is the constructor with the greatest number
* of parameters that has the {@link ConstructorProperties} annotation.
- * If none of the constructors have the {@code ConstructorProperties} annotation,
+ * If none of the constructors has the {@code ConstructorProperties} annotation,
* then the nullary constructor (constructor with no parameters) will be used.
- * For example, in the following the nullary constructor
- * for {@code Foo} will be used, while the two parameter constructor
- * for {@code Bar} will be used.
- * <code>
- * public class Foo {
+ * For example, in the following code fragment, the nullary constructor
+ * for the {@code Foo} class will be used,
+ * while the two-parameter constructor
+ * for the {@code Bar} class will be used.
+ * <pre>
+ * public class Foo {
* public Foo() { ... }
* public Foo(int x) { ... }
- * }
- * public class Bar {
+ * }
+ * public class Bar {
* public Bar() { ... }
* @ConstructorProperties({"x"})
* public Bar(int x) { ... }
* @ConstructorProperties({"x", "y"})
* public Bar(int x, int y) { ... }
- * }
- * </code>
- * </ul>
+ * }</pre>
+ * </ol>
*
- * @param type The type of the object.
- * @return The persistence delegate for this type of object.
+ * @param type the class of the objects
+ * @return the persistence delegate for the given type
*
* @see #setPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
@@ -176,21 +204,18 @@
}
/**
- * Sets the persistence delegate associated with this <code>type</code> to
- * <code>persistenceDelegate</code>.
+ * Associates the specified persistence delegate with the given type.
*
- * @param type The class of objects that <code>persistenceDelegate</code> applies to.
- * @param persistenceDelegate The persistence delegate for instances of <code>type</code>.
+ * @param type the class of objects that the specified persistence delegate applies to
+ * @param delegate the persistence delegate for instances of the given type
*
* @see #getPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.BeanInfo#getBeanDescriptor
*/
- public void setPersistenceDelegate(Class<?> type,
- PersistenceDelegate persistenceDelegate)
- {
+ public void setPersistenceDelegate(Class<?> type, PersistenceDelegate delegate) {
synchronized (this.finder) {
- this.finder.register(type, persistenceDelegate);
+ this.finder.register(type, delegate);
}
}
--- a/jdk/src/share/classes/java/beans/Expression.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Expression.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -51,12 +51,19 @@
private Object value = unbound;
/**
- * Creates a new <code>Statement</code> object with a <code>target</code>,
- * <code>methodName</code> and <code>arguments</code> as per the parameters.
+ * Creates a new {@link Expression} object
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ * <p>
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param target The target of this expression.
- * @param methodName The methodName of this expression.
- * @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
+ * @param target the target object of this expression
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*
* @see #getValue
*/
@@ -66,16 +73,23 @@
}
/**
- * Creates a new <code>Expression</code> object for a method
- * that returns a result. The result will never be calculated
- * however, since this constructor uses the <code>value</code>
- * parameter to set the value property by calling the
- * <code>setValue</code> method.
+ * Creates a new {@link Expression} object with the specified value
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ * The {@code value} value is used as the value of the {@code value} property,
+ * so the {@link #getValue} method will return it
+ * without executing this {@code Expression}.
+ * <p>
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param value The value of this expression.
- * @param target The target of this expression.
- * @param methodName The methodName of this expression.
- * @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
+ * @param value the value of this expression
+ * @param target the target object of this expression
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*
* @see #setValue
*/
--- a/jdk/src/share/classes/java/beans/Introspector.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Introspector.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2010 Sun Microsystems, Inc. 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
@@ -29,6 +29,8 @@
import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -39,6 +41,7 @@
import java.util.EventListener;
import java.util.List;
import java.util.TreeMap;
+import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.reflect.misc.ReflectUtil;
@@ -155,11 +158,11 @@
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
}
synchronized (BEANINFO_CACHE) {
- WeakCache<Class<?>, BeanInfo> beanInfoCache =
- (WeakCache<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map<Class<?>, BeanInfo> beanInfoCache =
+ (Map<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache == null) {
- beanInfoCache = new WeakCache<Class<?>, BeanInfo>();
+ beanInfoCache = new WeakHashMap<Class<?>, BeanInfo>();
AppContext.getAppContext().put(BEANINFO_CACHE, beanInfoCache);
}
BeanInfo beanInfo = beanInfoCache.get(beanClass);
@@ -341,7 +344,7 @@
public static void flushCaches() {
synchronized (BEANINFO_CACHE) {
- WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.clear();
}
@@ -369,7 +372,7 @@
throw new NullPointerException();
}
synchronized (BEANINFO_CACHE) {
- WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.put(clz, null);
}
@@ -1458,7 +1461,7 @@
private PropertyDescriptor[] properties;
private int defaultProperty;
private MethodDescriptor[] methods;
- private BeanInfo targetBeanInfo;
+ private final Reference<BeanInfo> targetBeanInfoRef;
public GenericBeanInfo(BeanDescriptor beanDescriptor,
EventSetDescriptor[] events, int defaultEvent,
@@ -1470,7 +1473,7 @@
this.properties = properties;
this.defaultProperty = defaultProperty;
this.methods = methods;
- this.targetBeanInfo = targetBeanInfo;
+ this.targetBeanInfoRef = new SoftReference<BeanInfo>(targetBeanInfo);
}
/**
@@ -1509,7 +1512,7 @@
methods[i] = new MethodDescriptor(old.methods[i]);
}
}
- targetBeanInfo = old.targetBeanInfo;
+ this.targetBeanInfoRef = old.targetBeanInfoRef;
}
public PropertyDescriptor[] getPropertyDescriptors() {
@@ -1537,6 +1540,7 @@
}
public java.awt.Image getIcon(int iconKind) {
+ BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
if (targetBeanInfo != null) {
return targetBeanInfo.getIcon(iconKind);
}
--- a/jdk/src/share/classes/java/beans/PersistenceDelegate.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/PersistenceDelegate.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -105,6 +105,8 @@
*
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
public void writeObject(Object oldInstance, Encoder out) {
Object newInstance = out.get(oldInstance);
@@ -158,6 +160,8 @@
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
* @return An expression whose value is <code>oldInstance</code>.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
protected abstract Expression instantiate(Object oldInstance, Encoder out);
@@ -196,6 +200,8 @@
* @param oldInstance The instance to be copied.
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
protected void initialize(Class<?> type,
Object oldInstance, Object newInstance,
--- a/jdk/src/share/classes/java/beans/Statement.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Statement.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -69,13 +69,19 @@
ClassLoader loader;
/**
- * Creates a new <code>Statement</code> object with a <code>target</code>,
- * <code>methodName</code> and <code>arguments</code> as per the parameters.
+ * Creates a new {@link Statement} object
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ * <p>
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param target The target of this statement.
- * @param methodName The methodName of this statement.
- * @param arguments The arguments of this statement. If <code>null</code> then an empty array will be used.
- *
+ * @param target the target object of this statement
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*/
@ConstructorProperties({"target", "methodName", "arguments"})
public Statement(Object target, String methodName, Object[] arguments) {
@@ -85,27 +91,36 @@
}
/**
- * Returns the target of this statement.
+ * Returns the target object of this statement.
+ * If this method returns {@code null},
+ * the {@link #execute} method
+ * throws a {@code NullPointerException}.
*
- * @return The target of this statement.
+ * @return the target object of this statement
*/
public Object getTarget() {
return target;
}
/**
- * Returns the name of the method.
+ * Returns the name of the method to invoke.
+ * If this method returns {@code null},
+ * the {@link #execute} method
+ * throws a {@code NullPointerException}.
*
- * @return The name of the method.
+ * @return the name of the method
*/
public String getMethodName() {
return methodName;
}
/**
- * Returns the arguments of this statement.
+ * Returns the arguments for the method to invoke.
+ * The number of arguments and their types
+ * must match the method being called.
+ * {@code null} can be used as a synonym of an empty array.
*
- * @return the arguments of this statement.
+ * @return the array of arguments
*/
public Object[] getArguments() {
return arguments;
@@ -154,6 +169,9 @@
}
Object[] arguments = getArguments();
+ if (arguments == null) {
+ arguments = emptyArray;
+ }
// Class.forName() won't load classes outside
// of core from a class inside core. Special
// case this method.
@@ -285,7 +303,9 @@
Object target = getTarget();
String methodName = getMethodName();
Object[] arguments = getArguments();
-
+ if (arguments == null) {
+ arguments = emptyArray;
+ }
StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "(");
int n = arguments.length;
for(int i = 0; i < n; i++) {
--- a/jdk/src/share/classes/java/text/CollationElementIterator.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/text/CollationElementIterator.java Tue Feb 09 00:05:16 2010 -0800
@@ -232,7 +232,7 @@
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
- } else {
+ } else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
@@ -242,7 +242,7 @@
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
- } else {
+ } else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
--- a/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java Tue Feb 09 00:05:16 2010 -0800
@@ -621,6 +621,8 @@
return handleNext();
}
+ private int cachedLastKnownBreak = BreakIterator.DONE;
+
/**
* Advances the iterator backwards, to the last boundary preceding this one.
* @return The position of the last boundary position preceding this one.
@@ -638,8 +640,16 @@
// the current position), but not necessarily the last one before
// where we started
int start = current();
- getPrevious();
- int lastResult = handlePrevious();
+ int lastResult = cachedLastKnownBreak;
+ if (lastResult >= start || lastResult <= BreakIterator.DONE) {
+ getPrevious();
+ lastResult = handlePrevious();
+ } else {
+ //it might be better to check if handlePrevious() give us closer
+ //safe value but handlePrevious() is slow too
+ //So, this has to be done carefully
+ text.setIndex(lastResult);
+ }
int result = lastResult;
// iterate forward from the known break position until we pass our
@@ -653,6 +663,7 @@
// set the current iteration position to be the last break position
// before where we started, and then return that value
text.setIndex(lastResult);
+ cachedLastKnownBreak = lastResult;
return lastResult;
}
@@ -757,7 +768,8 @@
// then we can just use next() to get our return value
text.setIndex(offset);
if (offset == text.getBeginIndex()) {
- return handleNext();
+ cachedLastKnownBreak = handleNext();
+ return cachedLastKnownBreak;
}
// otherwise, we have to sync up first. Use handlePrevious() to back
@@ -767,10 +779,19 @@
// position at or before our starting position. Advance forward
// from here until we've passed the starting position. The position
// we stop on will be the first break position after the specified one.
- int result = handlePrevious();
+ int result = cachedLastKnownBreak;
+ if (result >= offset || result <= BreakIterator.DONE) {
+ result = handlePrevious();
+ } else {
+ //it might be better to check if handlePrevious() give us closer
+ //safe value but handlePrevious() is slow too
+ //So, this has to be done carefully
+ text.setIndex(result);
+ }
while (result != BreakIterator.DONE && result <= offset) {
result = handleNext();
}
+ cachedLastKnownBreak = result;
return result;
}
@@ -865,6 +886,8 @@
text = new SafeCharIterator(newText);
}
text.first();
+
+ cachedLastKnownBreak = BreakIterator.DONE;
}
--- a/jdk/src/share/classes/java/util/Date.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/util/Date.java Tue Feb 09 00:05:16 2010 -0800
@@ -953,7 +953,7 @@
* without affecting its internal state.
*/
static final long getMillisOf(Date date) {
- if (date.cdate == null) {
+ if (date.cdate == null || date.cdate.isNormalized()) {
return date.fastTime;
}
BaseCalendar.Date d = (BaseCalendar.Date) date.cdate.clone();
--- a/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Tue Feb 09 00:05:16 2010 -0800
@@ -27,6 +27,7 @@
import java.util.Enumeration;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
@@ -89,11 +90,7 @@
@Override
public int size() {
- int n = super.size();
- for (UIDefaults table : tables) {
- n += (table != null) ? table.size() : 0;
- }
- return n;
+ return entrySet().size();
}
@Override
@@ -104,40 +101,26 @@
@Override
public Enumeration<Object> keys()
{
- Enumeration[] enums = new Enumeration[1 + tables.length];
- enums[0] = super.keys();
- for(int i = 0; i < tables.length; i++) {
- UIDefaults table = tables[i];
- if (table != null) {
- enums[i + 1] = table.keys();
- }
- }
- return new MultiUIDefaultsEnumerator(enums);
+ return new MultiUIDefaultsEnumerator(
+ MultiUIDefaultsEnumerator.Type.KEYS, entrySet());
}
@Override
public Enumeration<Object> elements()
{
- Enumeration[] enums = new Enumeration[1 + tables.length];
- enums[0] = super.elements();
- for(int i = 0; i < tables.length; i++) {
- UIDefaults table = tables[i];
- if (table != null) {
- enums[i + 1] = table.elements();
- }
- }
- return new MultiUIDefaultsEnumerator(enums);
+ return new MultiUIDefaultsEnumerator(
+ MultiUIDefaultsEnumerator.Type.ELEMENTS, entrySet());
}
@Override
public Set<Entry<Object, Object>> entrySet() {
Set<Entry<Object, Object>> set = new HashSet<Entry<Object, Object>>();
- if (tables == null) return set;
- for (UIDefaults table : tables) {
- if (table != null) {
- set.addAll(table.entrySet());
+ for (int i = tables.length - 1; i >= 0; i--) {
+ if (tables[i] != null) {
+ set.addAll(tables[i].entrySet());
}
}
+ set.addAll(super.entrySet());
return set;
}
@@ -152,50 +135,46 @@
private static class MultiUIDefaultsEnumerator implements Enumeration<Object>
{
- Enumeration[] enums;
- int n = 0;
+ public static enum Type { KEYS, ELEMENTS };
+ private Iterator<Entry<Object, Object>> iterator;
+ private Type type;
- MultiUIDefaultsEnumerator(Enumeration[] enums) {
- this.enums = enums;
+ MultiUIDefaultsEnumerator(Type type, Set<Entry<Object, Object>> entries) {
+ this.type = type;
+ this.iterator = entries.iterator();
}
public boolean hasMoreElements() {
- for(int i = n; i < enums.length; i++) {
- Enumeration e = enums[i];
- if ((e != null) && (e.hasMoreElements())) {
- return true;
- }
- }
- return false;
+ return iterator.hasNext();
}
public Object nextElement() {
- for(; n < enums.length; n++) {
- Enumeration e = enums[n];
- if ((e != null) && (e.hasMoreElements())) {
- return e.nextElement();
- }
+ switch (type) {
+ case KEYS: return iterator.next().getKey();
+ case ELEMENTS: return iterator.next().getValue();
+ default: return null;
}
- return null;
}
}
@Override
public Object remove(Object key)
{
- Object value = super.remove(key);
- if (value != null) {
- return value;
+ Object value = null;
+ for (int i = tables.length - 1; i >= 0; i--) {
+ if (tables[i] != null) {
+ Object v = tables[i].remove(key);
+ if (v != null) {
+ value = v;
+ }
+ }
+ }
+ Object v = super.remove(key);
+ if (v != null) {
+ value = v;
}
- for (UIDefaults table : tables) {
- value = (table != null) ? table.remove(key) : null;
- if (value != null) {
- return value;
- }
- }
-
- return null;
+ return value;
}
@Override
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template Tue Feb 09 00:05:16 2010 -0800
@@ -90,6 +90,10 @@
*/
private Map<String, Region> registeredRegions =
new HashMap<String, Region>();
+
+ private Map<JComponent, Map<Region, SynthStyle>> overridesCache =
+ new WeakHashMap<JComponent, Map<Region, SynthStyle>>();
+
/**
* Our fallback style to avoid NPEs if the proper style cannot be found in
* this class. Not sure if relying on DefaultSynthStyle is the best choice.
@@ -251,7 +255,11 @@
}
//return the style, if found, or the default style if not found
- return foundStyle == null ? defaultStyle : foundStyle.getStyle(comp);
+ return foundStyle == null ? defaultStyle : foundStyle.getStyle(comp, r);
+ }
+
+ public void clearOverridesCache(JComponent c) {
+ overridesCache.remove(c);
}
/*
@@ -457,15 +465,6 @@
* Cached shared style.
*/
private NimbusStyle style;
- /**
- * A weakly referenced hash map such that if the reference JComponent
- * key is garbage collected then the entry is removed from the map.
- * This cache exists so that when a JComponent has nimbus overrides
- * in its client map, a unique style will be created and returned
- * for that JComponent instance, always. In such a situation each
- * JComponent instance must have its own instance of NimbusStyle.
- */
- private WeakHashMap<JComponent, WeakReference<NimbusStyle>> overridesCache;
/**
* Create a new LazyStyle.
@@ -513,17 +512,21 @@
* Gets the style. Creates it if necessary.
* @return the style
*/
- SynthStyle getStyle(JComponent c) {
+ SynthStyle getStyle(JComponent c, Region r) {
// if the component has overrides, it gets its own unique style
// instead of the shared style.
if (c.getClientProperty("Nimbus.Overrides") != null) {
- if (overridesCache == null)
- overridesCache = new WeakHashMap<JComponent, WeakReference<NimbusStyle>>();
- WeakReference<NimbusStyle> ref = overridesCache.get(c);
- NimbusStyle s = ref == null ? null : ref.get();
+ Map<Region, SynthStyle> map = overridesCache.get(c);
+ SynthStyle s = null;
+ if (map == null) {
+ map = new HashMap<Region, SynthStyle>();
+ overridesCache.put(c, map);
+ } else {
+ s = map.get(r);
+ }
if (s == null) {
s = new NimbusStyle(prefix, c);
- overridesCache.put(c, new WeakReference<NimbusStyle>(s));
+ map.put(r, s);
}
return s;
}
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Tue Feb 09 00:05:16 2010 -0800
@@ -280,11 +280,15 @@
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
String eName = ev.getPropertyName();
- // Always update when overrides or size variant change
- if ("Nimbus.Overrides" == eName ||
+ // These properties affect style cached inside NimbusDefaults (6860433)
+ if ("name" == eName ||
+ "ancestor" == eName ||
+ "Nimbus.Overrides" == eName ||
"Nimbus.Overrides.InheritDefaults" == eName ||
"JComponent.sizeVariant" == eName) {
+ JComponent c = (JComponent) ev.getSource();
+ defaults.clearOverridesCache(c);
return true;
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -237,7 +237,16 @@
// ********************************
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -250,7 +259,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -264,7 +279,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
AbstractButton b = (AbstractButton)context.getComponent();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -137,7 +137,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -151,7 +160,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -166,7 +181,8 @@
* This implementation does not perform any actions.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -305,7 +305,16 @@
// begin ComponentUI Implementation
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -319,7 +328,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -333,7 +348,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
hasFocus = comboBox.hasFocus();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -152,7 +152,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -166,7 +175,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -180,7 +195,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -439,7 +439,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -453,7 +462,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -467,7 +482,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -148,7 +148,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -164,7 +173,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -194,7 +194,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -208,7 +217,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -222,7 +237,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -156,12 +156,16 @@
}
/**
- * Notifies this UI delegate that it's time to paint the specified
- * component. This method is invoked by <code>JComponent</code>
- * when the specified component is being painted.
- */
- /**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -175,7 +179,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -189,7 +199,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JLabel label = (JLabel)context.getComponent();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -57,7 +57,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint
*/
@Override
public void update(Graphics g, JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -125,7 +125,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -139,7 +148,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -153,7 +168,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -227,7 +227,16 @@
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -240,7 +249,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -254,7 +269,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -227,7 +227,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -241,7 +250,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -255,7 +270,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -149,7 +149,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -163,7 +172,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -177,7 +192,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -136,7 +136,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -150,7 +159,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -164,7 +179,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
// do actual painting
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -132,7 +132,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -146,7 +155,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -160,7 +175,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -193,7 +193,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -208,7 +217,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -222,7 +237,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JProgressBar pBar = (JProgressBar)context.getComponent();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -102,7 +102,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -116,7 +125,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -130,7 +145,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -222,7 +222,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -237,7 +246,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -251,7 +266,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext subcontext = getContext(scrollbar,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -64,7 +64,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -78,7 +87,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -92,7 +107,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Border vpBorder = scrollpane.getViewportBorder();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -135,7 +135,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -151,7 +160,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -165,7 +180,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JSeparator separator = (JSeparator)context.getComponent();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -788,7 +788,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -802,7 +811,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -815,7 +830,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
recalculateIfInsetsChanged();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -283,7 +283,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -298,7 +307,13 @@
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -312,7 +327,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -269,7 +269,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -283,7 +292,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -297,7 +312,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
// This is done to update package private variables in
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -92,8 +92,8 @@
private SynthStyle tabAreaStyle;
private SynthStyle tabContentStyle;
- private Rectangle textRect;
- private Rectangle iconRect;
+ private Rectangle textRect = new Rectangle();
+ private Rectangle iconRect = new Rectangle();
private Rectangle tabAreaBounds = new Rectangle();
@@ -115,11 +115,6 @@
return new SynthTabbedPaneUI();
}
- private SynthTabbedPaneUI() {
- textRect = new Rectangle();
- iconRect = new Rectangle();
- }
-
private boolean scrollableTabLayoutEnabled() {
return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT);
}
@@ -362,7 +357,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -409,7 +413,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -423,7 +433,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
int selectedIndex = tabPane.getSelectedIndex();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -123,7 +123,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -137,7 +146,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -151,7 +166,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, context.getComponent());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -256,7 +256,16 @@
//
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -279,7 +288,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -293,7 +308,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -123,7 +123,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -140,7 +149,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -161,7 +161,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -182,7 +191,8 @@
* model to potentially be updated asynchronously.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -198,7 +198,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -213,7 +222,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -258,7 +273,8 @@
* Paints the toolbar.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
if (handleIcon != null && toolBar.isFloatable()) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -121,7 +121,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -144,7 +153,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -158,7 +173,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JToolTip tip = (JToolTip)context.getComponent();
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -250,7 +250,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -273,7 +282,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -287,7 +302,8 @@
* Paints the specified component.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
paintContext = context;
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java Tue Feb 09 00:05:16 2010 -0800
@@ -150,7 +150,16 @@
}
/**
- * @inheritDoc
+ * Notifies this UI delegate to repaint the specified component.
+ * This method paints the component background, then calls
+ * the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * <p>In general, this method does not need to be overridden by subclasses.
+ * All Look and Feel rendering code should reside in the {@code paint} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
@@ -174,7 +183,13 @@
}
/**
- * @inheritDoc
+ * Paints the specified component according to the Look and Feel.
+ * <p>This method is not used by Synth Look and Feel.
+ * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
+ *
+ * @param g the {@code Graphics} object used for painting
+ * @param c the component being painted
+ * @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
@@ -188,7 +203,8 @@
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
- * @param g {@code Graphics} object used for painting
+ * @param g the {@code Graphics} object used for painting
+ * @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
--- a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/**
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 Sun Microsystems, Inc. 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
@@ -38,6 +38,7 @@
import java.beans.BeanInfo;
import java.beans.Introspector;
+import java.lang.ref.Reference;
import java.lang.reflect.Field;
import sun.awt.SunToolkit;
@@ -61,9 +62,10 @@
try {
actual = Introspector.getBeanInfo(type);
type = actual.getClass();
- Field field = type.getDeclaredField("targetBeanInfo"); // NON-NLS: field name
+ Field field = type.getDeclaredField("targetBeanInfoRef"); // NON-NLS: field name
field.setAccessible(true);
- actual = (BeanInfo) field.get(actual);
+ Reference ref = (Reference) field.get(actual);
+ actual = (BeanInfo) ref.get();
}
catch (Exception exception) {
throw new Error("unexpected error", exception);
--- a/jdk/test/java/beans/Introspector/Test5102804.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/test/java/beans/Introspector/Test5102804.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 Sun Microsystems, Inc. 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
@@ -24,9 +24,9 @@
/*
* @test
* @bug 5102804
- * @ignore This test is not predictable with regards to GC
* @summary Tests memory leak
* @author Sergey Malenkov
+ * @run main/othervm -ms16m -mx16m Test5102804
*/
import java.beans.BeanInfo;
--- a/jdk/test/java/beans/XMLEncoder/Test4646747.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/test/java/beans/XMLEncoder/Test4646747.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2010 Sun Microsystems, Inc. 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
@@ -26,6 +26,7 @@
* @bug 4646747
* @summary Tests that persistence delegate is correct after memory stress
* @author Mark Davidson
+ * @run main/othervm -ms16m -mx16m Test4646747
*/
import java.beans.DefaultPersistenceDelegate;
@@ -41,11 +42,14 @@
encoder.setPersistenceDelegate(Test4646747.class, new MyPersistenceDelegate());
// WARNING: This can eat up a lot of memory
Object[] obs = new Object[10000];
- for (int i = 0; i < obs.length; i++) {
- obs[i] = new int[1000];
+ while (obs != null) {
+ try {
+ obs = new Object[obs.length + obs.length / 3];
+ }
+ catch (OutOfMemoryError error) {
+ obs = null;
+ }
}
- System.gc();
- System.gc();
PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class);
if (!(pd instanceof MyPersistenceDelegate))
throw new Error("persistence delegate has been lost");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/text/Collator/Bug5047314.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5047314
+ * @summary verify that compare() and getCollationKey() don't go into an infinite loop for unfinished Thai/Lao text.
+ * @run main/timeout=60 Bug5047314
+ */
+import java.text.Collator;
+import java.util.Locale;
+
+public class Bug5047314 {
+
+ private static Collator colLao = Collator.getInstance(new Locale("lo"));
+ private static Collator colThai = Collator.getInstance(new Locale("th"));
+
+ private static String[] textLao = {
+ "\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"
+ };
+ private static String[] textThai = {
+ "\u0e40", "\u0e41", "\u0e42", "\u0e43", "\u0e44"
+ };
+
+ public static void main(String[] args) {
+ testLao1();
+ testLao2();
+ testThai1();
+ testThai2();
+ }
+
+ private static void testLao1() {
+ System.out.print("Test(Lao 1) .... ");
+ for (int i = 0; i < textLao.length; i++) {
+ colLao.compare(textLao[i], textLao[i]);
+ }
+ System.out.println("Passed.");
+ }
+
+ private static void testLao2() {
+ System.out.print("Test(Lao 2) .... ");
+ for (int i = 0; i < textLao.length; i++) {
+ colLao.compare(textLao[i], textLao[i]);
+ }
+ System.out.println("Passed.");
+ }
+
+ private static void testThai1() {
+ System.out.print("Test(Thai 1) .... ");
+ for (int i = 0; i < textThai.length; i++) {
+ colThai.compare(textThai[i], textThai[i]);
+ }
+ System.out.println("Passed.");
+ }
+
+ private static void testThai2() {
+ System.out.print("Test(Thai 2) .... ");
+ for (int i = 0; i < textThai.length; i++) {
+ colThai.getCollationKey(textThai[i]);
+ }
+ System.out.println("Passed.");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimeZone/TimeZoneDatePermissionCheck.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,42 @@
+/* Testcase for PR381 Stackoverflow error with security manager, signed jars
+ * and -Djava.security.debug set.
+ * Copyright (c) 2009, Red Hat Inc.
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.util.Date;
+
+/**
+ * Test class. Create a test keystore and dummy cert, create a jar file to
+ * sign with the test class in it. Sign it run it with the security manager
+ * on, plus accesscontroller debugging, will go into infinite recursion
+ * trying to get enough permissions for printing Date of failing
+ * certificate, unless fix is applied.
+ */
+public class TimeZoneDatePermissionCheck
+{
+ public static void main(String[] args)
+ {
+ System.out.println(new Date());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimeZone/TimeZoneDatePermissionCheck.sh Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,58 @@
+# Testcase for PR381 Stackoverflow error with security manager, signed jars
+# and -Djava.security.debug set.
+#
+# Copyright (c) 2009, Red Hat Inc.
+#
+# This code is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# 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 for more details.
+#
+# 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.
+#
+# @test
+# @bug 6584033
+# @summary Stackoverflow error with security manager, signed jars and debug.
+# @build TimeZoneDatePermissionCheck
+# @run shell TimeZoneDatePermissionCheck.sh
+
+# Set default if not run under jtreg from test dir itself
+if [ "${TESTCLASSES}" = "" ] ; then
+ TESTCLASSES="."
+fi
+if [ "${TESTJAVA}" = "" ] ; then
+ TESTJAVA=/usr
+fi
+
+# create a test keystore and dummy cert
+rm -f ${TESTCLASSES}/timezonedatetest.store
+${TESTJAVA}/bin/keytool -genkeypair -alias testcert \
+ -keystore ${TESTCLASSES}/timezonedatetest.store \
+ -storepass testpass -validity 360 \
+ -dname "cn=Mark Wildebeest, ou=FreeSoft, o=Red Hat, c=NL" \
+ -keypass testpass
+
+# create a jar file to sign with the test class in it.
+rm -f ${TESTCLASSES}/timezonedatetest.jar
+${TESTJAVA}/bin/jar cf \
+ ${TESTCLASSES}/timezonedatetest.jar \
+ -C ${TESTCLASSES} TimeZoneDatePermissionCheck.class
+
+# sign it
+${TESTJAVA}/bin/jarsigner \
+ -keystore ${TESTCLASSES}/timezonedatetest.store \
+ -storepass testpass ${TESTCLASSES}/timezonedatetest.jar testcert
+
+# run it with the security manager on, plus accesscontroller debugging
+# will go into infinite recursion trying to get enough permissions for
+# printing Date of failing certificate unless fix is applied.
+${TESTJAVA}/bin/java -Djava.security.manager \
+ -Djava.security.debug=access,failure,policy \
+ -cp ${TESTCLASSES}/timezonedatetest.jar TimeZoneDatePermissionCheck
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/MultiUIDefaults/4300666/bug4300666.html Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,28 @@
+<!--
+ Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ CA 95054 USA or visit www.sun.com if you need additional information or
+ have any questions.
+-->
+
+<html>
+<body>
+<applet code="bug4300666.class" width=200 height=200></applet>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/MultiUIDefaults/4300666/bug4300666.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 4300666
+ @summary Printing UIDefaults throws NoSuchElementExcept
+ @author Andrey Pikalev
+ @run applet bug4300666.html
+*/
+
+import javax.swing.*;
+
+
+public class bug4300666 extends JApplet {
+
+ public void init() {
+ UIDefaults d = UIManager.getDefaults();
+ d.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/MultiUIDefaults/4331767/bug4331767.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 4331767
+ @summary Tests that custom implementation of UIDefaults.getUIError() is
+ called when an UI error occurs
+ @author Peter Zhelezniakov
+ @run main bug4331767
+*/
+import javax.swing.*;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import java.util.Locale;
+
+public class bug4331767
+{
+ private static boolean passed = false;
+
+ public static void main(String[] argv) {
+ try {
+ UIManager.setLookAndFeel(new BrokenLookAndFeel());
+ } catch (Exception e) {
+ throw new Error("Failed to set BrokenLookAndFeel, cannot test", e);
+ }
+
+ // This should call BrokenUIDefaults.getUIError()
+ new JButton();
+
+ if (!passed) {
+ throw new RuntimeException("Failed: Custom getUIError() not called");
+ }
+ }
+
+ static class BrokenUIDefaults extends UIDefaults {
+ UIDefaults defaults;
+
+ public BrokenUIDefaults(UIDefaults def) {
+ defaults = def;
+ }
+
+ public Object get(Object key) {
+ if ("ButtonUI".equals(key)) {
+ System.err.println("[II] Called BrokenUIDefaults.get(Object)");
+ return "a nonexistent class";
+ }
+ return defaults.get(key);
+ }
+
+ public Object get(Object key, Locale l) {
+ if ("ButtonUI".equals(key)) {
+ System.err.println("[II] Called BrokenUIDefaults.get(Object, Locale)");
+ return "a nonexistent class";
+ }
+ return defaults.get(key, l);
+ }
+
+ protected void getUIError(String msg) {
+ System.err.println("[II] BrokenUIDefaults.getUIError() called, test passes");
+ passed = true;
+ }
+ }
+
+ static class BrokenLookAndFeel extends MetalLookAndFeel {
+ UIDefaults defaults;
+
+ public BrokenLookAndFeel() {
+ defaults = new BrokenUIDefaults(super.getDefaults());
+ }
+
+ public UIDefaults getDefaults() {
+ return defaults;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/MultiUIDefaults/Test6860438.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6860438
+ @summary Tests various MultiUIDefaults methods
+ @author Peter Zhelezniakov
+ @run main Test6860438
+*/
+
+import java.util.Enumeration;
+import java.util.Map.Entry;
+import java.util.Set;
+import javax.swing.UIManager;
+
+public class Test6860438
+{
+ static final String KEY = "Test6860438.key";
+ static final String VALUE = "Test6860438.value";
+
+ void check(Object key, Object value, boolean present, int size) {
+ check(UIManager.get(key) == value, "UIManager.get()");
+ check(UIManager.getDefaults().size() == size, "MultiUIDefaults.size()");
+
+ checkEnumeration(UIManager.getDefaults().keys(),
+ key, present, "MultiUIDefaults.keys()");
+ checkEnumeration(UIManager.getDefaults().elements(),
+ value, present, "MultiUIDefaults.elements()");
+
+ // check MultiUIDefaults.entrySet()
+ boolean found = false;
+ Set<Entry<Object, Object>> entries = UIManager.getDefaults().entrySet();
+ for (Entry<Object, Object> e: entries) {
+ if (e.getKey() == key) {
+ check(e.getValue() == value, "MultiUIDefaults.entrySet()");
+ found = true;
+ }
+ }
+ check(found == present, "MultiUIDefaults.entrySet()");
+ }
+
+ void checkEnumeration(Enumeration<Object> e, Object elem,
+ boolean present, String error) {
+ boolean found = false;
+ while (e.hasMoreElements()) {
+ if (e.nextElement() == elem) {
+ found = true;
+ }
+ }
+ check(found == present, error);
+ }
+
+ void check(boolean condition, String methodName) {
+ if (! condition) {
+ throw new RuntimeException(methodName + " failed");
+ }
+ }
+
+ void test() {
+ int size = UIManager.getDefaults().size();
+
+ // create a new value, size increases
+ UIManager.getLookAndFeelDefaults().put(KEY, VALUE);
+ check(KEY, VALUE, true, size + 1);
+
+ // override the value, size remains the same
+ UIManager.put(KEY, VALUE);
+ check(KEY, VALUE, true, size + 1);
+
+ // remove the value, size decreases
+ UIManager.getDefaults().remove(KEY);
+ check(KEY, null, false, size);
+ }
+
+ public static void main(String[] args) {
+ new Test6860438().test();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/nimbus/ColorCustomizationTest.java Tue Feb 09 00:05:16 2010 -0800
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6860433
+ @summary Tests variuos techniques of Nimbus color customization
+ @author Peter Zhelezniakov
+ @run main ColorCustomizationTest
+*/
+
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.nimbus.NimbusLookAndFeel;
+import javax.swing.plaf.synth.Region;
+
+public class ColorCustomizationTest
+{
+ final static int WIDTH = 200;
+ final static int HEIGHT = 100;
+
+ static NimbusLookAndFeel nimbus;
+
+ final JLabel label;
+ final Graphics g;
+
+ ColorCustomizationTest() {
+ label = new JLabel();
+ label.setSize(200, 100);
+
+ g = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB).getGraphics();
+ }
+
+ public static void main(String[] args) throws Exception {
+ nimbus = new NimbusLookAndFeel();
+ try {
+ UIManager.setLookAndFeel(nimbus);
+ } catch (UnsupportedLookAndFeelException e) {
+ throw new Error("Unable to set Nimbus LAF");
+ }
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override public void run() {
+ new ColorCustomizationTest().test();
+ }
+ });
+ }
+
+ void check(Color c) {
+ SwingUtilities.updateComponentTreeUI(label);
+ label.paint(g);
+ if (label.getBackground().getRGB() != c.getRGB()) {
+ System.err.println("Color mismatch!");
+ System.err.println(" found: " + label.getBackground());
+ System.err.println(" expected: " + c);
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ void test() {
+ testOverrides();
+ testInheritance();
+ testNames();
+ testBaseColor();
+ }
+
+ void testOverrides() {
+ Color defaultColor = label.getBackground();
+
+ // override default background
+ UIDefaults defs = new UIDefaults();
+ defs.put("Label.background", new ColorUIResource(Color.RED));
+ label.putClientProperty("Nimbus.Overrides", defs);
+ check(Color.RED);
+
+ // change overriding color
+ defs = new UIDefaults();
+ defs.put("Label.background", new ColorUIResource(Color.GREEN));
+ label.putClientProperty("Nimbus.Overrides", defs);
+ check(Color.GREEN);
+
+ // remove override
+ label.putClientProperty("Nimbus.Overrides", null);
+ check(defaultColor);
+ }
+
+ void testInheritance() {
+ Color defaultColor = label.getBackground();
+
+ // more specific setting is in global defaults
+ UIManager.put("Label[Enabled].background", new ColorUIResource(Color.RED));
+
+ // less specific one is in overrides
+ UIDefaults defs = new UIDefaults();
+ defs.put("Label.background", new ColorUIResource(Color.GREEN));
+
+ // global wins
+ label.putClientProperty("Nimbus.Overrides", defs);
+ check(Color.RED);
+
+ // now override wins
+ label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
+ check(Color.GREEN);
+
+ // global is back
+ label.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
+ check(Color.RED);
+
+ // back to default color
+ UIManager.put("Label[Enabled].background", null);
+ label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
+ label.putClientProperty("Nimbus.Overrides", null);
+ check(defaultColor);
+ }
+
+ void testNames() {
+ Color defaultColor = label.getBackground();
+
+ UIManager.put("\"BlueLabel\"[Enabled].background",
+ new ColorUIResource(Color.BLUE));
+ UIManager.put("\"RedLabel\"[Enabled].background",
+ new ColorUIResource(Color.RED));
+ nimbus.register(Region.LABEL, "\"BlueLabel\"");
+ nimbus.register(Region.LABEL, "\"RedLabel\"");
+
+ label.setName("BlueLabel");
+ check(Color.BLUE);
+ label.setName("RedLabel");
+ check(Color.RED);
+
+ // remove name, color goes back to default
+ label.setName(null);
+ check(defaultColor);
+ }
+
+ void testBaseColor() {
+ UIManager.put("control", Color.GREEN);
+ check(Color.GREEN);
+ }
+}