提交 b5803f0d 编写于 作者: L lana

Merge

......@@ -33,7 +33,7 @@ include $(BUILDDIR)/common/Defs.gmk
# Files
#
include FILES.gmk
AUTO_FILES_JAVA_DIRS = javax/swing sun/swing
AUTO_FILES_JAVA_DIRS = javax/swing sun/swing com/sun/java/swing
AUTO_JAVA_PRUNE = plaf
SUBDIRS = html32dtd plaf
......
......@@ -32,7 +32,6 @@ include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = \
addjsum \
auto_multi \
buildmetaindex \
commentchecker \
compile_font_config \
......
#
# Copyright 1998-2005 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. 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.
#
#
# Makefile for building the automulti tool
#
BUILDDIR = ../..
PACKAGE = build.tools.automulti
PRODUCT = tools
PROGRAM = automulti
include $(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
BUILDTOOL_MAIN = $(PKGDIR)/AutoMulti.java
#
# Build tool jar rules.
#
include $(BUILDDIR)/common/BuildToolJar.gmk
/*
* Copyright 1998-2001 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. 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.
*/
package build.tools.automulti;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
/**
* Automatically generates the Multiplexing UI classes
* for Swing.
* <p>
* To use, type 'java AutoMulti <plafdir> <prefix>' where <plafdir>
* is the directory containing the source for Swing's UI classes and
* <prefix> is the package prefix to use before ".swing.plaf.multi".
* For example:
*
* <pre>
* cd TEST
* ../../../../build/solaris-sparc/bin/java AutoMulti ../../../../src/share/classes/javax/swing/plaf javax
* </pre>
*
* AutoMulti will scour the plaf directory for *UI.java files and
* generate Multi*UI.java files that do the multiplexing thing.
* <p>
* NOTE: This tool depends upon the existence of <plafdir> and on the
* compiled classes from <plafdir> being somewhere in the class path.
*
* @author Willie Walker
*/
public class AutoMulti {
static String importLines;
/**
* A silly list of parameter names to use. Skips "i" because we use
* it as a 'for' loop counter. If you want to get fancy, please feel
* to change how parameter names are obtained. This will break if
* someone decides to create a UI method that takes more than 8
* parameters. Which one is a bug (this breaking or having a method
* with more than eight parameters) is a subjective thing.
*/
public static String[] paramNames = {"a","b","c","d","e","f","g","h"};
/**
* Removes the package names (e.g., javax.swing) from the name.
*/
public static String unqualifyName(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
String unqualifiedName = null;
while (parser.hasMoreTokens()) {
unqualifiedName = parser.nextToken();
}
return removeDollars(unqualifiedName);
}
/**
* Strips the extension from the filename.
*/
public static String stripExtension(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
return parser.nextToken();
}
/**
* Adds some spaces.
*/
public static void indent(StringBuffer s, int i) {
while (i > 0) {
s.append(" ");
i--;
}
}
/**
* Spits out all the beginning stuff.
*/
public static StringBuffer createPreamble(String prefixName) {
StringBuffer s = new StringBuffer();
s.append("/*\n");
s.append(" *\n");
s.append(" * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.\n");
s.append(" * \n");
s.append(" * This software is the proprietary information of Sun Microsystems, Inc. \n");
s.append(" * Use is subject to license terms.\n");
s.append(" * \n");
s.append(" */\n");
s.append("package " + prefixName + ".swing.plaf.multi;\n");
s.append("\n");
return s;
}
/**
* Replaces 'Xxx$Yyy' with "Xxx'. Used by addImport because you
* can't import nested classes directly.
*/
public static String removeNestedClassName(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
sb.setLength(dollarPosition);
return sb.toString();
} else { // no '$'
return s;
}
}
/**
* Replaces '$' with ".'. Needed for printing inner class names
* for argument and return types.
*/
public static String removeDollars(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
while (dollarPosition >= 0) {
//XXX: will there ever be more than one '$'?
sb.replace(dollarPosition, dollarPosition+1, ".");
dollarPosition = sb.indexOf("$", dollarPosition);
}
return sb.toString();
} else { // no $
return s;
}
}
/**
* Adds an import line to the String.
*/
public static void addImport(String s, Class theClass) {
if (!theClass.isPrimitive() && (theClass != Object.class)) {
String className = removeNestedClassName(theClass.getName());
String importLine = new String("import " + className + ";\n");
if (importLines.indexOf(importLine) == -1) {
importLines += importLine;
}
}
}
/**
* Spits out the class header information.
*/
public static void addHeader(StringBuffer s, String className) {
s.append("/**\n");
s.append(" * A multiplexing UI used to combine <code>" + className + "</code>s.\n");
s.append(" * \n");
s.append(" * <p>This file was automatically generated by AutoMulti.\n");
s.append(" *\n");
s.append(" * @author Otto Multey\n"); // Get it? I crack myself up.
s.append(" */\n");
s.append("public class Multi" + className + " extends " + className + " {\n");
s.append("\n");
s.append(" /**\n");
s.append(" * The vector containing the real UIs. This is populated \n");
s.append(" * in the call to <code>createUI</code>, and can be obtained by calling\n");
s.append(" * the <code>getUIs</code> method. The first element is guaranteed to be the real UI \n");
s.append(" * obtained from the default look and feel.\n");
s.append(" */\n");
s.append(" protected Vector uis = new Vector();\n");
s.append("\n");
s.append("////////////////////\n");
s.append("// Common UI methods\n");
s.append("////////////////////\n");
s.append("\n");
s.append(" /**\n");
s.append(" * Returns the list of UIs associated with this multiplexing UI. This \n");
s.append(" * allows processing of the UIs by an application aware of multiplexing \n");
s.append(" * UIs on components.\n");
s.append(" */\n");
s.append(" public ComponentUI[] getUIs() {\n");
s.append(" return MultiLookAndFeel.uisToArray(uis);\n");
s.append(" }\n");
}
/**
* Prints out the code for a method. This is pretty specific to the
* Multiplexing UI code, so don't get any fancy ideas.
*/
public static void addMethod(StringBuffer s, Method m, String origName, String className) {
// Get the method name and the return type. Be a little careful about arrays.
//
String methodName = unqualifyName(m.getName());
String returnType;
if (!m.getReturnType().isArray()) {
returnType = unqualifyName(m.getReturnType().toString());
addImport(importLines,m.getReturnType());
} else {
returnType = unqualifyName(m.getReturnType().getComponentType().toString())
+ "[]";
addImport(importLines,m.getReturnType().getComponentType());
}
// Print the javadoc
//
s.append("\n");
if (methodName.equals("createUI")) {
s.append(" /**\n");
s.append(" * Returns a multiplexing UI instance if any of the auxiliary\n");
s.append(" * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the \n");
s.append(" * UI object obtained from the default <code>LookAndFeel</code>.\n");
s.append(" */\n");
} else if (!returnType.equals("void")) {
s.append(" /**\n");
s.append(" * Invokes the <code>" + methodName + "</code> method on each UI handled by this object.\n");
s.append(" * \n");
s.append(" * @return the value obtained from the first UI, which is\n");
s.append(" * the UI obtained from the default <code>LookAndFeel</code>\n");
s.append(" */\n");
} else {
s.append(" /**\n");
s.append(" * Invokes the <code>" + methodName
+ "</code> method on each UI handled by this object.\n");
s.append(" */\n");
}
// Print the method signature
//
s.append(" public");
if (Modifier.isStatic(m.getModifiers())) {
s.append(" static");
}
s.append(" " + returnType);
s.append(" " + methodName);
s.append("(");
Class[] params = m.getParameterTypes();
Class temp;
String braces;
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(", ");
}
temp = params[i];
braces = new String("");
while (temp.isArray()) {
braces += "[]";
temp = temp.getComponentType();
}
s.append(unqualifyName(temp.getName()) + braces + " " + paramNames[i]);
addImport(importLines,temp);
}
s.append(")");
// Don't forget about exceptions
//
Class exceptions[] = m.getExceptionTypes();
String throwsString = new String("");
if (exceptions.length > 0) {
s.append("\n");
indent(s,12);
s.append("throws ");
for (int i = 0; i < exceptions.length; i++) {
if (i > 0) {
s.append(", ");
}
s.append(unqualifyName(exceptions[i].getName()));
addImport(importLines,exceptions[i]);
}
}
s.append(throwsString + " {\n");
// Now print out the contents of the method. We do a special thing
// for the createUI method, another thing if the method returns 'void'
// and a third thing if we don't do either of the first two. If
// you want to squash this down, feel free.
//
if (methodName.equals("createUI")) {
indent(s,8);
s.append("ComponentUI mui = new Multi" + origName + "();\n");
indent(s,8);
s.append("return MultiLookAndFeel.createUIs(mui,\n");
indent(s,42);
s.append("((Multi" + origName +") mui).uis,\n");
indent(s,42);
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
} else if (!returnType.equals("void")) {
indent(s,8);
s.append(returnType + " returnValue = \n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(0)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("for (int i = 1; i < uis.size(); i++) {\n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(i)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("}\n");
indent(s,8);
s.append("return returnValue;\n");
} else {
indent(s,8);
s.append("for (int i = 0; i < uis.size(); i++) {\n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(i)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("}\n");
}
indent(s,4);
s.append("}\n");
}
/**
* Takes a plaf class name (e.g., "MenuUI") and generates the corresponding
* Multiplexing UI Java source code (e.g., "MultiMenuUI.java").
*/
public static void generateFile(String prefixName, String className) {
try {
FileOutputStream fos;
PrintWriter outFile;
importLines = new String();
importLines += new String("import java.util.Vector;\n");
StringBuffer body = new StringBuffer();
Class wee = Class.forName(prefixName + ".swing.plaf." + className);
String weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
while (!weeName.equals("Object")) {
body.append("\n");
body.append("////////////////////\n");
body.append("// " + weeName + " methods\n");
body.append("////////////////////\n");
Method[] methods = wee.getDeclaredMethods();
for (int i=0; i < methods.length; i++) {
if (Modifier.isPublic(methods[i].getModifiers())) {
addMethod(body,methods[i],className,weeName);
}
}
wee = wee.getSuperclass();
weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
}
fos = new FileOutputStream("Multi" + className + ".java");
outFile = new PrintWriter(fos);
StringBuffer outText = createPreamble(prefixName);
outText.append(importLines.toString() + "\n");
addHeader(outText,className);
outText.append(body.toString());
outText.append("}\n");
outFile.write(outText.toString());
outFile.flush();
outFile.close();
} catch (Exception e) {
System.err.println(e);
}
}
/**
* D'Oh! Something bad happened.
*/
public static void usage(String s) throws IOException {
System.err.println("Usage: AutoMulti <plafdir> [com.sun]");
throw new IllegalArgumentException(s);
}
/**
* Takes the plaf directory name and generates the multiplexing UI
* source code.
*/
public static void main(String[] args) throws IOException {
if (args.length < 1) {
usage("");
}
String dirName = args[0];
File dir = new File(dirName);
if (!dir.isDirectory()) {
System.err.println("No such directory: " + dirName);
usage("");
}
String prefixName;
if (args.length > 1) {
prefixName = args[1];
} else {
prefixName = "com.sun.java";
}
String plafUIs[] = dir.list(new UIJavaFilter());
for (int i = 0; i < plafUIs.length; i++) {
generateFile(prefixName,stripExtension(plafUIs[i]));
}
}
}
/**
* Only accepts file names of the form *UI.java. The one exception
* is not accepting ComponentUI.java because we don't need to generate
* a multiplexing class for it.
*/
class UIJavaFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (name.equals("ComponentUI.java")) {
return false;
} else if (name.endsWith("UI.java")) {
return true;
} else {
return false;
}
}
}
AutoMulti is the tool that automatically generates the
Multi*UI classes for the Multiplexing look and feel.
Instructions for using it are in AutoMulti.java.
TestALFGenerator is a tool (a variation of AutoMulti)
that automatically generates an auxiliary look and
feel that you can use to test the Multiplexing look
and feel. The TestALF look and feel implements every
method by printing the message "In the xxx method of
the TextALFYyyUI class." and, except in the case of
createUI, returning something meaningless (since,
except in the case of createUI, the return value is
ignored).
TestALFLookAndFeel.java is the only non-auto-generated
file for the TestALF L&F. If you specify a package
argument to TestALFGenerator, you'll have to change
the code in TestALFLookAndFeel.java to reflect the
package name.
To test any application with the TestALF, make sure the
compiled TestALF classes are in the class path. Then add
this to the <JDK_HOME>/lib/swing.properties file (which
you'll probably have to create):
swing.auxiliarylaf=TestALFLookAndFeel
E.g., if you're running SwingSet2 against your solaris
build, then you'd create/edit the swing.properties file
in <wsdir>/build/solaris-sparc/lib.
Then run any app. You'll see lots of thrilling "In the
Xxxx method of the Yyy class" messages. If you get anything
else (especially an exception), then you've found a bug.
Probably in the default look and feel.
/*
* Copyright 2001 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. 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.
*/
package build.tools.automulti;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
/**
* Automatically generates an auxiliary look and feel to be
* used for testing the Multiplexing look and feel.
* <p>
* To use, type 'java TestALFGenerator <plafdir> [<package>]' where <plafdir>
* is the directory containing the source for Swing's UI classes.
* <package> is an optional argument that specifies the package
* of the TestALF classes. If it's omitted, the classes are in
* the default package.
* For example:
*
* <pre>
* ../../../../build/solaris-sparc/bin/java TestALFGenerator ../../../../src/share/classes/javax/swing/plaf com.myco.myalaf
* </pre>
*
* TestALFGenerator will scour the plaf directory for *UI.java files and
* generate TestALF*UI.java files.
* <p>
* NOTE: This tool depends upon the existence of <plafdir> and on the
* compiled classes from <plafdir> being somewhere in the class path.
*
* @author Willie Walker
*/
public class TestALFGenerator {
static String importLines;
static String packageName;
static String classPrefix = "TestALF";
/**
* A silly list of parameter names to use. Skips "i" because we use
* it as a 'for' loop counter. If you want to get fancy, please feel
* to change how parameter names are obtained. This will break if
* someone decides to create a UI method that takes more than 8
* parameters. Which one is a bug (this breaking or having a method
* with more than eight parameters) is a subjective thing.
*/
public static String[] paramNames = {"a","b","c","d","e","f","g","h"};
/**
* Removes the package names (e.g., javax.swing) from the name.
*/
public static String unqualifyName(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
String unqualifiedName = null;
while (parser.hasMoreTokens()) {
unqualifiedName = parser.nextToken();
}
return removeDollars(unqualifiedName);
}
/**
* Strips the extension from the filename.
*/
public static String stripExtension(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
return parser.nextToken();
}
/**
* Adds some spaces.
*/
public static void indent(StringBuffer s, int i) {
while (i > 0) {
s.append(" ");
i--;
}
}
/**
* Spits out all the beginning stuff.
*/
public static StringBuffer createPreamble(String prefixName) {
StringBuffer s = new StringBuffer();
s.append("/*\n");
s.append(" *\n");
s.append(" * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.\n");
s.append(" * \n");
s.append(" * This software is the proprietary information of Sun Microsystems, Inc. \n");
s.append(" * Use is subject to license terms.\n");
s.append(" * \n");
s.append(" */\n");
if (packageName != null) {
s.append("package " + packageName + ";\n");
s.append("\n");
}
return s;
}
/**
* Replaces 'Xxx$Yyy' with "Xxx'. Used by addImport because you
* can't import nested classes directly.
*/
public static String removeNestedClassName(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
sb.setLength(dollarPosition);
return sb.toString();
} else { // no '$'
return s;
}
}
/**
* Replaces '$' with ".'. Needed for printing inner class names
* for argument and return types.
*/
public static String removeDollars(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
while (dollarPosition >= 0) {
//XXX: will there ever be more than one '$'?
sb.replace(dollarPosition, dollarPosition+1, ".");
dollarPosition = sb.indexOf("$", dollarPosition);
}
return sb.toString();
} else { // no $
return s;
}
}
/**
* Adds an import line to the String.
*/
public static void addImport(String s, Class theClass) {
if (!theClass.isPrimitive() && (theClass != Object.class)) {
String className = removeNestedClassName(theClass.getName());
String importLine = new String("import " + className + ";\n");
if (importLines.indexOf(importLine) == -1) {
importLines += importLine;
}
}
}
/**
* Spits out the class header information.
*/
public static void addHeader(StringBuffer s, String className) {
s.append("/**\n");
s.append(" * An auxiliary UI for <code>" + className + "</code>s.\n");
s.append(" * \n");
s.append(" * <p>This file was automatically generated by TestALFGenerator.\n");
s.append(" *\n");
s.append(" * @author Otto Multey\n"); // Get it? I crack myself up.
s.append(" */\n");
s.append("public class " + classPrefix + className + " extends " + className + " {\n");
s.append("\n");
}
/**
* Prints out the code for a method.
*/
public static void addMethod(StringBuffer s, Method m, String origName, String className) {
// Get the method name and the return type. Be a little careful about arrays.
//
String methodName = unqualifyName(m.getName());
String returnType;
if (!m.getReturnType().isArray()) {
returnType = unqualifyName(m.getReturnType().toString());
addImport(importLines,m.getReturnType());
} else {
returnType = unqualifyName(m.getReturnType().getComponentType().toString())
+ "[]";
addImport(importLines,m.getReturnType().getComponentType());
}
// Print the javadoc
//
s.append("\n");
if (methodName.equals("createUI")) {
s.append(" /**\n");
s.append(" * Returns a UI object for this component.\n");
s.append(" */\n");
} else {
s.append(" /**\n");
s.append(" * Prints a message saying this method has been invoked.\n");
s.append(" */\n");
}
// Print the method signature
//
s.append(" public");
if (Modifier.isStatic(m.getModifiers())) {
s.append(" static");
}
s.append(" " + returnType);
s.append(" " + methodName);
s.append("(");
Class[] params = m.getParameterTypes();
Class temp;
String braces;
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(", ");
}
temp = params[i];
braces = new String("");
while (temp.isArray()) {
braces += "[]";
temp = temp.getComponentType();
}
s.append(unqualifyName(temp.getName()) + braces + " " + paramNames[i]);
addImport(importLines,temp);
}
s.append(")");
// Don't forget about exceptions
//
Class exceptions[] = m.getExceptionTypes();
String throwsString = new String("");
if (exceptions.length > 0) {
s.append("\n");
indent(s,12);
s.append("throws ");
for (int i = 0; i < exceptions.length; i++) {
if (i > 0) {
s.append(", ");
}
s.append(unqualifyName(exceptions[i].getName()));
addImport(importLines,exceptions[i]);
}
}
s.append(throwsString + " {\n");
// Now print out the contents of the method.
indent(s,8);
s.append("System.out.println(\"In the " + methodName
+ " method of the "
+ classPrefix + origName + " class.\");\n");
if (methodName.equals("createUI")) {
indent(s,8);
s.append("return ui;\n");
} else {
// If we have to return something, do so.
if (!returnType.equals("void")) {
Class rType = m.getReturnType();
indent(s,8);
if (!rType.isPrimitive()) {
s.append("return null;\n");
} else if (rType == Boolean.TYPE) {
s.append("return false;\n");
} else if (rType == Character.TYPE) {
s.append("return '0';\n");
} else { // byte, short, int, long, float, or double
s.append("return 0;\n");
}
}
}
indent(s,4);
s.append("}\n");
}
/**
* Takes a plaf class name (e.g., "MenuUI") and generates the corresponding
* TestALF UI Java source code (e.g., "TestALFMenuUI.java").
*/
public static void generateFile(String prefixName, String className) {
try {
FileOutputStream fos;
PrintWriter outFile;
importLines = new String();
importLines += new String("import java.util.Vector;\n");
StringBuffer body = new StringBuffer();
Class wee = Class.forName(prefixName + ".swing.plaf." + className);
String weeName = unqualifyName(wee.getName());
String thisClassName = classPrefix + className;
addImport(importLines,wee);
// Declare and initialize the shared UI object.
body.append("\n");
body.append("////////////////////\n");
body.append("// Shared UI object\n");
body.append("////////////////////\n");
body.append("private final static " + thisClassName
+ " ui = new " + thisClassName + "();\n");
while (!weeName.equals("Object")) {
body.append("\n");
body.append("////////////////////\n");
body.append("// " + weeName + " methods\n");
body.append("////////////////////\n");
Method[] methods = wee.getDeclaredMethods();
for (int i=0; i < methods.length; i++) {
if (Modifier.isPublic(methods[i].getModifiers())) {
addMethod(body,methods[i],className,weeName);
}
}
wee = wee.getSuperclass();
weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
}
fos = new FileOutputStream(classPrefix + className + ".java");
outFile = new PrintWriter(fos);
StringBuffer outText = createPreamble(prefixName);
outText.append(importLines.toString() + "\n");
addHeader(outText,className);
outText.append(body.toString());
outText.append("}\n");
outFile.write(outText.toString());
outFile.flush();
outFile.close();
} catch (Exception e) {
System.err.println(e);
}
}
/**
* D'Oh! Something bad happened.
*/
public static void usage(String s) throws IOException {
System.err.println("Usage: java TestALFGenerator <plafdir> [<packageName>]");
throw new IllegalArgumentException(s);
}
/**
* Takes the plaf directory name and generates the TestALF UI
* source code.
*/
public static void main(String[] args) throws IOException {
if (args.length < 1) {
usage("");
}
String dirName = args[0];
File dir = new File(dirName);
if (!dir.isDirectory()) {
System.err.println("No such directory: " + dirName);
usage("");
}
if (args.length > 1) {
packageName = args[1];
}
String plafUIs[] = dir.list(new UIJavaFilter());
for (int i = 0; i < plafUIs.length; i++) {
generateFile("javax",stripExtension(plafUIs[i]));
}
}
}
/**
* Only accepts file names of the form *UI.java. The one exception
* is not accepting ComponentUI.java because we don't need to generate
* a TestALF class for it.
*/
class UIJavaFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (name.equals("ComponentUI.java")) {
return false;
} else if (name.endsWith("UI.java")) {
return true;
} else {
return false;
}
}
}
/*
* Copyright 2001 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. 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.
*/
//package com.myco.myalaf; //search for myalaf for other refs to package name
package build.tools.automulti;
import java.util.Vector;
import java.lang.reflect.Method;
import javax.swing.*;
import javax.swing.plaf.*;
/**
* <p>An auxiliary look and feel used for testing the Multiplexing
* look and feel.
* <p>
*
* @see UIManager#addAuxiliaryLookAndFeel
* @see javax.swing.plaf.multi
*
* @author Kathy Walrath
* @author Will Walker
*/
public class TestALFLookAndFeel extends LookAndFeel {
//////////////////////////////
// LookAndFeel methods
//////////////////////////////
/**
* Returns a string, suitable for use in menus,
* that identifies this look and feel.
*
* @return a string such as "Test Auxiliary Look and Feel"
*/
public String getName() {
return "Test Auxiliary Look and Feel";
}
/**
* Returns a string, suitable for use by applications/services,
* that identifies this look and feel.
*
* @return "TestALF"
*/
public String getID() {
return "TestALF";
}
/**
* Returns a one-line description of this look and feel.
*
* @return a descriptive string such as "Allows multiple UI instances per component instance"
*/
public String getDescription() {
return "Allows multiple UI instances per component instance";
}
/**
* Returns <code>false</code>;
* this look and feel is not native to any platform.
*
* @return <code>false</code>
*/
public boolean isNativeLookAndFeel() {
return false;
}
/**
* Returns <code>true</code>;
* every platform permits this look and feel.
*
* @return <code>true</code>
*/
public boolean isSupportedLookAndFeel() {
return true;
}
/**
* Creates, initializes, and returns
* the look and feel specific defaults.
* For this look and feel,
* the defaults consist solely of
* mappings of UI class IDs
* (such as "ButtonUI")
* to <code>ComponentUI</code> class names
* (such as "com.myco.myalaf.MultiButtonUI").
*
* @return an initialized <code>UIDefaults</code> object
* @see javax.swing.JComponent#getUIClassID
*/
public UIDefaults getDefaults() {
System.out.println("In the TestALFLookAndFeel getDefaults method.");
UIDefaults table = new TestALFUIDefaults();
//String prefix = "com.myco.myalaf.TestALF";
String prefix = "TestALF";
Object[] uiDefaults = {
"ButtonUI", prefix + "ButtonUI",
"CheckBoxMenuItemUI", prefix + "MenuItemUI",
"CheckBoxUI", prefix + "ButtonUI",
"ColorChooserUI", prefix + "ColorChooserUI",
"ComboBoxUI", prefix + "ComboBoxUI",
"DesktopIconUI", prefix + "DesktopIconUI",
"DesktopPaneUI", prefix + "DesktopPaneUI",
"EditorPaneUI", prefix + "TextUI",
"FileChooserUI", prefix + "FileChooserUI",
"FormattedTextFieldUI", prefix + "TextUI",
"InternalFrameUI", prefix + "InternalFrameUI",
"LabelUI", prefix + "LabelUI",
"ListUI", prefix + "ListUI",
"MenuBarUI", prefix + "MenuBarUI",
"MenuItemUI", prefix + "MenuItemUI",
"MenuUI", prefix + "MenuItemUI",
"OptionPaneUI", prefix + "OptionPaneUI",
"PanelUI", prefix + "PanelUI",
"PasswordFieldUI", prefix + "TextUI",
"PopupMenuSeparatorUI", prefix + "SeparatorUI",
"PopupMenuUI", prefix + "PopupMenuUI",
"ProgressBarUI", prefix + "ProgressBarUI",
"RadioButtonMenuItemUI", prefix + "MenuItemUI",
"RadioButtonUI", prefix + "ButtonUI",
"RootPaneUI", prefix + "RootPaneUI",
"ScrollBarUI", prefix + "ScrollBarUI",
"ScrollPaneUI", prefix + "ScrollPaneUI",
"SeparatorUI", prefix + "SeparatorUI",
"SliderUI", prefix + "SliderUI",
"SpinnerUI", prefix + "SpinnerUI",
"SplitPaneUI", prefix + "SplitPaneUI",
"TabbedPaneUI", prefix + "TabbedPaneUI",
"TableHeaderUI", prefix + "TableHeaderUI",
"TableUI", prefix + "TableUI",
"TextAreaUI", prefix + "TextUI",
"TextFieldUI", prefix + "TextUI",
"TextPaneUI", prefix + "TextUI",
"ToggleButtonUI", prefix + "ButtonUI",
"ToolBarSeparatorUI", prefix + "SeparatorUI",
"ToolBarUI", prefix + "ToolBarUI",
"ToolTipUI", prefix + "ToolTipUI",
"TreeUI", prefix + "TreeUI",
"ViewportUI", prefix + "ViewportUI",
};
table.putDefaults(uiDefaults);
return table;
}
}
/**
* We want the Test auxiliary look and feel to be quiet and fallback
* gracefully if it cannot find a UI. This class overrides the
* getUIError method of UIDefaults, which is the method that
* emits error messages when it cannot find a UI class in the
* LAF.
*/
class TestALFUIDefaults extends UIDefaults {
protected void getUIError(String msg) {
System.err.println("Test auxiliary L&F: " + msg);
}
}
/*
* Copyright 2002-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. 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.
*/
package com.sun.java.swing;
import sun.awt.EventQueueDelegate;
import sun.awt.AppContext;
import java.util.Map;
import java.util.concurrent.Callable;
import java.awt.AWTEvent;
import java.awt.EventQueue;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.RepaintManager;
/**
* A collection of utility methods for Swing.
* <p>
* <b>WARNING:</b> While this class is public, it should not be treated as
* public API and its API may change in incompatable ways between dot dot
* releases and even patch releases. You should not rely on this class even
* existing.
*
* This is a second part of sun.swing.SwingUtilities2. It is required
* to provide services for JavaFX applets.
*
*/
public class SwingUtilities3 {
/**
* The {@code clientProperty} key for delegate {@code RepaintManager}
*/
private static final Object DELEGATE_REPAINT_MANAGER_KEY =
new StringBuilder("DelegateRepaintManagerKey");
/**
* Registers delegate RepaintManager for {@code JComponent}.
*/
public static void setDelegateRepaintManager(JComponent component,
RepaintManager repaintManager) {
/* setting up flag in AppContext to speed up lookups in case
* there are no delegate RepaintManagers used.
*/
AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
Boolean.TRUE);
component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
repaintManager);
}
/**
* Returns delegate {@code RepaintManager} for {@code component} hierarchy.
*/
public static RepaintManager getDelegateRepaintManager(Component
component) {
RepaintManager delegate = null;
if (Boolean.TRUE == AppContext.getAppContext().get(
DELEGATE_REPAINT_MANAGER_KEY)) {
while (delegate == null && component != null) {
while (component != null
&& ! (component instanceof JComponent)) {
component = component.getParent();
}
if (component != null) {
delegate = (RepaintManager)
((JComponent) component)
.getClientProperty(DELEGATE_REPAINT_MANAGER_KEY);
component = component.getParent();
}
}
}
return delegate;
}
/*
* We use maps to avoid reflection. Hopefully it should perform better
* this way.
*/
public static void setEventQueueDelegate(
Map<String, Map<String, Object>> map) {
EventQueueDelegate.setDelegate(new EventQueueDelegateFromMap(map));
}
private static class EventQueueDelegateFromMap
implements EventQueueDelegate.Delegate {
private final AWTEvent[] afterDispatchEventArgument;
private final Object[] afterDispatchHandleArgument;
private final Callable<Void> afterDispatchCallable;
private final AWTEvent[] beforeDispatchEventArgument;
private final Callable<Object> beforeDispatchCallable;
private final EventQueue[] getNextEventEventQueueArgument;
private final Callable<AWTEvent> getNextEventCallable;
@SuppressWarnings("unchecked")
public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) {
Map<String, Object> methodMap = objectMap.get("afterDispatch");
afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
afterDispatchHandleArgument = (Object[]) methodMap.get("handle");
afterDispatchCallable = (Callable<Void>) methodMap.get("method");
methodMap = objectMap.get("beforeDispatch");
beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
beforeDispatchCallable = (Callable<Object>) methodMap.get("method");
methodMap = objectMap.get("getNextEvent");
getNextEventEventQueueArgument =
(EventQueue[]) methodMap.get("eventQueue");
getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
}
@Override
public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException {
afterDispatchEventArgument[0] = event;
afterDispatchHandleArgument[0] = handle;
try {
afterDispatchCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Object beforeDispatch(AWTEvent event) throws InterruptedException {
beforeDispatchEventArgument[0] = event;
try {
return beforeDispatchCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException {
getNextEventEventQueueArgument[0] = eventQueue;
try {
return getNextEventCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
......@@ -442,7 +442,10 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
}
if (updateModel) {
getColorSelectionModel().setSelectedColor(color);
ColorSelectionModel model = getColorSelectionModel();
if (model != null) {
model.setSelectedColor(color);
}
}
triangle.setColor(hue, saturation, brightness);
......
......@@ -770,33 +770,56 @@ class Metacity implements SynthConstants {
JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
JComponent closeButton = findChild(titlePane, "InternalFrameTitlePane.closeButton");
int buttonGap = 0;
Insets button_border = (Insets)gm.get("button_border");
Dimension buttonDim = calculateButtonSize(titlePane);
int x = getInt("left_titlebar_edge");
int y = (button_border != null) ? button_border.top : 0;
if (titlePaneParent.getComponentOrientation().isLeftToRight()) {
int x = getInt("left_titlebar_edge");
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x = w - buttonDim.width - getInt("right_titlebar_edge");
if (button_border != null) {
x -= button_border.right;
}
x = w - buttonDim.width - getInt("right_titlebar_edge");
if (button_border != null) {
x -= button_border.right;
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= (buttonDim.width + buttonGap);
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= buttonDim.width;
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= (buttonDim.width + buttonGap);
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= buttonDim.width;
}
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
}
} else {
int x = w - buttonDim.width - getInt("right_titlebar_edge");
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x = getInt("left_titlebar_edge");
if (button_border != null) {
x += button_border.left;
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x += buttonDim.width;
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x += buttonDim.width;
}
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
}
}
}
} // end TitlePaneLayout
......@@ -973,10 +996,8 @@ class Metacity implements SynthConstants {
String title = jif.getTitle();
if (title != null) {
FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g);
if (jif.getComponentOrientation().isLeftToRight()) {
title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
calculateTitleTextWidth(g, jif));
}
title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
calculateTitleArea(jif).width);
g.setColor(color);
SwingUtilities2.drawString(jif, g, title, x, y + fm.getAscent());
}
......@@ -1010,9 +1031,10 @@ class Metacity implements SynthConstants {
JComponent titlePane = findChild(jif, "InternalFrame.northPane");
Dimension buttonDim = calculateButtonSize(titlePane);
Insets title_border = (Insets)frameGeometry.get("title_border");
Rectangle r = new Rectangle();
Insets button_border = (Insets)getFrameGeometry().get("button_border");
r.x = getInt("left_titlebar_edge") + buttonDim.width;
Rectangle r = new Rectangle();
r.x = getInt("left_titlebar_edge");
r.y = 0;
r.height = titlePane.getHeight();
if (title_border != null) {
......@@ -1021,15 +1043,36 @@ class Metacity implements SynthConstants {
r.height -= (title_border.top + title_border.bottom);
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
if (jif.isClosable()) {
r.width -= buttonDim.width;
}
if (jif.isMaximizable()) {
r.width -= buttonDim.width;
}
if (jif.isIconifiable()) {
r.width -= buttonDim.width;
if (titlePane.getParent().getComponentOrientation().isLeftToRight()) {
r.x += buttonDim.width;
if (button_border != null) {
r.x += button_border.left;
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
if (jif.isClosable()) {
r.width -= buttonDim.width;
}
if (jif.isMaximizable()) {
r.width -= buttonDim.width;
}
if (jif.isIconifiable()) {
r.width -= buttonDim.width;
}
} else {
if (jif.isClosable()) {
r.x += buttonDim.width;
}
if (jif.isMaximizable()) {
r.x += buttonDim.width;
}
if (jif.isIconifiable()) {
r.x += buttonDim.width;
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge")
- buttonDim.width;
if (button_border != null) {
r.x -= button_border.right;
}
}
if (title_border != null) {
r.width -= title_border.right;
......
......@@ -49,8 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* ReferenceQueue of unreferenced WeakPCLs.
*/
private static ReferenceQueue queue;
private static ReferenceQueue<DesktopProperty> queue;
/**
* PropertyChangeListener attached to the Toolkit.
......@@ -76,7 +75,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
static {
queue = new ReferenceQueue();
queue = new ReferenceQueue<DesktopProperty>();
}
/**
......@@ -117,8 +116,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
XPStyle.invalidateStyle();
}
Frame appFrames[] = Frame.getFrames();
for (int j=0; j < appFrames.length; j++) {
updateWindowUI(appFrames[j]);
for (Frame appFrame : appFrames) {
updateWindowUI(appFrame);
}
}
......@@ -128,8 +127,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
private static void updateWindowUI(Window window) {
SwingUtilities.updateComponentTreeUI(window);
Window ownedWins[] = window.getOwnedWindows();
for (int i=0; i < ownedWins.length; i++) {
updateWindowUI(ownedWins[i]);
for (Window ownedWin : ownedWins) {
updateWindowUI(ownedWin);
}
}
......@@ -270,13 +269,13 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* is handled via a WeakReference so as not to pin down the
* DesktopProperty.
*/
private static class WeakPCL extends WeakReference
private static class WeakPCL extends WeakReference<DesktopProperty>
implements PropertyChangeListener {
private Toolkit kit;
private String key;
private LookAndFeel laf;
WeakPCL(Object target, Toolkit kit, String key, LookAndFeel laf) {
WeakPCL(DesktopProperty target, Toolkit kit, String key, LookAndFeel laf) {
super(target, queue);
this.kit = kit;
this.key = key;
......@@ -284,7 +283,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
}
public void propertyChange(PropertyChangeEvent pce) {
DesktopProperty property = (DesktopProperty)get();
DesktopProperty property = get();
if (property == null || laf != UIManager.getLookAndFeel()) {
// The property was GC'ed, we're no longer interested in
......
......@@ -96,7 +96,7 @@ public class WindowsDesktopManager extends DefaultDesktopManager
}
} catch (PropertyVetoException e) {}
if (f != currentFrame) {
currentFrameRef = new WeakReference(f);
currentFrameRef = new WeakReference<JInternalFrame>(f);
}
}
......
......@@ -983,7 +983,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
} else if (s.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) {
if (o != e.getOldValue()) {
cc.applyComponentOrientation(o);
}
} else if (s.equals("ancestor")) {
......@@ -1123,7 +1123,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
* Data model for a type-face selection combo-box.
*/
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector();
Vector<File> directories = new Vector<File>();
int[] depths = null;
File selectedDirectory = null;
JFileChooser chooser = getFileChooser();
......@@ -1162,7 +1162,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical = null;
File canonical;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
......@@ -1175,7 +1175,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector path = new Vector(10);
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
......@@ -1183,7 +1183,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = (File)path.get(i);
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
......@@ -1202,12 +1202,12 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
private void calculateDepths() {
depths = new int[directories.size()];
for (int i = 0; i < depths.length; i++) {
File dir = (File)directories.get(i);
File dir = directories.get(i);
File parent = dir.getParentFile();
depths[i] = 0;
if (parent != null) {
for (int j = i-1; j >= 0; j--) {
if (parent.equals((File)directories.get(j))) {
if (parent.equals(directories.get(j))) {
depths[i] = depths[j] + 1;
break;
}
......@@ -1306,8 +1306,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false;
if(currentFilter != null) {
for(int i=0; i < filters.length; i++) {
if(filters[i] == currentFilter) {
for (FileFilter filter : filters) {
if (filter == currentFilter) {
found = true;
}
}
......
......@@ -137,25 +137,46 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
fm.getDescent()) / 2;
Rectangle lastIconBounds = new Rectangle(0, 0, 0, 0);
if (frame.isIconifiable()) {
lastIconBounds = iconButton.getBounds();
} else if (frame.isMaximizable()) {
lastIconBounds = maxButton.getBounds();
} else if (frame.isClosable()) {
lastIconBounds = closeButton.getBounds();
}
int titleX;
Rectangle r = new Rectangle(0, 0, 0, 0);
if (frame.isIconifiable()) r = iconButton.getBounds();
else if (frame.isMaximizable()) r = maxButton.getBounds();
else if (frame.isClosable()) r = closeButton.getBounds();
int titleW;
if(WindowsGraphicsUtils.isLeftToRight(frame) ) {
if (r.x == 0) r.x = frame.getWidth()-frame.getInsets().right;
titleX = systemLabel.getX() + systemLabel.getWidth() + 2;
if (xp != null) {
titleX += 2;
}
titleW = r.x - titleX - 3;
title = getTitle(frame.getTitle(), fm, titleW);
int gap = 2;
if (WindowsGraphicsUtils.isLeftToRight(frame)) {
if (lastIconBounds.x == 0) { // There are no icons
lastIconBounds.x = frame.getWidth() - frame.getInsets().right;
}
titleX = systemLabel.getX() + systemLabel.getWidth() + gap;
if (xp != null) {
titleX += 2;
}
titleW = lastIconBounds.x - titleX - gap;
} else {
titleX = systemLabel.getX() - 2
- SwingUtilities2.stringWidth(frame,fm,title);
if (lastIconBounds.x == 0) { // There are no icons
lastIconBounds.x = frame.getInsets().left;
}
titleW = SwingUtilities2.stringWidth(frame, fm, title);
int minTitleX = lastIconBounds.x + lastIconBounds.width + gap;
if (xp != null) {
minTitleX += 2;
}
int availableWidth = systemLabel.getX() - gap - minTitleX;
if (availableWidth > titleW) {
titleX = systemLabel.getX() - gap - titleW;
} else {
titleX = minTitleX;
titleW = availableWidth;
}
}
title = getTitle(frame.getTitle(), fm, titleW);
if (xp != null) {
String shadowType = null;
if (isSelected) {
......@@ -258,8 +279,8 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
g.fillRect(0, 0, w, h);
}
Icon icon = getIcon();
int iconWidth = 0;
int iconHeight = 0;
int iconWidth;
int iconHeight;
if (icon != null &&
(iconWidth = icon.getIconWidth()) > 0 &&
(iconHeight = icon.getIconHeight()) > 0) {
......@@ -304,18 +325,18 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
}
protected void addSystemMenuItems(JPopupMenu menu) {
JMenuItem mi = (JMenuItem)menu.add(restoreAction);
JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R');
mi = (JMenuItem)menu.add(moveAction);
mi = menu.add(moveAction);
mi.setMnemonic('M');
mi = (JMenuItem)menu.add(sizeAction);
mi = menu.add(sizeAction);
mi.setMnemonic('S');
mi = (JMenuItem)menu.add(iconifyAction);
mi = menu.add(iconifyAction);
mi.setMnemonic('n');
mi = (JMenuItem)menu.add(maximizeAction);
mi = menu.add(maximizeAction);
mi.setMnemonic('x');
systemPopupMenu.add(new JSeparator());
mi = (JMenuItem)menu.add(closeAction);
mi = menu.add(closeAction);
mi.setMnemonic('C');
}
......@@ -441,7 +462,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName();
String prop = evt.getPropertyName();
// Update the internal frame icon for the system menu.
if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
......
......@@ -369,21 +369,21 @@ public class WindowsScrollBarUI extends BasicScrollBarUI {
*/
private static class Grid {
private static final int BUFFER_SIZE = 64;
private static HashMap map;
private static HashMap<String, WeakReference<Grid>> map;
private BufferedImage image;
static {
map = new HashMap();
map = new HashMap<String, WeakReference<Grid>>();
}
public static Grid getGrid(Color fg, Color bg) {
String key = fg.getRGB() + " " + bg.getRGB();
WeakReference ref = (WeakReference)map.get(key);
Grid grid = (ref == null) ? null : (Grid)ref.get();
WeakReference<Grid> ref = map.get(key);
Grid grid = (ref == null) ? null : ref.get();
if (grid == null) {
grid = new Grid(fg, bg);
map.put(key, new WeakReference(grid));
map.put(key, new WeakReference<Grid>(grid));
}
return grid;
}
......
......@@ -53,13 +53,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
* Keys to use for forward focus traversal when the JComponent is
* managing focus.
*/
private static Set managingFocusForwardTraversalKeys;
private static Set<KeyStroke> managingFocusForwardTraversalKeys;
/**
* Keys to use for backward focus traversal when the JComponent is
* managing focus.
*/
private static Set managingFocusBackwardTraversalKeys;
private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
private boolean contentOpaque = true;
......@@ -69,13 +69,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
// focus forward traversal key
if (managingFocusForwardTraversalKeys==null) {
managingFocusForwardTraversalKeys = new HashSet();
managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
}
tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
// focus backward traversal key
if (managingFocusBackwardTraversalKeys==null) {
managingFocusBackwardTraversalKeys = new HashSet();
managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
}
tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
......
......@@ -124,7 +124,7 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI {
setIcon(null);
sortIcon = null;
SortOrder sortOrder =
getColumnSortOrder(header.getTable(), column);
getColumnSortOrder(table, column);
if (sortOrder != null) {
switch (sortOrder) {
case ASCENDING:
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=Sample Text Sample Text
ColorChooser.swatchesNameText=Swatches
ColorChooser.swatchesMnemonic=83
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Recent:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=Red
ColorChooser.rgbRedMnemonic=68
ColorChooser.rgbGreenText=Green
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=Blue
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=90
ColorChooser.sampleText=Beispieltext Beispieltext
ColorChooser.swatchesNameText=Muster
ColorChooser.swatchesMnemonic=77
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Aktuell:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=Rot
ColorChooser.rgbRedMnemonic=82
ColorChooser.rgbGreenText=Gr\u00fcn
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=Blau
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=Texto de ejemplo Texto de ejemplo
ColorChooser.swatchesNameText=Muestras
ColorChooser.swatchesMnemonic=77
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Reciente:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=V
ColorChooser.hsbBlueText=A
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=Rojo
ColorChooser.rgbRedMnemonic=74
ColorChooser.rgbGreenText=Verde
ColorChooser.rgbGreenMnemonic=86
ColorChooser.rgbBlueText=Azul
ColorChooser.rgbBlueMnemonic=76
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=Echantillon de texte Echantillon de texte
ColorChooser.swatchesNameText=Echantillons
ColorChooser.swatchesMnemonic=69
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Dernier :
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=V
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RVB
ColorChooser.rgbMnemonic=86
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=Rouge
ColorChooser.rgbRedMnemonic=71
ColorChooser.rgbGreenText=Vert
ColorChooser.rgbGreenMnemonic=84
ColorChooser.rgbBlueText=Bleu
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=Testo di prova Testo di prova
ColorChooser.swatchesNameText=Colori campione
ColorChooser.swatchesMnemonic=67
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Recenti:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=Rosso
ColorChooser.rgbRedMnemonic=79
ColorChooser.rgbGreenText=Verde
ColorChooser.rgbGreenMnemonic=69
ColorChooser.rgbBlueText=Blu
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=\u30b5\u30f3\u30d7\u30eb\u30c6\u30ad\u30b9\u30c8 \u30b5\u30f3\u30d7\u30eb\u30c6\u30ad\u30b9\u30c8
ColorChooser.swatchesNameText=\u30b5\u30f3\u30d7\u30eb(S)
ColorChooser.swatchesMnemonic=83
ColorChooser.swatchesDisplayedMnemonicIndex=5
ColorChooser.swatchesRecentText=\u6700\u65b0:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=\u8d64(D)
ColorChooser.rgbRedMnemonic=68
ColorChooser.rgbGreenText=\u7dd1(N)
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=\u9752(B)
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=\uc0d8\ud50c \ud14d\uc2a4\ud2b8 \uc0d8\ud50c \ud14d\uc2a4\ud2b8
ColorChooser.swatchesNameText=\uacac\ubcf8(S)
ColorChooser.swatchesMnemonic=83
ColorChooser.swatchesDisplayedMnemonicIndex=3
ColorChooser.swatchesRecentText=\ucd5c\uadfc \ubaa9\ub85d:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=\ube68\uac04\uc0c9(D)
ColorChooser.rgbRedMnemonic=68
ColorChooser.rgbGreenText=\ub179\uc0c9(N)
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=\ud30c\ub780\uc0c9(B)
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=84
ColorChooser.sampleText=Exempeltext Exempeltext
ColorChooser.swatchesNameText=Prov
ColorChooser.swatchesMnemonic=80
ColorChooser.swatchesDisplayedMnemonicIndex=0
ColorChooser.swatchesRecentText=Tidigare:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=R\u00f6d
ColorChooser.rgbRedMnemonic=82
ColorChooser.rgbGreenText=Gr\u00f6n
ColorChooser.rgbGreenMnemonic=71
ColorChooser.rgbBlueText=Bl\u00e5
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=\u6837\u54c1\u6587\u672c \u6837\u54c1\u6587\u672c
ColorChooser.swatchesNameText=\u6837\u54c1(S)
ColorChooser.swatchesMnemonic=83
ColorChooser.swatchesDisplayedMnemonicIndex=3
ColorChooser.swatchesRecentText=\u6700\u8fd1:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=\u7ea2
ColorChooser.rgbRedMnemonic=68
ColorChooser.rgbGreenText=\u7eff
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=\u84dd
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText=\u7bc4\u4f8b\u6587\u5b57 \u7bc4\u4f8b\u6587\u5b57
ColorChooser.swatchesNameText=\u8abf\u8272\u677f(S)
ColorChooser.swatchesMnemonic=83
ColorChooser.swatchesDisplayedMnemonicIndex=4
ColorChooser.swatchesRecentText=\u6700\u65b0\u9078\u64c7:
ColorChooser.hsbNameText=HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic=72
ColorChooser.hsbDisplayedMnemonicIndex=0
ColorChooser.hsbHueText=H
ColorChooser.hsbSaturationText=S
ColorChooser.hsbBrightnessText=B
ColorChooser.hsbRedText=R
ColorChooser.hsbGreenText=G
ColorChooser.hsbBlueText=B
ColorChooser.hsvNameText=HSV
ColorChooser.hsvMnemonic=72
ColorChooser.hsvHueText=Hue
ColorChooser.hsvSaturationText=Saturation
ColorChooser.hsvValueText=Value
ColorChooser.hsvTransparencyText=Transparency
ColorChooser.hslNameText=HSL
ColorChooser.hslMnemonic=76
ColorChooser.hslHueText=Hue
ColorChooser.hslSaturationText=Saturation
ColorChooser.hslLightnessText=Lightness
ColorChooser.hslTransparencyText=Transparency
ColorChooser.rgbNameText=RGB
ColorChooser.rgbMnemonic=71
ColorChooser.rgbDisplayedMnemonicIndex=1
ColorChooser.rgbRedText=\u7d05\u8272(D)
ColorChooser.rgbRedMnemonic=68
ColorChooser.rgbGreenText=\u7da0\u8272(N)
ColorChooser.rgbGreenMnemonic=78
ColorChooser.rgbBlueText=\u85cd\u8272(B)
ColorChooser.rgbBlueMnemonic=66
ColorChooser.rgbAlphaText=Alpha
ColorChooser.rgbHexCodeText=Color Code
ColorChooser.rgbHexCodeMnemonic=67
ColorChooser.cmykNameText=CMYK
ColorChooser.cmykMnemonic=77
ColorChooser.cmykCyanText=Cyan
ColorChooser.cmykMagentaText=Magenta
ColorChooser.cmykYellowText=Yellow
ColorChooser.cmykBlackText=Black
ColorChooser.cmykAlphaText=Alpha
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
......
......@@ -39,6 +39,7 @@ import java.util.Vector;
import java.util.logging.*;
import sun.awt.dnd.SunDragSourceContextPeer;
import sun.awt.EventQueueDelegate;
/**
* EventDispatchThread is a package-private AWT class which takes
......@@ -243,10 +244,16 @@ class EventDispatchThread extends Thread {
try {
AWTEvent event;
boolean eventOK;
EventQueueDelegate.Delegate delegate =
EventQueueDelegate.getDelegate();
do {
event = (id == ANY_EVENT)
? theQueue.getNextEvent()
: theQueue.getNextEvent(id);
if (delegate != null && id == ANY_EVENT) {
event = delegate.getNextEvent(theQueue);
} else {
event = (id == ANY_EVENT)
? theQueue.getNextEvent()
: theQueue.getNextEvent(id);
}
eventOK = true;
synchronized (eventFilters) {
......@@ -272,7 +279,14 @@ class EventDispatchThread extends Thread {
eventLog.log(Level.FINEST, "Dispatching: " + event);
}
Object handle = null;
if (delegate != null) {
handle = delegate.beforeDispatch(event);
}
theQueue.dispatchEvent(event);
if (delegate != null) {
delegate.afterDispatch(event, handle);
}
return true;
}
catch (ThreadDeath death) {
......
......@@ -298,7 +298,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{});
newL = (EventListener[])MethodUtil.invoke(m, newInstance, new Object[]{});
}
catch (Throwable e2) {
catch (Exception e2) {
try {
Method m = type.getMethod("getListeners", new Class[]{Class.class});
oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{listenerType});
......
......@@ -404,7 +404,7 @@ public class EventHandler implements InvocationHandler {
Object newTarget = MethodUtil.invoke(getter, target, new Object[]{});
return applyGetters(newTarget, rest);
}
catch (Throwable e) {
catch (Exception e) {
throw new RuntimeException("Failed to call method: " + first +
" on " + target, e);
}
......
......@@ -650,7 +650,7 @@ class java_util_Map_PersistenceDelegate extends DefaultPersistenceDelegate {
// Remove the new elements.
// Do this first otherwise we undo the adding work.
if (newMap != null) {
for ( Object newKey : newMap.keySet() ) {
for (Object newKey : newMap.keySet().toArray()) {
// PENDING: This "key" is not in the right environment.
if (!oldMap.containsKey(newKey)) {
invokeStatement(oldInstance, "remove", new Object[]{newKey}, out);
......@@ -986,14 +986,20 @@ class java_awt_Component_PersistenceDelegate extends DefaultPersistenceDelegate
// null to defined values after the Windows are made visible -
// special case them for now.
if (!(oldInstance instanceof java.awt.Window)) {
String[] fieldNames = new String[]{"background", "foreground", "font"};
for(int i = 0; i < fieldNames.length; i++) {
String name = fieldNames[i];
Object oldValue = ReflectionUtils.getPrivateField(oldInstance, java.awt.Component.class, name, out.getExceptionListener());
Object newValue = (newInstance == null) ? null : ReflectionUtils.getPrivateField(newInstance, java.awt.Component.class, name, out.getExceptionListener());
if (oldValue != null && !oldValue.equals(newValue)) {
invokeStatement(oldInstance, "set" + NameGenerator.capitalize(name), new Object[]{oldValue}, out);
}
Object oldBackground = c.isBackgroundSet() ? c.getBackground() : null;
Object newBackground = c2.isBackgroundSet() ? c2.getBackground() : null;
if (!MetaData.equals(oldBackground, newBackground)) {
invokeStatement(oldInstance, "setBackground", new Object[] { oldBackground }, out);
}
Object oldForeground = c.isForegroundSet() ? c.getForeground() : null;
Object newForeground = c2.isForegroundSet() ? c2.getForeground() : null;
if (!MetaData.equals(oldForeground, newForeground)) {
invokeStatement(oldInstance, "setForeground", new Object[] { oldForeground }, out);
}
Object oldFont = c.isFontSet() ? c.getFont() : null;
Object newFont = c2.isFontSet() ? c2.getFont() : null;
if (!MetaData.equals(oldFont, newFont)) {
invokeStatement(oldInstance, "setFont", new Object[] { oldFont }, out);
}
}
......@@ -1104,26 +1110,30 @@ class java_awt_List_PersistenceDelegate extends DefaultPersistenceDelegate {
// BorderLayout
class java_awt_BorderLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
private static final String[] CONSTRAINTS = {
BorderLayout.NORTH,
BorderLayout.SOUTH,
BorderLayout.EAST,
BorderLayout.WEST,
BorderLayout.CENTER,
BorderLayout.PAGE_START,
BorderLayout.PAGE_END,
BorderLayout.LINE_START,
BorderLayout.LINE_END,
};
@Override
protected void initialize(Class<?> type, Object oldInstance,
Object newInstance, Encoder out) {
super.initialize(type, oldInstance, newInstance, out);
String[] locations = {"north", "south", "east", "west", "center"};
String[] names = {java.awt.BorderLayout.NORTH, java.awt.BorderLayout.SOUTH,
java.awt.BorderLayout.EAST, java.awt.BorderLayout.WEST,
java.awt.BorderLayout.CENTER};
for(int i = 0; i < locations.length; i++) {
Object oldC = ReflectionUtils.getPrivateField(oldInstance,
java.awt.BorderLayout.class,
locations[i],
out.getExceptionListener());
Object newC = ReflectionUtils.getPrivateField(newInstance,
java.awt.BorderLayout.class,
locations[i],
out.getExceptionListener());
BorderLayout oldLayout = (BorderLayout) oldInstance;
BorderLayout newLayout = (BorderLayout) newInstance;
for (String constraints : CONSTRAINTS) {
Object oldC = oldLayout.getLayoutComponent(constraints);
Object newC = newLayout.getLayoutComponent(constraints);
// Pending, assume any existing elements are OK.
if (oldC != null && newC == null) {
invokeStatement(oldInstance, "addLayoutComponent",
new Object[]{oldC, names[i]}, out);
new Object[] { oldC, constraints }, out);
}
}
}
......
/*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 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
......@@ -208,91 +208,91 @@ public class PropertyChangeSupport implements Serializable {
}
/**
* Report a bound property update to any registered listeners.
* No event is fired if old and new are equal and non-null.
*
* Reports a bound property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal and non-null.
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes {@code
* PropertyChangeEvent} value.
* {@link #firePropertyChange(PropertyChangeEvent)} method.
*
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
public void firePropertyChange(String propertyName,
Object oldValue, Object newValue) {
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
firePropertyChange(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
}
firePropertyChange(new PropertyChangeEvent(source, propertyName,
oldValue, newValue));
}
/**
* Report an int bound property update to any registered listeners.
* No event is fired if old and new are equal.
* Reports an integer bound property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes Object values.
* {@link #firePropertyChange(String, Object, Object)} method.
*
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
public void firePropertyChange(String propertyName,
int oldValue, int newValue) {
if (oldValue == newValue) {
return;
public void firePropertyChange(String propertyName, int oldValue, int newValue) {
if (oldValue != newValue) {
firePropertyChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
}
firePropertyChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
}
/**
* Report a boolean bound property update to any registered listeners.
* No event is fired if old and new are equal.
* Reports a boolean bound property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes Object values.
* {@link #firePropertyChange(String, Object, Object)} method.
*
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
public void firePropertyChange(String propertyName,
boolean oldValue, boolean newValue) {
if (oldValue == newValue) {
return;
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
if (oldValue != newValue) {
firePropertyChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
firePropertyChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
/**
* Fire an existing PropertyChangeEvent to any registered listeners.
* No event is fired if the given event's old and new values are
* equal and non-null.
* @param evt The PropertyChangeEvent object.
* Fires a property change event to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if the given event's old and new values are equal and non-null.
*
* @param event the {@code PropertyChangeEvent} to be fired
*/
public void firePropertyChange(PropertyChangeEvent evt) {
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
String propertyName = evt.getPropertyName();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
PropertyChangeListener[] common = this.map.get(null);
PropertyChangeListener[] named = (propertyName != null)
? this.map.get(propertyName)
: null;
public void firePropertyChange(PropertyChangeEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
String name = event.getPropertyName();
fire(common, evt);
fire(named, evt);
PropertyChangeListener[] common = this.map.get(null);
PropertyChangeListener[] named = (name != null)
? this.map.get(name)
: null;
fire(common, event);
fire(named, event);
}
}
private void fire(PropertyChangeListener[] listeners, PropertyChangeEvent event) {
private static void fire(PropertyChangeListener[] listeners, PropertyChangeEvent event) {
if (listeners != null) {
for (PropertyChangeListener listener : listeners) {
listener.propertyChange(event);
......@@ -301,78 +301,69 @@ public class PropertyChangeSupport implements Serializable {
}
/**
* Report a bound indexed property update to any registered
* listeners.
* Reports a bound indexed property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal
* and non-null.
*
* No event is fired if old and new values are equal and non-null.
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes {@code PropertyChangeEvent} value.
* {@link #firePropertyChange(PropertyChangeEvent)} method.
*
* @param propertyName The programmatic name of the property that
* was changed.
* @param index index of the property element that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param index the index of the property element that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @since 1.5
*/
public void fireIndexedPropertyChange(String propertyName, int index,
Object oldValue, Object newValue) {
firePropertyChange(new IndexedPropertyChangeEvent
(source, propertyName, oldValue, newValue, index));
public void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) {
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
firePropertyChange(new IndexedPropertyChangeEvent(source, propertyName, oldValue, newValue, index));
}
}
/**
* Report an <code>int</code> bound indexed property update to any registered
* listeners.
* Reports an integer bound indexed property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* fireIndexedPropertyChange method which takes Object values.
* {@link #fireIndexedPropertyChange(String, int, Object, Object)} method.
*
* @param propertyName The programmatic name of the property that
* was changed.
* @param index index of the property element that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param index the index of the property element that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @since 1.5
*/
public void fireIndexedPropertyChange(String propertyName, int index,
int oldValue, int newValue) {
if (oldValue == newValue) {
return;
public void fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue) {
if (oldValue != newValue) {
fireIndexedPropertyChange(propertyName, index, Integer.valueOf(oldValue), Integer.valueOf(newValue));
}
fireIndexedPropertyChange(propertyName, index,
Integer.valueOf(oldValue),
Integer.valueOf(newValue));
}
/**
* Report a <code>boolean</code> bound indexed property update to any
* registered listeners.
* Reports a boolean bound indexed property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* fireIndexedPropertyChange method which takes Object values.
* {@link #fireIndexedPropertyChange(String, int, Object, Object)} method.
*
* @param propertyName The programmatic name of the property that
* was changed.
* @param index index of the property element that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that was changed
* @param index the index of the property element that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @since 1.5
*/
public void fireIndexedPropertyChange(String propertyName, int index,
boolean oldValue, boolean newValue) {
if (oldValue == newValue) {
return;
public void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue) {
if (oldValue != newValue) {
fireIndexedPropertyChange(propertyName, index, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
fireIndexedPropertyChange(propertyName, index, Boolean.valueOf(oldValue),
Boolean.valueOf(newValue));
}
/**
......
......@@ -204,20 +204,21 @@ public interface PropertyEditor {
//----------------------------------------------------------------------
/**
* Register a listener for the PropertyChange event. When a
* PropertyEditor changes its value it should fire a PropertyChange
* event on all registered PropertyChangeListeners, specifying the
* null value for the property name and itself as the source.
* Adds a listener for the value change.
* When the property editor changes its value
* it should fire a {@link PropertyChangeEvent}
* on all registered {@link PropertyChangeListener}s,
* specifying the {@code null} value for the property name
* and itself as the source.
*
* @param listener An object to be invoked when a PropertyChange
* event is fired.
* @param listener the {@link PropertyChangeListener} to add
*/
void addPropertyChangeListener(PropertyChangeListener listener);
/**
* Remove a listener for the PropertyChange event.
* Removes a listener for the value change.
*
* @param listener The PropertyChange listener to be removed.
* @param listener the {@link PropertyChangeListener} to remove
*/
void removePropertyChangeListener(PropertyChangeListener listener);
......
......@@ -233,11 +233,20 @@ public class PropertyEditorSupport implements PropertyEditor {
//----------------------------------------------------------------------
/**
* Register a listener for the PropertyChange event. The class will
* fire a PropertyChange value whenever the value is updated.
* Adds a listener for the value change.
* When the property editor changes its value
* it should fire a {@link PropertyChangeEvent}
* on all registered {@link PropertyChangeListener}s,
* specifying the {@code null} value for the property name.
* If the source property is set,
* it should be used as the source of the event.
* <p>
* The same listener object may be added more than once,
* and will be called as many times as it is added.
* If {@code listener} is {@code null},
* no exception is thrown and no action is taken.
*
* @param listener An object to be invoked when a PropertyChange
* event is fired.
* @param listener the {@link PropertyChangeListener} to add
*/
public synchronized void addPropertyChangeListener(
PropertyChangeListener listener) {
......@@ -248,9 +257,14 @@ public class PropertyEditorSupport implements PropertyEditor {
}
/**
* Remove a listener for the PropertyChange event.
* Removes a listener for the value change.
* <p>
* If the same listener was added more than once,
* it will be notified one less time after being removed.
* If {@code listener} is {@code null}, or was never added,
* no exception is thrown and no action is taken.
*
* @param listener The PropertyChange listener to be removed.
* @param listener the {@link PropertyChangeListener} to remove
*/
public synchronized void removePropertyChangeListener(
PropertyChangeListener listener) {
......
/*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 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
......@@ -208,126 +208,149 @@ public class VetoableChangeSupport implements Serializable {
}
/**
* Report a vetoable property update to any registered listeners. If
* anyone vetos the change, then fire a new event reverting everyone to
* the old value and then rethrow the PropertyVetoException.
* Reports a constrained property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new are equal and non-null.
* Any listener can throw a {@code PropertyVetoException} to veto the update.
* If one of the listeners vetoes the update, this method passes
* a new "undo" {@code PropertyChangeEvent} that reverts to the old value
* to all listeners that already confirmed this update
* and throws the {@code PropertyVetoException} again.
* <p>
* No event is fired if old and new values are equal and non-null.
* <p>
* This is merely a convenience wrapper around the more general
* {@link #fireVetoableChange(PropertyChangeEvent)} method.
*
* @param propertyName The programmatic name of the property
* that is about to change..
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
* @param propertyName the programmatic name of the property that is about to change
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @throws PropertyVetoException if one of listeners vetoes the property update
*/
public void fireVetoableChange(String propertyName,
Object oldValue, Object newValue)
throws PropertyVetoException {
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
public void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
throws PropertyVetoException {
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
fireVetoableChange(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
}
PropertyChangeEvent evt = new PropertyChangeEvent(source, propertyName,
oldValue, newValue);
fireVetoableChange(evt);
}
/**
* Report a int vetoable property update to any registered listeners.
* No event is fired if old and new are equal.
* Reports an integer constrained property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* Any listener can throw a {@code PropertyVetoException} to veto the update.
* If one of the listeners vetoes the update, this method passes
* a new "undo" {@code PropertyChangeEvent} that reverts to the old value
* to all listeners that already confirmed this update
* and throws the {@code PropertyVetoException} again.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* fireVetoableChange method that takes Object values.
* {@link #fireVetoableChange(String, Object, Object)} method.
*
* @param propertyName The programmatic name of the property
* that is about to change.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that is about to change
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @throws PropertyVetoException if one of listeners vetoes the property update
*/
public void fireVetoableChange(String propertyName,
int oldValue, int newValue)
throws PropertyVetoException {
if (oldValue == newValue) {
return;
public void fireVetoableChange(String propertyName, int oldValue, int newValue)
throws PropertyVetoException {
if (oldValue != newValue) {
fireVetoableChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
}
fireVetoableChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
}
/**
* Report a boolean vetoable property update to any registered listeners.
* No event is fired if old and new are equal.
* Reports a boolean constrained property update to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* Any listener can throw a {@code PropertyVetoException} to veto the update.
* If one of the listeners vetoes the update, this method passes
* a new "undo" {@code PropertyChangeEvent} that reverts to the old value
* to all listeners that already confirmed this update
* and throws the {@code PropertyVetoException} again.
* <p>
* No event is fired if old and new values are equal.
* <p>
* This is merely a convenience wrapper around the more general
* fireVetoableChange method that takes Object values.
* {@link #fireVetoableChange(String, Object, Object)} method.
*
* @param propertyName The programmatic name of the property
* that is about to change.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @param propertyName the programmatic name of the property that is about to change
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @throws PropertyVetoException if one of listeners vetoes the property update
*/
public void fireVetoableChange(String propertyName,
boolean oldValue, boolean newValue)
throws PropertyVetoException {
if (oldValue == newValue) {
return;
public void fireVetoableChange(String propertyName, boolean oldValue, boolean newValue)
throws PropertyVetoException {
if (oldValue != newValue) {
fireVetoableChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
fireVetoableChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
/**
* Fire a vetoable property update to any registered listeners. If
* anyone vetos the change, then fire a new event reverting everyone to
* the old value and then rethrow the PropertyVetoException.
* Fires a property change event to listeners
* that have been registered to track updates of
* all properties or a property with the specified name.
* <p>
* No event is fired if old and new are equal and non-null.
* Any listener can throw a {@code PropertyVetoException} to veto the update.
* If one of the listeners vetoes the update, this method passes
* a new "undo" {@code PropertyChangeEvent} that reverts to the old value
* to all listeners that already confirmed this update
* and throws the {@code PropertyVetoException} again.
* <p>
* No event is fired if the given event's old and new values are equal and non-null.
*
* @param evt The PropertyChangeEvent to be fired.
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
* @param event the {@code PropertyChangeEvent} to be fired
* @throws PropertyVetoException if one of listeners vetoes the property update
*/
public void fireVetoableChange(PropertyChangeEvent evt)
throws PropertyVetoException {
public void fireVetoableChange(PropertyChangeEvent event)
throws PropertyVetoException {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
String name = event.getPropertyName();
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
String propertyName = evt.getPropertyName();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
VetoableChangeListener[] common = this.map.get(null);
VetoableChangeListener[] named = (propertyName != null)
? this.map.get(propertyName)
: null;
fire(common, evt);
fire(named, evt);
}
VetoableChangeListener[] common = this.map.get(null);
VetoableChangeListener[] named = (name != null)
? this.map.get(name)
: null;
private void fire(VetoableChangeListener[] listeners, PropertyChangeEvent event) throws PropertyVetoException {
if (listeners != null) {
VetoableChangeListener current = null;
try {
for (VetoableChangeListener listener : listeners) {
current = listener;
listener.vetoableChange(event);
}
} catch (PropertyVetoException veto) {
// Create an event to revert everyone to the old value.
event = new PropertyChangeEvent( this.source,
event.getPropertyName(),
event.getNewValue(),
event.getOldValue() );
for (VetoableChangeListener listener : listeners) {
if (current == listener) {
break;
VetoableChangeListener[] listeners;
if (common == null) {
listeners = named;
}
else if (named == null) {
listeners = common;
}
else {
listeners = new VetoableChangeListener[common.length + named.length];
System.arraycopy(common, 0, listeners, 0, common.length);
System.arraycopy(named, 0, listeners, common.length, named.length);
}
if (listeners != null) {
int current = 0;
try {
while (current < listeners.length) {
listeners[current].vetoableChange(event);
current++;
}
try {
listener.vetoableChange(event);
} catch (PropertyVetoException ex) {
// We just ignore exceptions that occur during reversions.
}
catch (PropertyVetoException veto) {
event = new PropertyChangeEvent(this.source, name, newValue, oldValue);
for (int i = 0; i < current; i++) {
try {
listeners[i].vetoableChange(event);
}
catch (PropertyVetoException exception) {
// ignore exceptions that occur during rolling back
}
}
throw veto; // rethrow the veto exception
}
// And now rethrow the PropertyVetoException.
throw veto;
}
}
}
......
......@@ -131,10 +131,7 @@ public class JApplet extends Applet implements Accessible,
// Check the timerQ and restart if necessary.
TimerQueue q = TimerQueue.sharedInstance();
if(q != null) {
synchronized(q) {
if(!q.running)
q.start();
}
q.startIfNeeded();
}
/* Workaround for bug 4155072. The shared double buffer image
......
......@@ -40,6 +40,8 @@ import sun.awt.SunToolkit;
import sun.java2d.SunGraphicsEnvironment;
import sun.security.action.GetPropertyAction;
import com.sun.java.swing.SwingUtilities3;
/**
* This class manages repaint requests, allowing the number
......@@ -303,6 +305,11 @@ public class RepaintManager
*/
public synchronized void addInvalidComponent(JComponent invalidComponent)
{
RepaintManager delegate = getDelegate(invalidComponent);
if (delegate != null) {
delegate.addInvalidComponent(invalidComponent);
return;
}
Component validateRoot = null;
/* Find the first JComponent ancestor of this component whose
......@@ -373,6 +380,11 @@ public class RepaintManager
* @see #addInvalidComponent
*/
public synchronized void removeInvalidComponent(JComponent component) {
RepaintManager delegate = getDelegate(component);
if (delegate != null) {
delegate.removeInvalidComponent(component);
return;
}
if(invalidComponents != null) {
int index = invalidComponents.indexOf(component);
if(index != -1) {
......@@ -464,6 +476,11 @@ public class RepaintManager
*/
public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
{
RepaintManager delegate = getDelegate(c);
if (delegate != null) {
delegate.addDirtyRegion(c, x, y, w, h);
return;
}
addDirtyRegion0(c, x, y, w, h);
}
......@@ -588,6 +605,10 @@ public class RepaintManager
* dirty.
*/
public Rectangle getDirtyRegion(JComponent aComponent) {
RepaintManager delegate = getDelegate(aComponent);
if (delegate != null) {
return delegate.getDirtyRegion(aComponent);
}
Rectangle r = null;
synchronized(this) {
r = (Rectangle)dirtyComponents.get(aComponent);
......@@ -603,6 +624,11 @@ public class RepaintManager
* completely painted during the next paintDirtyRegions() call.
*/
public void markCompletelyDirty(JComponent aComponent) {
RepaintManager delegate = getDelegate(aComponent);
if (delegate != null) {
delegate.markCompletelyDirty(aComponent);
return;
}
addDirtyRegion(aComponent,0,0,Integer.MAX_VALUE,Integer.MAX_VALUE);
}
......@@ -611,6 +637,11 @@ public class RepaintManager
* get painted during the next paintDirtyRegions() call.
*/
public void markCompletelyClean(JComponent aComponent) {
RepaintManager delegate = getDelegate(aComponent);
if (delegate != null) {
delegate.markCompletelyClean(aComponent);
return;
}
synchronized(this) {
dirtyComponents.remove(aComponent);
}
......@@ -623,6 +654,10 @@ public class RepaintManager
* if it return true.
*/
public boolean isCompletelyDirty(JComponent aComponent) {
RepaintManager delegate = getDelegate(aComponent);
if (delegate != null) {
return delegate.isCompletelyDirty(aComponent);
}
Rectangle r;
r = getDirtyRegion(aComponent);
......@@ -900,6 +935,10 @@ public class RepaintManager
* repaint manager.
*/
public Image getOffscreenBuffer(Component c,int proposedWidth,int proposedHeight) {
RepaintManager delegate = getDelegate(c);
if (delegate != null) {
return delegate.getOffscreenBuffer(c, proposedWidth, proposedHeight);
}
return _getOffscreenBuffer(c, proposedWidth, proposedHeight);
}
......@@ -917,6 +956,11 @@ public class RepaintManager
*/
public Image getVolatileOffscreenBuffer(Component c,
int proposedWidth,int proposedHeight) {
RepaintManager delegate = getDelegate(c);
if (delegate != null) {
return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
proposedHeight);
}
GraphicsConfiguration config = c.getGraphicsConfiguration();
if (config == null) {
config = GraphicsEnvironment.getLocalGraphicsEnvironment().
......@@ -1550,4 +1594,11 @@ public class RepaintManager
prePaintDirtyRegions();
}
}
private RepaintManager getDelegate(Component c) {
RepaintManager delegate = SwingUtilities3.getDelegateRepaintManager(c);
if (this == delegate) {
delegate = null;
}
return delegate;
}
}
/*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2008 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
......@@ -974,6 +974,7 @@ public class SwingUtilities implements SwingConstants
boolean textIsEmpty = (text == null) || text.equals("");
int lsb = 0;
int rsb = 0;
/* Unless both text and icon are non-null, we effectively ignore
* the value of textIconGap.
*/
......@@ -1015,7 +1016,7 @@ public class SwingUtilities implements SwingConstants
if (lsb < 0) {
textR.width -= lsb;
}
int rsb = SwingUtilities2.getRightSideBearing(c, fm, text);
rsb = SwingUtilities2.getRightSideBearing(c, fm, text);
if (rsb > 0) {
textR.width += rsb;
}
......@@ -1118,6 +1119,11 @@ public class SwingUtilities implements SwingConstants
// lsb is negative. Shift the x location so that the text is
// visually drawn at the right location.
textR.x -= lsb;
textR.width += lsb;
}
if (rsb > 0) {
textR.width -= rsb;
}
return text;
......
......@@ -31,6 +31,7 @@ package javax.swing;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import java.util.concurrent.atomic.AtomicLong;
import sun.awt.AppContext;
......@@ -52,7 +53,8 @@ class TimerQueue implements Runnable
new StringBuffer("TimerQueue.expiredTimersKey");
private final DelayQueue<DelayedTimer> queue;
volatile boolean running;
private volatile boolean running;
private final Lock runningLock;
/* Lock object used in place of class object for synchronization.
* (4187686)
......@@ -69,7 +71,8 @@ class TimerQueue implements Runnable
super();
queue = new DelayQueue<DelayedTimer>();
// Now start the TimerQueue thread.
start();
runningLock = new ReentrantLock();
startIfNeeded();
}
......@@ -87,33 +90,30 @@ class TimerQueue implements Runnable
}
synchronized void start() {
if (running) {
throw new RuntimeException("Can't start a TimerQueue " +
"that is already running");
}
else {
final ThreadGroup threadGroup =
AppContext.getAppContext().getThreadGroup();
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
Thread timerThread = new Thread(threadGroup, TimerQueue.this,
"TimerQueue");
timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start();
return null;
}
});
running = true;
void startIfNeeded() {
if (! running) {
runningLock.lock();
try {
final ThreadGroup threadGroup =
AppContext.getAppContext().getThreadGroup();
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
Thread timerThread = new Thread(threadGroup, TimerQueue.this,
"TimerQueue");
timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start();
return null;
}
});
running = true;
} finally {
runningLock.unlock();
}
}
}
synchronized void stop() {
running = false;
}
void addTimer(Timer timer, long delayMillis) {
timer.getLock().lock();
try {
......@@ -164,6 +164,7 @@ class TimerQueue implements Runnable
public void run() {
runningLock.lock();
try {
while (running) {
try {
......@@ -195,14 +196,14 @@ class TimerQueue implements Runnable
}
}
catch (ThreadDeath td) {
synchronized (this) {
running = false;
// Mark all the timers we contain as not being queued.
for (DelayedTimer delayedTimer : queue) {
delayedTimer.getTimer().cancelEvent();
}
throw td;
// Mark all the timers we contain as not being queued.
for (DelayedTimer delayedTimer : queue) {
delayedTimer.getTimer().cancelEvent();
}
throw td;
} finally {
running = false;
runningLock.unlock();
}
}
......
......@@ -79,10 +79,13 @@ public class CompoundBorder extends AbstractBorder {
}
/**
* Returns whether or not this compound border is opaque.
* Returns true if both the inside and outside borders are
* non-null and opaque; returns false otherwise.
* Returns whether or not the compound border is opaque.
*
* @return {@code true} if the inside and outside borders
* are each either {@code null} or opaque;
* or {@code false} otherwise
*/
@Override
public boolean isBorderOpaque() {
return (outsideBorder == null || outsideBorder.isBorderOpaque()) &&
(insideBorder == null || insideBorder.isBorderOpaque());
......
......@@ -160,7 +160,9 @@ public abstract class AbstractColorChooserPanel extends JPanel {
* is editing
*/
public ColorSelectionModel getColorSelectionModel() {
return chooser.getSelectionModel();
return (this.chooser != null)
? this.chooser.getSelectionModel()
: null;
}
/**
......@@ -168,7 +170,17 @@ public abstract class AbstractColorChooserPanel extends JPanel {
* @return the <code>Color</code> that is selected
*/
protected Color getColorFromModel() {
return getColorSelectionModel().getSelectedColor();
ColorSelectionModel model = getColorSelectionModel();
return (model != null)
? model.getSelectedColor()
: null;
}
void setSelectedColor(Color color) {
ColorSelectionModel model = getColorSelectionModel();
if (model != null) {
model.setSelectedColor(color);
}
}
/**
......
/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2008 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
......@@ -25,9 +25,7 @@
package javax.swing.colorchooser;
import javax.swing.*;
import javax.swing.JComponent;
/**
* A class designed to produce preconfigured "accessory" objects to
......@@ -49,16 +47,17 @@ public class ColorChooserComponentFactory {
private ColorChooserComponentFactory() { } // can't instantiate
public static AbstractColorChooserPanel[] getDefaultChooserPanels() {
AbstractColorChooserPanel[] choosers = { new DefaultSwatchChooserPanel(),
new DefaultHSBChooserPanel(),
new DefaultRGBChooserPanel() };
return choosers;
return new AbstractColorChooserPanel[] {
new DefaultSwatchChooserPanel(),
new ColorChooserPanel(new ColorModelHSV()),
new ColorChooserPanel(new ColorModelHSL()),
new ColorChooserPanel(new ColorModel()),
new ColorChooserPanel(new ColorModelCMYK()),
};
}
public static JComponent getPreviewPanel() {
return new DefaultPreviewPanel();
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
final class ColorChooserPanel extends AbstractColorChooserPanel implements PropertyChangeListener {
private static final int MASK = 0xFF000000;
private final ColorModel model;
private final ColorPanel panel;
private final DiagramComponent slider;
private final DiagramComponent diagram;
private final JFormattedTextField text;
private final JLabel label;
ColorChooserPanel(ColorModel model) {
this.model = model;
this.panel = new ColorPanel(this.model);
this.slider = new DiagramComponent(this.panel, false);
this.diagram = new DiagramComponent(this.panel, true);
this.text = new JFormattedTextField();
this.label = new JLabel(null, null, SwingConstants.RIGHT);
ValueFormatter.init(6, true, this.text);
}
@Override
public void updateChooser() {
Color color = getColorFromModel();
if (color != null) {
this.panel.setColor(color);
this.text.setValue(Integer.valueOf(color.getRGB()));
this.slider.repaint();
this.diagram.repaint();
}
}
@Override
protected void buildChooser() {
if (0 == getComponentCount()) {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridwidth = 2;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets.top = 10;
gbc.insets.right = 10;
add(this.panel, gbc);
gbc.gridwidth = 1;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets.right = 5;
gbc.insets.bottom = 10;
add(this.label, gbc);
gbc.gridx = 4;
gbc.weightx = 0.0;
gbc.insets.right = 10;
add(this.text, gbc);
gbc.gridx = 2;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTH;
gbc.ipadx = this.text.getPreferredSize().height;
gbc.ipady = getPreferredSize().height;
add(this.slider, gbc);
gbc.gridx = 1;
gbc.insets.left = 10;
gbc.ipadx = gbc.ipady;
add(this.diagram, gbc);
this.label.setLabelFor(this.text);
this.text.addPropertyChangeListener("value", this); // NON-NLS: the property name
this.slider.setBorder(this.text.getBorder());
this.diagram.setBorder(this.text.getBorder());
setInheritsPopupMenu(this, true); // CR:4966112
}
String label = this.model.getText(this, "HexCode"); // NON-NLS: suffix
boolean visible = label != null;
this.text.setVisible(visible);
this.label.setVisible(visible);
if (visible) {
this.label.setText(label);
int mnemonic = this.model.getInteger(this, "HexCodeMnemonic"); // NON-NLS: suffix
if (mnemonic > 0) {
this.label.setDisplayedMnemonic(mnemonic);
mnemonic = this.model.getInteger(this, "HexCodeMnemonicIndex"); // NON-NLS: suffix
if (mnemonic >= 0) {
this.label.setDisplayedMnemonicIndex(mnemonic);
}
}
}
this.panel.buildPanel();
}
@Override
public String getDisplayName() {
return this.model.getText(this, "Name"); // NON-NLS: suffix
}
@Override
public int getMnemonic() {
return this.model.getInteger(this, "Mnemonic"); // NON-NLS: suffix
}
@Override
public int getDisplayedMnemonicIndex() {
return this.model.getInteger(this, "DisplayedMnemonicIndex"); // NON-NLS: suffix
}
@Override
public Icon getSmallDisplayIcon() {
return null;
}
@Override
public Icon getLargeDisplayIcon() {
return null;
}
public void propertyChange(PropertyChangeEvent event) {
ColorSelectionModel model = getColorSelectionModel();
if (model != null) {
Object object = event.getNewValue();
if (object instanceof Integer) {
int value = MASK & model.getSelectedColor().getRGB() | (Integer) object;
model.setSelectedColor(new Color(value, true));
}
}
this.text.selectAll();
}
/**
* Allows to show context popup for all components recursively.
*
* @param component the root component of the tree
* @param value whether or not the popup menu is inherited
*/
private static void setInheritsPopupMenu(JComponent component, boolean value) {
component.setInheritsPopupMenu(value);
for (Object object : component.getComponents()) {
if (object instanceof JComponent) {
setInheritsPopupMenu((JComponent) object, value);
}
}
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
import java.awt.Component;
import javax.swing.UIManager;
class ColorModel {
private final String prefix;
private final String[] labels;
ColorModel(String name, String... labels) {
this.prefix = "ColorChooser." + name; // NON-NLS: default prefix
this.labels = labels;
}
ColorModel() {
this("rgb", "Red", "Green", "Blue", "Alpha"); // NON-NLS: components
}
void setColor(int color, float[] model) {
model[0] = normalize(color >> 16);
model[1] = normalize(color >> 8);
model[2] = normalize(color);
model[3] = normalize(color >> 24);
}
int getColor(float[] model) {
return to8bit(model[2]) | (to8bit(model[1]) << 8) | (to8bit(model[0]) << 16) | (to8bit(model[3]) << 24);
}
int getCount() {
return this.labels.length;
}
int getMinimum(int index) {
return 0;
}
int getMaximum(int index) {
return 255;
}
float getDefault(int index) {
return 0.0f;
}
final String getLabel(Component component, int index) {
return getText(component, this.labels[index]);
}
private static float normalize(int value) {
return (float) (value & 0xFF) / 255.0f;
}
private static int to8bit(float value) {
return (int) (255.0f * value);
}
final String getText(Component component, String suffix) {
return UIManager.getString(this.prefix + suffix + "Text", component.getLocale()); // NON-NLS: default postfix
}
final int getInteger(Component component, String suffix) {
Object value = UIManager.get(this.prefix + suffix, component.getLocale());
if (value instanceof Integer) {
return (Integer) value;
}
if (value instanceof String) {
try {
return Integer.parseInt((String) value);
}
catch (NumberFormatException exception) {
}
}
return -1;
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
final class ColorModelCMYK extends ColorModel {
ColorModelCMYK() {
super("cmyk", "Cyan", "Magenta", "Yellow", "Black", "Alpha"); // NON-NLS: components
}
@Override
void setColor(int color, float[] space) {
super.setColor(color, space);
space[4] = space[3];
RGBtoCMYK(space, space);
}
@Override
int getColor(float[] space) {
CMYKtoRGB(space, space);
space[3] = space[4];
return super.getColor(space);
}
/**
* Converts CMYK components of a color to a set of RGB components.
*
* @param cmyk a float array with length equal to
* the number of CMYK components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private static float[] CMYKtoRGB(float[] cmyk, float[] rgb) {
if (rgb == null) {
rgb = new float[3];
}
rgb[0] = 1.0f + cmyk[0] * cmyk[3] - cmyk[3] - cmyk[0];
rgb[1] = 1.0f + cmyk[1] * cmyk[3] - cmyk[3] - cmyk[1];
rgb[2] = 1.0f + cmyk[2] * cmyk[3] - cmyk[3] - cmyk[2];
return rgb;
}
/**
* Converts RGB components of a color to a set of CMYK components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param cmyk a float array with length equal to
* the number of CMYK components
* @return a float array that contains CMYK components
*/
private static float[] RGBtoCMYK(float[] rgb, float[] cmyk) {
if (cmyk == null) {
cmyk = new float[4];
}
float max = ColorModelHSL.max(rgb[0], rgb[1], rgb[2]);
if (max > 0.0f) {
cmyk[0] = 1.0f - rgb[0] / max;
cmyk[1] = 1.0f - rgb[1] / max;
cmyk[2] = 1.0f - rgb[2] / max;
}
else {
cmyk[0] = 0.0f;
cmyk[1] = 0.0f;
cmyk[2] = 0.0f;
}
cmyk[3] = 1.0f - max;
return cmyk;
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
final class ColorModelHSL extends ColorModel {
ColorModelHSL() {
super("hsl", "Hue", "Saturation", "Lightness", "Transparency"); // NON-NLS: components
}
@Override
void setColor(int color, float[] space) {
super.setColor(color, space);
RGBtoHSL(space, space);
space[3] = 1.0f - space[3];
}
@Override
int getColor(float[] space) {
space[3] = 1.0f - space[3];
HSLtoRGB(space, space);
return super.getColor(space);
}
@Override
int getMaximum(int index) {
return (index == 0) ? 360 : 100;
}
@Override
float getDefault(int index) {
return (index == 0) ? -1.0f : (index == 2) ? 0.5f : 1.0f;
}
/**
* Converts HSL components of a color to a set of RGB components.
*
* @param hsl a float array with length equal to
* the number of HSL components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private static float[] HSLtoRGB(float[] hsl, float[] rgb) {
if (rgb == null) {
rgb = new float[3];
}
float hue = hsl[0];
float saturation = hsl[1];
float lightness = hsl[2];
if (saturation > 0.0f) {
hue = (hue < 1.0f) ? hue * 6.0f : 0.0f;
float q = lightness + saturation * ((lightness > 0.5f) ? 1.0f - lightness : lightness);
float p = 2.0f * lightness - q;
rgb[0]= normalize(q, p, (hue < 4.0f) ? (hue + 2.0f) : (hue - 4.0f));
rgb[1]= normalize(q, p, hue);
rgb[2]= normalize(q, p, (hue < 2.0f) ? (hue + 4.0f) : (hue - 2.0f));
}
else {
rgb[0] = lightness;
rgb[1] = lightness;
rgb[2] = lightness;
}
return rgb;
}
/**
* Converts RGB components of a color to a set of HSL components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param hsl a float array with length equal to
* the number of HSL components
* @return a float array that contains HSL components
*/
private static float[] RGBtoHSL(float[] rgb, float[] hsl) {
if (hsl == null) {
hsl = new float[3];
}
float max = max(rgb[0], rgb[1], rgb[2]);
float min = min(rgb[0], rgb[1], rgb[2]);
float summa = max + min;
float saturation = max - min;
if (saturation > 0.0f) {
saturation /= (summa > 1.0f)
? 2.0f - summa
: summa;
}
hsl[0] = getHue(rgb[0], rgb[1], rgb[2], max, min);
hsl[1] = saturation;
hsl[2] = summa / 2.0f;
return hsl;
}
/**
* Returns the smaller of three color components.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @return the smaller of {@code red}, {@code green} and {@code blue}
*/
static float min(float red, float green, float blue) {
float min = (red < green) ? red : green;
return (min < blue) ? min : blue;
}
/**
* Returns the larger of three color components.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @return the larger of {@code red}, {@code green} and {@code blue}
*/
static float max(float red, float green, float blue) {
float max = (red > green) ? red : green;
return (max > blue) ? max : blue;
}
/**
* Calculates the hue component for HSL and HSV color spaces.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @param max the larger of {@code red}, {@code green} and {@code blue}
* @param min the smaller of {@code red}, {@code green} and {@code blue}
* @return the hue component
*/
static float getHue(float red, float green, float blue, float max, float min) {
float hue = max - min;
if (hue > 0.0f) {
if (max == red) {
hue = (green - blue) / hue;
if (hue < 0.0f) {
hue += 6.0f;
}
}
else if (max == green) {
hue = 2.0f + (blue - red) / hue;
}
else /*max == blue*/ {
hue = 4.0f + (red - green) / hue;
}
hue /= 6.0f;
}
return hue;
}
private static float normalize(float q, float p, float color) {
if (color < 1.0f) {
return p + (q - p) * color;
}
if (color < 3.0f) {
return q;
}
if (color < 4.0f) {
return p + (q - p) * (4.0f - color);
}
return p;
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
final class ColorModelHSV extends ColorModel {
ColorModelHSV() {
super("hsv", "Hue", "Saturation", "Value", "Transparency"); // NON-NLS: components
}
@Override
void setColor(int color, float[] space) {
super.setColor(color, space);
RGBtoHSV(space, space);
space[3] = 1.0f - space[3];
}
@Override
int getColor(float[] space) {
space[3] = 1.0f - space[3];
HSVtoRGB(space, space);
return super.getColor(space);
}
@Override
int getMaximum(int index) {
return (index == 0) ? 360 : 100;
}
@Override
float getDefault(int index) {
return (index == 0) ? -1.0f : 1.0f;
}
/**
* Converts HSV components of a color to a set of RGB components.
*
* @param hsv a float array with length equal to
* the number of HSV components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private static float[] HSVtoRGB(float[] hsv, float[] rgb) {
if (rgb == null) {
rgb = new float[3];
}
float hue = hsv[0];
float saturation = hsv[1];
float value = hsv[2];
rgb[0] = value;
rgb[1] = value;
rgb[2] = value;
if (saturation > 0.0f) {
hue = (hue < 1.0f) ? hue * 6.0f : 0.0f;
int integer = (int) hue;
float f = hue - (float) integer;
switch (integer) {
case 0:
rgb[1] *= 1.0f - saturation * (1.0f - f);
rgb[2] *= 1.0f - saturation;
break;
case 1:
rgb[0] *= 1.0f - saturation * f;
rgb[2] *= 1.0f - saturation;
break;
case 2:
rgb[0] *= 1.0f - saturation;
rgb[2] *= 1.0f - saturation * (1.0f - f);
break;
case 3:
rgb[0] *= 1.0f - saturation;
rgb[1] *= 1.0f - saturation * f;
break;
case 4:
rgb[0] *= 1.0f - saturation * (1.0f - f);
rgb[1] *= 1.0f - saturation;
break;
case 5:
rgb[1] *= 1.0f - saturation;
rgb[2] *= 1.0f - saturation * f;
break;
}
}
return rgb;
}
/**
* Converts RGB components of a color to a set of HSV components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param hsv a float array with length equal to
* the number of HSV components
* @return a float array that contains HSV components
*/
private static float[] RGBtoHSV(float[] rgb, float[] hsv) {
if (hsv == null) {
hsv = new float[3];
}
float max = ColorModelHSL.max(rgb[0], rgb[1], rgb[2]);
float min = ColorModelHSL.min(rgb[0], rgb[1], rgb[2]);
float saturation = max - min;
if (saturation > 0.0f) {
saturation /= max;
}
hsv[0] = ColorModelHSL.getHue(rgb[0], rgb[1], rgb[2], max, min);
hsv[1] = saturation;
hsv[2] = max;
return hsv;
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
import java.awt.Color;
import java.awt.ContainerOrderFocusTraversalPolicy;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
final class ColorPanel extends JPanel implements ActionListener {
private final SlidingSpinner[] spinners = new SlidingSpinner[5];
private final float[] values = new float[this.spinners.length];
private final ColorModel model;
private Color color;
private int x = 1;
private int y = 2;
private int z;
ColorPanel(ColorModel model) {
super(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 1;
ButtonGroup group = new ButtonGroup();
EmptyBorder border = null;
for (int i = 0; i < this.spinners.length; i++) {
if (i < 3) {
JRadioButton button = new JRadioButton();
if (i == 0) {
Insets insets = button.getInsets();
insets.left = button.getPreferredSize().width;
border = new EmptyBorder(insets);
button.setSelected(true);
gbc.insets.top = 5;
}
add(button, gbc);
group.add(button);
button.setActionCommand(Integer.toString(i));
button.addActionListener(this);
this.spinners[i] = new SlidingSpinner(this, button);
}
else {
JLabel label = new JLabel();
add(label, gbc);
label.setBorder(border);
label.setFocusable(false);
this.spinners[i] = new SlidingSpinner(this, label);
}
}
gbc.gridx = 2;
gbc.weightx = 1.0;
gbc.insets.top = 0;
gbc.insets.left = 5;
for (SlidingSpinner spinner : this.spinners) {
add(spinner.getSlider(), gbc);
gbc.insets.top = 5;
}
gbc.gridx = 3;
gbc.weightx = 0.0;
gbc.insets.top = 0;
for (SlidingSpinner spinner : this.spinners) {
add(spinner.getSpinner(), gbc);
gbc.insets.top = 5;
}
setFocusTraversalPolicy(new ContainerOrderFocusTraversalPolicy());
setFocusTraversalPolicyProvider(true);
setFocusable(false);
this.model = model;
}
public void actionPerformed(ActionEvent event) {
try {
this.z = Integer.parseInt(event.getActionCommand());
this.y = (this.z != 2) ? 2 : 1;
this.x = (this.z != 0) ? 0 : 1;
getParent().repaint();
}
catch (NumberFormatException exception) {
}
}
void buildPanel() {
int count = this.model.getCount();
this.spinners[4].setVisible(count > 4);
for (int i = 0; i < count; i++) {
Object object = this.spinners[i].getLabel();
if (object instanceof JRadioButton) {
JRadioButton button = (JRadioButton) object;
button.setText(this.model.getLabel(this, i));
}
else if (object instanceof JLabel) {
JLabel label = (JLabel) object;
label.setText(this.model.getLabel(this, i));
}
this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
this.spinners[i].setValue(this.values[i]);
}
}
void colorChanged() {
this.color = new Color(getColor(0), true);
Object parent = getParent();
if (parent instanceof ColorChooserPanel) {
ColorChooserPanel chooser = (ColorChooserPanel) parent;
chooser.setSelectedColor(this.color);
chooser.repaint();
}
}
float getValueX() {
return this.spinners[this.x].getValue();
}
float getValueY() {
return 1.0f - this.spinners[this.y].getValue();
}
float getValueZ() {
return 1.0f - this.spinners[this.z].getValue();
}
void setValue(float z) {
this.spinners[this.z].setValue(1.0f - z);
colorChanged();
}
void setValue(float x, float y) {
this.spinners[this.x].setValue(x);
this.spinners[this.y].setValue(1.0f - y);
colorChanged();
}
int getColor(float z) {
setDefaultValue(this.x);
setDefaultValue(this.y);
this.values[this.z] = 1.0f - z;
return getColor(3);
}
int getColor(float x, float y) {
this.values[this.x] = x;
this.values[this.y] = 1.0f - y;
setValue(this.z);
return getColor(3);
}
void setColor(Color color) {
if (!color.equals(this.color)) {
this.color = color;
this.model.setColor(color.getRGB(), this.values);
for (int i = 0; i < this.model.getCount(); i++) {
this.spinners[i].setValue(this.values[i]);
}
}
}
private int getColor(int index) {
while (index < this.model.getCount()) {
setValue(index++);
}
return this.model.getColor(this.values);
}
private void setValue(int index) {
this.values[index] = this.spinners[index].getValue();
}
private void setDefaultValue(int index) {
float value = this.model.getDefault(index);
this.values[index] = (value < 0.0f)
? this.spinners[index].getValue()
: value;
}
}
/*
* Copyright 1998-2004 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. 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.
*/
package javax.swing.colorchooser;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.util.Locale;
/**
* The standard RGB chooser.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Steve Wilson
* @author Mark Davidson
* @see JColorChooser
* @see AbstractColorChooserPanel
*/
class DefaultRGBChooserPanel extends AbstractColorChooserPanel implements ChangeListener {
protected JSlider redSlider;
protected JSlider greenSlider;
protected JSlider blueSlider;
protected JSpinner redField;
protected JSpinner blueField;
protected JSpinner greenField;
private final int minValue = 0;
private final int maxValue = 255;
private boolean isAdjusting = false; // indicates the fields are being set internally
public DefaultRGBChooserPanel() {
super();
setInheritsPopupMenu(true);
}
/**
* Sets the values of the controls to reflect the color
*/
private void setColor( Color newColor ) {
int red = newColor.getRed();
int blue = newColor.getBlue();
int green = newColor.getGreen();
if (redSlider.getValue() != red) {
redSlider.setValue(red);
}
if (greenSlider.getValue() != green) {
greenSlider.setValue(green);
}
if (blueSlider.getValue() != blue) {
blueSlider.setValue(blue);
}
if (((Integer)redField.getValue()).intValue() != red)
redField.setValue(new Integer(red));
if (((Integer)greenField.getValue()).intValue() != green)
greenField.setValue(new Integer(green));
if (((Integer)blueField.getValue()).intValue() != blue )
blueField.setValue(new Integer(blue));
}
public String getDisplayName() {
return UIManager.getString("ColorChooser.rgbNameText", getLocale());
}
/**
* Provides a hint to the look and feel as to the
* <code>KeyEvent.VK</code> constant that can be used as a mnemonic to
* access the panel. A return value <= 0 indicates there is no mnemonic.
* <p>
* The return value here is a hint, it is ultimately up to the look
* and feel to honor the return value in some meaningful way.
* <p>
* This implementation looks up the value from the default
* <code>ColorChooser.rgbMnemonic</code>, or if it
* isn't available (or not an <code>Integer</code>) returns -1.
* The lookup for the default is done through the <code>UIManager</code>:
* <code>UIManager.get("ColorChooser.rgbMnemonic");</code>.
*
* @return KeyEvent.VK constant identifying the mnemonic; <= 0 for no
* mnemonic
* @see #getDisplayedMnemonicIndex
* @since 1.4
*/
public int getMnemonic() {
return getInt("ColorChooser.rgbMnemonic", -1);
}
/**
* Provides a hint to the look and feel as to the index of the character in
* <code>getDisplayName</code> that should be visually identified as the
* mnemonic. The look and feel should only use this if
* <code>getMnemonic</code> returns a value > 0.
* <p>
* The return value here is a hint, it is ultimately up to the look
* and feel to honor the return value in some meaningful way. For example,
* a look and feel may wish to render each
* <code>AbstractColorChooserPanel</code> in a <code>JTabbedPane</code>,
* and further use this return value to underline a character in
* the <code>getDisplayName</code>.
* <p>
* This implementation looks up the value from the default
* <code>ColorChooser.rgbDisplayedMnemonicIndex</code>, or if it
* isn't available (or not an <code>Integer</code>) returns -1.
* The lookup for the default is done through the <code>UIManager</code>:
* <code>UIManager.get("ColorChooser.rgbDisplayedMnemonicIndex");</code>.
*
* @return Character index to render mnemonic for; -1 to provide no
* visual identifier for this panel.
* @see #getMnemonic
* @since 1.4
*/
public int getDisplayedMnemonicIndex() {
return getInt("ColorChooser.rgbDisplayedMnemonicIndex", -1);
}
public Icon getSmallDisplayIcon() {
return null;
}
public Icon getLargeDisplayIcon() {
return null;
}
/**
* The background color, foreground color, and font are already set to the
* defaults from the defaults table before this method is called.
*/
public void installChooserPanel(JColorChooser enclosingChooser) {
super.installChooserPanel(enclosingChooser);
}
protected void buildChooser() {
Locale locale = getLocale();
String redString = UIManager.getString("ColorChooser.rgbRedText", locale);
String greenString = UIManager.getString("ColorChooser.rgbGreenText", locale);
String blueString = UIManager.getString("ColorChooser.rgbBlueText", locale);
setLayout( new BorderLayout() );
Color color = getColorFromModel();
JPanel enclosure = new JPanel();
enclosure.setLayout( new SmartGridLayout( 3, 3 ) );
enclosure.setInheritsPopupMenu(true);
// The panel that holds the sliders
add( enclosure, BorderLayout.CENTER );
// sliderPanel.setBorder(new LineBorder(Color.black));
// The row for the red value
JLabel l = new JLabel(redString);
l.setDisplayedMnemonic(getInt("ColorChooser.rgbRedMnemonic", -1));
enclosure.add(l);
redSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getRed());
redSlider.setMajorTickSpacing( 85 );
redSlider.setMinorTickSpacing( 17 );
redSlider.setPaintTicks( true );
redSlider.setPaintLabels( true );
redSlider.setInheritsPopupMenu(true);
enclosure.add( redSlider );
redField = new JSpinner(
new SpinnerNumberModel(color.getRed(), minValue, maxValue, 1));
l.setLabelFor(redSlider);
redField.setInheritsPopupMenu(true);
JPanel redFieldHolder = new JPanel(new CenterLayout());
redFieldHolder.setInheritsPopupMenu(true);
redField.addChangeListener(this);
redFieldHolder.add(redField);
enclosure.add(redFieldHolder);
// The row for the green value
l = new JLabel(greenString);
l.setDisplayedMnemonic(getInt("ColorChooser.rgbGreenMnemonic", -1));
enclosure.add(l);
greenSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getGreen());
greenSlider.setMajorTickSpacing( 85 );
greenSlider.setMinorTickSpacing( 17 );
greenSlider.setPaintTicks( true );
greenSlider.setPaintLabels( true );
greenSlider.setInheritsPopupMenu(true);
enclosure.add(greenSlider);
greenField = new JSpinner(
new SpinnerNumberModel(color.getGreen(), minValue, maxValue, 1));
l.setLabelFor(greenSlider);
greenField.setInheritsPopupMenu(true);
JPanel greenFieldHolder = new JPanel(new CenterLayout());
greenFieldHolder.add(greenField);
greenFieldHolder.setInheritsPopupMenu(true);
greenField.addChangeListener(this);
enclosure.add(greenFieldHolder);
// The slider for the blue value
l = new JLabel(blueString);
l.setDisplayedMnemonic(getInt("ColorChooser.rgbBlueMnemonic", -1));
enclosure.add(l);
blueSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getBlue());
blueSlider.setMajorTickSpacing( 85 );
blueSlider.setMinorTickSpacing( 17 );
blueSlider.setPaintTicks( true );
blueSlider.setPaintLabels( true );
blueSlider.setInheritsPopupMenu(true);
enclosure.add(blueSlider);
blueField = new JSpinner(
new SpinnerNumberModel(color.getBlue(), minValue, maxValue, 1));
l.setLabelFor(blueSlider);
blueField.setInheritsPopupMenu(true);
JPanel blueFieldHolder = new JPanel(new CenterLayout());
blueFieldHolder.add(blueField);
blueField.addChangeListener(this);
blueFieldHolder.setInheritsPopupMenu(true);
enclosure.add(blueFieldHolder);
redSlider.addChangeListener( this );
greenSlider.addChangeListener( this );
blueSlider.addChangeListener( this );
redSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
greenSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
blueSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
}
public void uninstallChooserPanel(JColorChooser enclosingChooser) {
super.uninstallChooserPanel(enclosingChooser);
removeAll();
}
public void updateChooser() {
if (!isAdjusting) {
isAdjusting = true;
setColor(getColorFromModel());
isAdjusting = false;
}
}
public void stateChanged( ChangeEvent e ) {
if ( e.getSource() instanceof JSlider && !isAdjusting) {
int red = redSlider.getValue();
int green = greenSlider.getValue();
int blue = blueSlider.getValue() ;
Color color = new Color (red, green, blue);
getColorSelectionModel().setSelectedColor(color);
} else if (e.getSource() instanceof JSpinner && !isAdjusting) {
int red = ((Integer)redField.getValue()).intValue();
int green = ((Integer)greenField.getValue()).intValue();
int blue = ((Integer)blueField.getValue()).intValue();
Color color = new Color (red, green, blue);
getColorSelectionModel().setSelectedColor(color);
}
}
}
/*
* Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2008 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
......@@ -213,17 +213,15 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel {
class RecentSwatchListener extends MouseAdapter implements Serializable {
public void mousePressed(MouseEvent e) {
Color color = recentSwatchPanel.getColorForLocation(e.getX(), e.getY());
getColorSelectionModel().setSelectedColor(color);
setSelectedColor(color);
}
}
class MainSwatchListener extends MouseAdapter implements Serializable {
public void mousePressed(MouseEvent e) {
Color color = swatchPanel.getColorForLocation(e.getX(), e.getY());
getColorSelectionModel().setSelectedColor(color);
setSelectedColor(color);
recentSwatchPanel.setMostRecentColor(color);
}
}
......
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
final class DiagramComponent extends JComponent implements MouseListener, MouseMotionListener {
private final ColorPanel panel;
private final boolean diagram;
private final Insets insets = new Insets(0, 0, 0, 0);
private int width;
private int height;
private int[] array;
private BufferedImage image;
DiagramComponent(ColorPanel panel, boolean diagram) {
this.panel = panel;
this.diagram = diagram;
addMouseListener(this);
addMouseMotionListener(this);
}
@Override
protected void paintComponent(Graphics g) {
getInsets(this.insets);
this.width = getWidth() - this.insets.left - this.insets.right;
this.height = getHeight() - this.insets.top - this.insets.bottom;
boolean update = (this.image == null)
|| (this.width != this.image.getWidth())
|| (this.height != this.image.getHeight());
if (update) {
int size = this.width * this.height;
if ((this.array == null) || (this.array.length < size)) {
this.array = new int[size];
}
this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
}
{
float dx = 1.0f / (float) (this.width - 1);
float dy = 1.0f / (float) (this.height - 1);
int offset = 0;
float y = 0.0f;
for (int h = 0; h < this.height; h++, y += dy) {
if (this.diagram) {
float x = 0.0f;
for (int w = 0; w < this.width; w++, x += dx, offset++) {
this.array[offset] = this.panel.getColor(x, y);
}
}
else {
int color = this.panel.getColor(y);
for (int w = 0; w < this.width; w++, offset++) {
this.array[offset] = color;
}
}
}
}
this.image.setRGB(0, 0, this.width, this.height, this.array, 0, this.width);
g.drawImage(this.image, this.insets.left, this.insets.top, this.width, this.height, this);
if (isEnabled()) {
this.width--;
this.height--;
g.setXORMode(Color.WHITE);
g.setColor(Color.BLACK);
if (this.diagram) {
int x = getValue(this.panel.getValueX(), this.insets.left, this.width);
int y = getValue(this.panel.getValueY(), this.insets.top, this.height);
g.drawLine(x - 8, y, x + 8, y);
g.drawLine(x, y - 8, x, y + 8);
}
else {
int z = getValue(this.panel.getValueZ(), this.insets.top, this.height);
g.drawLine(this.insets.left, z, this.insets.left + this.width, z);
}
g.setPaintMode();
}
}
public void mousePressed(MouseEvent event) {
mouseDragged(event);
}
public void mouseReleased(MouseEvent event) {
}
public void mouseClicked(MouseEvent event) {
}
public void mouseEntered(MouseEvent event) {
}
public void mouseExited(MouseEvent event) {
}
public void mouseMoved(MouseEvent event) {
}
public void mouseDragged(MouseEvent event) {
if (isEnabled()) {
float y = getValue(event.getY(), this.insets.top, this.height);
if (this.diagram) {
float x = getValue(event.getX(), this.insets.left, this.width);
this.panel.setValue(x, y);
}
else {
this.panel.setValue(y);
}
}
}
private static int getValue(float value, int min, int max) {
return min + (int) (value * (float) (max));
}
private static float getValue(int value, int min, int max) {
if (min < value) {
value -= min;
return (value < max)
? (float) value / (float) max
: 1.0f;
}
return 0.0f;
}
}
/*
* Copyright 2008 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. 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.
*/
package javax.swing.colorchooser;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.JSpinner;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
final class SlidingSpinner implements ChangeListener {
private final ColorPanel panel;
private final JComponent label;
private final SpinnerNumberModel model = new SpinnerNumberModel();
private final JSlider slider = new JSlider();
private final JSpinner spinner = new JSpinner(this.model);
private float value;
private boolean internal;
SlidingSpinner(ColorPanel panel, JComponent label) {
this.panel = panel;
this.label = label;
this.slider.addChangeListener(this);
this.spinner.addChangeListener(this);
DefaultEditor editor = (DefaultEditor) this.spinner.getEditor();
ValueFormatter.init(3, false, editor.getTextField());
editor.setFocusable(false);
this.spinner.setFocusable(false);
}
JComponent getLabel() {
return this.label;
}
JSlider getSlider() {
return this.slider;
}
JSpinner getSpinner() {
return this.spinner;
}
float getValue() {
return this.value;
}
void setValue(float value) {
int min = this.slider.getMinimum();
int max = this.slider.getMaximum();
this.internal = true;
this.slider.setValue(min + (int) (value * (float) (max - min)));
this.spinner.setValue(Integer.valueOf(this.slider.getValue()));
this.internal = false;
this.value = value;
}
void setRange(int min, int max) {
this.internal = true;
this.slider.setMinimum(min);
this.slider.setMaximum(max);
this.model.setMinimum(Integer.valueOf(min));
this.model.setMaximum(Integer.valueOf(max));
this.internal = false;
}
void setVisible(boolean visible) {
this.label.setVisible(visible);
this.slider.setVisible(visible);
this.spinner.setVisible(visible);
}
public void stateChanged(ChangeEvent event) {
if (!this.internal) {
if (this.spinner == event.getSource()) {
Object value = this.spinner.getValue();
if (value instanceof Integer) {
this.internal = true;
this.slider.setValue((Integer) value);
this.internal = false;
}
}
int value = this.slider.getValue();
this.internal = true;
this.spinner.setValue(Integer.valueOf(value));
this.internal = false;
int min = this.slider.getMinimum();
int max = this.slider.getMaximum();
this.value = (float) (value - min) / (float) (max - min);
this.panel.colorChanged();
}
}
}
......@@ -165,7 +165,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
JRootPane root = b.getRootPane();
if (root != null) {
BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
((AbstractButton)b).getUI(), BasicButtonUI.class);
b.getUI(), BasicButtonUI.class);
if (ui != null && DefaultLookup.getBoolean(b, ui,
ui.getPropertyPrefix() +
"defaultButtonFollowsFocus", true)) {
......@@ -185,7 +185,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton");
if (b != initialDefault) {
BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
((AbstractButton)b).getUI(), BasicButtonUI.class);
b.getUI(), BasicButtonUI.class);
if (ui != null && DefaultLookup.getBoolean(b, ui,
ui.getPropertyPrefix() +
"defaultButtonFollowsFocus", true)) {
......@@ -239,7 +239,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
}
}
}
};
}
public void mouseReleased(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
......@@ -253,7 +253,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
model.setPressed(false);
model.setArmed(false);
}
};
}
public void mouseEntered(MouseEvent e) {
AbstractButton b = (AbstractButton) e.getSource();
......@@ -263,7 +263,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
}
if (model.isPressed())
model.setArmed(true);
};
}
public void mouseExited(MouseEvent e) {
AbstractButton b = (AbstractButton) e.getSource();
......@@ -272,7 +272,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
model.setRollover(false);
}
model.setArmed(false);
};
}
/**
......
......@@ -237,7 +237,7 @@ public class BasicButtonUI extends ButtonUI{
/* the fallback icon should be based on the selected state */
if (model.isSelected()) {
selectedIcon = (Icon) b.getSelectedIcon();
selectedIcon = b.getSelectedIcon();
if (selectedIcon != null) {
icon = selectedIcon;
}
......@@ -245,31 +245,31 @@ public class BasicButtonUI extends ButtonUI{
if(!model.isEnabled()) {
if(model.isSelected()) {
tmpIcon = (Icon) b.getDisabledSelectedIcon();
tmpIcon = b.getDisabledSelectedIcon();
if (tmpIcon == null) {
tmpIcon = selectedIcon;
}
}
if (tmpIcon == null) {
tmpIcon = (Icon) b.getDisabledIcon();
tmpIcon = b.getDisabledIcon();
}
} else if(model.isPressed() && model.isArmed()) {
tmpIcon = (Icon) b.getPressedIcon();
tmpIcon = b.getPressedIcon();
if(tmpIcon != null) {
// revert back to 0 offset
clearTextShiftOffset();
}
} else if(b.isRolloverEnabled() && model.isRollover()) {
if(model.isSelected()) {
tmpIcon = (Icon) b.getRolloverSelectedIcon();
tmpIcon = b.getRolloverSelectedIcon();
if (tmpIcon == null) {
tmpIcon = selectedIcon;
}
}
if (tmpIcon == null) {
tmpIcon = (Icon) b.getRolloverIcon();
tmpIcon = b.getRolloverIcon();
}
}
......@@ -451,9 +451,9 @@ public class BasicButtonUI extends ButtonUI{
MouseMotionListener[] listeners = b.getMouseMotionListeners();
if (listeners != null) {
for (int counter = 0; counter < listeners.length; counter++) {
if (listeners[counter] instanceof BasicButtonListener) {
return (BasicButtonListener)listeners[counter];
for (MouseMotionListener listener : listeners) {
if (listener instanceof BasicButtonListener) {
return (BasicButtonListener) listener;
}
}
}
......
......@@ -299,8 +299,10 @@ public class BasicColorChooserUI extends ColorChooserUI
tabbedPane.addTab(name, centerWrapper);
if (mnemonic > 0) {
tabbedPane.setMnemonicAt(i, mnemonic);
tabbedPane.setDisplayedMnemonicIndexAt(
i, newPanels[i].getDisplayedMnemonicIndex());
int index = newPanels[i].getDisplayedMnemonicIndex();
if (index >= 0) {
tabbedPane.setDisplayedMnemonicIndexAt(i, index);
}
}
}
}
......
......@@ -92,7 +92,7 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener {
return oldValue;
} else {
// Must take the value from the editor and get the value and cast it to the new type.
Class cls = oldValue.getClass();
Class<?> cls = oldValue.getClass();
try {
Method method = cls.getMethod("valueOf", new Class[]{String.class});
newValue = method.invoke(oldValue, new Object[] { editor.getText()});
......
......@@ -142,7 +142,7 @@ class LazyActionMap extends ActionMapUIResource {
Object loader = _loader;
_loader = null;
Class klass = (Class)loader;
Class<?> klass = (Class<?>)loader;
try {
Method method = klass.getDeclaredMethod("loadActionMap",
new Class[] { LazyActionMap.class });
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册