[llvm-commits] [llvm-gcc-4.2] r43913 [51/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/UndoableEditListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/UndoableEditListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/UndoableEditListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/UndoableEditListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,56 @@
+/* UndoableEditListener.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.event;
+
+import java.util.EventListener;
+
+
+/**
+ * UndoableEditListener public interface
+ * @author Andrew Selkirk
+ * @author Ronald Veldema
+ */
+public interface UndoableEditListener extends EventListener
+{
+ /**
+ * Undoable edit has happened
+ *
+ * @param event Undoable Edit Event
+ */
+ void undoableEditHappened(UndoableEditEvent event);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/event/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.event package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.event</title></head>
+
+<body>
+<p>Provides events and listeners used by components in the
+<code>javax.swing</code> package.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileFilter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileFilter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* FileFilter.java --
+ Copyright (C) 2002, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.filechooser;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+
+/**
+ * The base class for filters that control the visibility of files in the
+ * {@link JFileChooser} component.
+ *
+ * @see JFileChooser#addChoosableFileFilter(FileFilter)
+ *
+ * @author Andrew Selkirk
+ */
+public abstract class FileFilter
+{
+
+ /**
+ * Default constructor.
+ */
+ public FileFilter()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns <code>true</code> if the specified file matches the filter, and
+ * <code>false</code> otherwise.
+ *
+ * @param file the file.
+ *
+ * @return A boolean.
+ */
+ public abstract boolean accept(File file);
+
+ /**
+ * Returns a description of the files that will be selected by the filter
+ * (for example, "Java source files"). This description will usually be
+ * displayed on the {@link JFileChooser} component, often in a combo box that
+ * is used to select the appropriate filter (in cases where more than one
+ * filter is available).
+ *
+ * @return A description of the filter.
+ */
+ public abstract String getDescription();
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileSystemView.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileSystemView.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileSystemView.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileSystemView.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,415 @@
+/* FileSystemView.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.filechooser;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.swing.Icon;
+import javax.swing.JFileChooser;
+
+
+/**
+ * The base class providing a view of the file system for use by the
+ * {@link JFileChooser} component.
+ */
+public abstract class FileSystemView
+{
+ /** The instance returned by {@link #getFileSystemView()}. */
+ private static FileSystemView defaultFileSystemView;
+
+ /**
+ * Creates a new file object with the given name in the specified directory.
+ *
+ * @param dir the directory (<code>null</code> permitted).
+ * @param filename the file name.
+ *
+ * @return A new file object.
+ */
+ public File createFileObject(File dir, String filename)
+ {
+ return new File(dir, filename);
+ }
+
+ /**
+ * Creates a new file object from the specified path.
+ *
+ * @param path the path.
+ *
+ * @return A new file object.
+ */
+ public File createFileObject(String path)
+ {
+ File f = new File(path);
+ if (isFileSystemRoot(f))
+ f = this.createFileSystemRoot(f);
+ return f;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected File createFileSystemRoot(File f)
+ {
+ File[] roots = File.listRoots();
+ if (roots == null)
+ return null;
+ return roots[0];
+ }
+
+ /**
+ * Creates a new folder with a unique name in the specified directory and
+ * returns a {@link File} object representing the new directory.
+ *
+ * @param containingDir the directory to contain the new folder
+ * (<code>null</code> not permitted).
+ *
+ * @return A {@link File} object representing the new directory.
+ *
+ * @throws IOException if an exception occurs while creating the new
+ * directory.
+ */
+ public abstract File createNewFolder(File containingDir)
+ throws IOException;
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ * @param fileName DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getChild(File parent, String fileName)
+ {
+ // FIXME: Handle the case when parent and child are special folders.
+ return new File(parent, fileName);
+ }
+
+ /**
+ * Returns the default directory.
+ *
+ * @return The default directory.
+ */
+ public File getDefaultDirectory()
+ {
+ return getHomeDirectory();
+ }
+
+ /**
+ * Returns an array containing the files in the given directory. The
+ * <code>useFileHiding</code> controls whether or not hidden files are
+ * included in the result.
+ *
+ * @param dir the directory (if <code>null</code>
+ * @param useFileHiding a flag that controls whether or not hidden files are
+ * included in the result (pass in <code>true</code> to
+ * exclude hidden files).
+ *
+ * @return The files in the given directory (possibly <code>null</code>).
+ */
+ public File[] getFiles(File dir, boolean useFileHiding)
+ {
+ if (dir == null || dir.listFiles() == null)
+ return null;
+ File[] files = dir.listFiles();
+ if (! useFileHiding)
+ return files;
+ ArrayList trim = new ArrayList();
+ for (int i = 0; i < files.length; i++)
+ if (! files[i].isHidden())
+ trim.add(files[i]);
+ File[] value = (File[]) trim.toArray(new File[trim.size()]);
+ return value;
+ }
+
+ /**
+ * Returns a default {@link FileSystemView} appropriate for the platform.
+ *
+ * @return A default {@link FileSystemView} appropriate for the platform.
+ */
+ public static FileSystemView getFileSystemView()
+ {
+ if (defaultFileSystemView == null)
+ {
+ if (File.separator.equals("/"))
+ defaultFileSystemView = new UnixFileSystemView();
+ // FIXME: need to implement additional views
+ // else if (File.Separator.equals("\"))
+ // return new Win32FileSystemView();
+ // else
+ // return new GenericFileSystemView();
+ }
+ return defaultFileSystemView;
+ }
+
+ /**
+ * Returns the home directory for the current user.
+ *
+ * @return The home directory for the current user.
+ */
+ public File getHomeDirectory()
+ {
+ return createFileObject(System.getProperty("user.home"));
+ }
+
+ /**
+ * Returns the parent directory for the given file/directory.
+ *
+ * @param f the file/directory.
+ *
+ * @return The parent directory (or <code>null</code> if there is no parent
+ * directory).
+ */
+ public File getParentDirectory(File f)
+ {
+ if (f == null)
+ return null;
+ return f.getParentFile();
+ }
+
+ /**
+ * Returns an array containing the file system roots. On Unix-like platforms,
+ * this array will contain just a single item ("/"), while other platforms
+ * may return multiple roots.
+ * <p>
+ * This method is implemented to return <code>null</code>, subclasses must
+ * override this method.
+ *
+ * @return An array containing the file system roots.
+ */
+ public File[] getRoots()
+ {
+ // subclass
+ return null;
+ }
+
+ /**
+ * Returns the name of a file as it would be displayed by the underlying
+ * system.
+ *
+ * @param f the file.
+ *
+ * @return the name of a file as it would be displayed by the underlying
+ * system
+ *
+ * @specnote The specification suggests that the information here is
+ * fetched from a ShellFolder class. This seems to be a non public
+ * private file handling class. We simply return File.getName()
+ * here and leave special handling to subclasses.
+ */
+ public String getSystemDisplayName(File f)
+ {
+ String name = null;
+ if (f != null)
+ name = f.getName();
+ return name;
+ }
+
+ /**
+ * Returns the icon that would be displayed for the given file by the
+ * underlying system. This implementation returns <code>null</code>,
+ * subclasses must override.
+ *
+ * @param f the file.
+ *
+ * @return <code>null</code>.
+ */
+ public Icon getSystemIcon(File f)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the type description of a file that would be displayed by the
+ * underlying system. This implementation returns <code>null</code>,
+ * subclasses must override.
+ *
+ * @param f the file.
+ *
+ * @return <code>null</code>.
+ */
+ public String getSystemTypeDescription(File f)
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isComputerNode(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if the given directory represents a disk
+ * drive, and <code>false</code> otherwise. This default implementation
+ * always returns <code>false</code>.
+ *
+ * @param dir the directory.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isDrive(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if <code>f</code> is a file or directory, and
+ * <code>false</code> otherwise.
+ *
+ * @param f the file/directory.
+ *
+ * @return <code>true</code> if <code>f</code> is a file or directory, and
+ * <code>false</code> otherwise.
+ */
+ public boolean isFileSystem(File f)
+ {
+ return (f.isFile() || f.isDirectory());
+ }
+
+ /**
+ * Returns <code>true</code> if the given directory is a file system root,
+ * and <code>false</code> otherwise.
+ *
+ * @param dir the directory.
+ *
+ * @return <code>true</code> if the given directory is a file system root,
+ * and <code>false</code> otherwise.
+ */
+ public boolean isFileSystemRoot(File dir)
+ {
+ File[] roots = File.listRoots();
+ if (roots == null || dir == null)
+ return false;
+ String filename = dir.getAbsolutePath();
+ for (int i = 0; i < roots.length; i++)
+ if (roots[i].getAbsolutePath().equals(filename))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if the given directory represents a floppy
+ * drive, and <code>false</code> otherwise. This default implementation
+ * always returns <code>false</code>.
+ *
+ * @param dir the directory.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isFloppyDrive(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if the given file is hidden, and
+ * <code>false</code> otherwise.
+ *
+ * @param f the file.
+ *
+ * @return <code>true</code> if the given file is hidden, and
+ * <code>false</code> otherwise.
+ */
+ public boolean isHiddenFile(File f)
+ {
+ return f.isHidden();
+ }
+
+ /**
+ * Returns <code>true</code> if <code>folder</code> is the parent of
+ * <code>file</code>, and <code>false</code> otherwise.
+ *
+ * @param folder the folder (<code>null</code> not permitted).
+ * @param file the file (<code>null</code> not permitted).
+ *
+ * @return <code>true</code> if <code>folder</code> is the parent of
+ * <code>file</code>, and <code>false</code> otherwise.
+ */
+ public boolean isParent(File folder, File file)
+ {
+ File parent = file.getParentFile();
+ if (parent == null)
+ return false;
+ return folder.equals(parent);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isRoot(File f)
+ {
+ // These are not file system roots.
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if the file is traversable, and
+ * <code>false</code> otherwise. Here, all directories are considered
+ * traversable, and files are considered non-traversable.
+ *
+ * @param f the file or directory (<code>null</code> not permitted).
+ *
+ * @return <code>true</code> if the file is traversable, and
+ * <code>false</code> otherwise.
+ */
+ public Boolean isTraversable(File f)
+ {
+ // Tested. A directory where the user has no permission to rwx is still
+ // traversable. (No files are listed when you traverse the directory)
+ // My best guess is that as long as it's a directory, the file is
+ // traversable.
+ return Boolean.valueOf(f.isDirectory());
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileView.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileView.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileView.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/FileView.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* FileView.java --
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.filechooser;
+
+import java.io.File;
+
+import javax.swing.Icon;
+
+/**
+ * An abstract class that provides presentation information about files and
+ * directories. .
+ *
+ * @author Andrew Selkirk
+ */
+public abstract class FileView
+{
+
+ /**
+ * Creates a new <code>FileView</code> instance.
+ */
+ public FileView()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the name for the specified file. This method always returns
+ * <code>null</code> and should be overridden by subclasses.
+ *
+ * @param file the file.
+ *
+ * @return Always <code>null</code>.
+ */
+ public String getName(File file)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a description for the specified file. This method always returns
+ * <code>null</code> and should be overridden by subclasses.
+ *
+ * @param file the file.
+ *
+ * @return Always <code>null</code>.
+ */
+ public String getDescription(File file)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a description for the type of the specified file. This method
+ * always returns <code>null</code> and should be overridden by subclasses.
+ *
+ * @param file the file.
+ *
+ * @return Always <code>null</code>.
+ */
+ public String getTypeDescription(File file)
+ {
+ return null;
+ }
+
+ /**
+ * Returns an {@link Icon} to represent the specified file. This method
+ * always returns <code>null</code> and should be overridden by subclasses.
+ *
+ * @param file the file.
+ *
+ * @return Always <code>null</code>.
+ */
+ public Icon getIcon(File file)
+ {
+ return null;
+ }
+
+ /**
+ * Returns {@link Boolean#TRUE} if the given directory is traversable, and
+ * {@link Boolean#FALSE} if it is not. This method always returns
+ * <code>null</code> and should be overridden by subclasses.
+ *
+ * @param directory the directory.
+ *
+ * @return Always <code>null</code>.
+ */
+ public Boolean isTraversable(File directory)
+ {
+ return null;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,180 @@
+/* UnixFileSystemView.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.filechooser;
+
+import gnu.classpath.NotImplementedException;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.swing.Icon;
+
+
+/**
+ * A concrete implementation of {@link FileSystemView} that is appropriate for
+ * Unix-like systems.
+ *
+ * @see FileSystemView#getFileSystemView()
+ */
+class UnixFileSystemView extends FileSystemView
+{
+ /** The default name for new folders. */
+ private static final String NEW_FOLDER_NAME = "NewFolder";
+
+ /**
+ * Creates a new folder with a unique name in the specified directory and
+ * returns a {@link File} object representing the new directory. The name
+ * of the new folder is <code>NewFolder</code> or, if a directory or file
+ * with that name already exists, <code>NewFolder.n</code> where
+ * <code>n</code> is the lowest integer greater than zero that results in
+ * a unique directory name.
+ *
+ * @param containingDir the directory to contain the new folder
+ * (<code>null</code> not permitted).
+ *
+ * @return A {@link File} object representing the new directory.
+ *
+ * @throws IOException if an exception occurs while creating the new
+ * directory.
+ */
+ public File createNewFolder(File containingDir) throws IOException
+ {
+ int count = 0;
+ File f = null;
+ String filename = containingDir.getAbsolutePath() + File.separator
+ + NEW_FOLDER_NAME;
+ while (f == null)
+ {
+ String full = filename;
+ if (count > 0)
+ full += "." + (count++);
+ f = new File(full);
+ if (f.isDirectory() || f.isFile())
+ {
+ count++;
+ f = null;
+ }
+ }
+ f.mkdir();
+ return f;
+ }
+
+ /**
+ * Returns an array containing the file system root.
+ *
+ * @return An array containing the file system root.
+ */
+ public File[] getRoots()
+ {
+ return File.listRoots();
+ }
+
+ /**
+ * Returns the name of a file as it would be displayed by the underlying
+ * system.
+ *
+ * @param f the file.
+ *
+ * @return the name of a file as it would be displayed by the underlying
+ * system
+ */
+ public String getSystemDisplayName(File f)
+ {
+ String name = null;
+ if (f != null)
+ {
+ if (isRoot(f))
+ name = f.getAbsolutePath();
+ else
+ {
+ try
+ {
+ String path = f.getCanonicalPath();
+ name = path.substring(path.lastIndexOf(File.separator) + 1);
+ }
+ catch (IOException e)
+ {
+ name = f.getName();
+ }
+ }
+ }
+ return name;
+ }
+
+ /**
+ * Returns the icon that would be displayed for the given file by the
+ * underlying system. This method is NOT YET IMPLEMENTED.
+ *
+ * @param f the file.
+ *
+ * @return <code>null</code>.
+ */
+ public Icon getSystemIcon(File f)
+ throws NotImplementedException
+ {
+ // FIXME: Implement;
+ return null;
+ }
+
+ /**
+ * Returns the description of a file that would be displayed by the
+ * underlying system. This method is NOT YET IMPLEMENTED.
+ *
+ * @param f the file.
+ *
+ * @return <code>null</code>.
+ */
+ public String getSystemTypeDescription(File f)
+ throws NotImplementedException
+ {
+ // FIXME: Implement.
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isRoot(File f)
+ {
+ return isFileSystemRoot(f);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/filechooser/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.event package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.filechooser</title></head>
+
+<body>
+<p>Provides support classes for the {@link javax.swing.JFileChooser}
+component.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing</title></head>
+
+<body>
+<p>Provides a collection of cross-platform user interface
+components.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ActionMapUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ActionMapUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ActionMapUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ActionMapUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* ActionMapUIResource.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+import javax.swing.ActionMap;
+
+
+/**
+ * An <code>ActionMap</code> that implements the {@link UIResource}
+ * interface to indicate that it belongs to a pluggable
+ * LookAndFeel.
+ *
+ * @see javax.swing.ActionMap
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class ActionMapUIResource extends ActionMap implements UIResource
+{
+ /**
+ * Constructs a new ActionMapUIResource.
+ */
+ public ActionMapUIResource()
+ {
+ /* The constructor does nothing. */
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/BorderUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/BorderUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/BorderUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/BorderUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,931 @@
+/* BorderUIResource.java
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.LineBorder;
+import javax.swing.border.MatteBorder;
+import javax.swing.border.TitledBorder;
+
+/**
+ * A wrapper for {@link javax.swing.border.Border} that also
+ * implements the {@link UIResource} marker interface. This is useful
+ * for implementing pluggable look-and-feels: When switching the
+ * current LookAndFeel, only those borders are replaced that are
+ * marked as {@link UIResource}. For this reason, a look-and-feel
+ * should always install borders that implement
+ * <code>UIResource</code>, such as the borders provided by this
+ * class.
+ *
+ * @serial
+ * @serialField delegate Border the <code>Border</code> wrapped
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class BorderUIResource implements Border, UIResource, Serializable
+{
+ /**
+ * Verified using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = -3440553684010079691L;
+
+
+ /**
+ * A shared instance of an {@link EtchedBorderUIResource}, or
+ * <code>null</code> if the {@link #getEtchedBorderUIResource()}
+ * method has not yet been called.
+ */
+ private static Border etchedBorderUIResource;
+
+
+ /**
+ * A shared instance of a {@link BevelBorderUIResource} whose
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#LOWERED}, or <code>null</code> if
+ * the {@link #getLoweredBevelBorderUIResource()} has not yet been
+ * called.
+ */
+ private static Border loweredBevelBorderUIResource;
+
+
+ /**
+ * A shared instance of a {@link BevelBorderUIResource} whose
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}, or <code>null</code> if
+ * the {@link #getRaisedBevelBorderUIResource()} has not yet been
+ * called.
+ */
+ private static Border raisedBevelBorderUIResource;
+
+
+ /**
+ * A shared instance of a {@link LineBorderUIResource} for
+ * a one-pixel thick black line, or <code>null</code> if
+ * the {@link #getBlackLineBorderUIResource()} has not yet been
+ * called.
+ */
+ private static Border blackLineBorderUIResource;
+
+
+ /**
+ * Returns a shared instance of an etched border which also
+ * is marked as an {@link UIResource}.
+ *
+ * @see javax.swing.border.EtchedBorder
+ */
+ public static Border getEtchedBorderUIResource()
+ {
+ /* Swing is not designed to be thread-safe, so there is no
+ * need to synchronize the access to the global variable.
+ */
+ if (etchedBorderUIResource == null)
+ etchedBorderUIResource = new EtchedBorderUIResource();
+ return etchedBorderUIResource;
+ }
+
+
+ /**
+ * Returns a shared instance of {@link BevelBorderUIResource} whose
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#LOWERED}.
+ *
+ * @see javax.swing.border.BevelBorder
+ */
+ public static Border getLoweredBevelBorderUIResource()
+ {
+ /* Swing is not designed to be thread-safe, so there is no
+ * need to synchronize the access to the global variable.
+ */
+ if (loweredBevelBorderUIResource == null)
+ loweredBevelBorderUIResource = new BevelBorderUIResource(
+ BevelBorder.LOWERED);
+ return loweredBevelBorderUIResource;
+ }
+
+
+ /**
+ * Returns a shared instance of {@link BevelBorderUIResource} whose
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}.
+ *
+ * @see javax.swing.border.BevelBorder
+ */
+ public static Border getRaisedBevelBorderUIResource()
+ {
+ /* Swing is not designed to be thread-safe, so there is no
+ * need to synchronize the access to the global variable.
+ */
+ if (raisedBevelBorderUIResource == null)
+ raisedBevelBorderUIResource = new BevelBorderUIResource(
+ BevelBorder.RAISED);
+ return raisedBevelBorderUIResource;
+ }
+
+
+ /**
+ * Returns a shared instance of {@link LineBorderUIResource} for
+ * a black, one-pixel width border.
+ *
+ * @see javax.swing.border.LineBorder
+ */
+ public static Border getBlackLineBorderUIResource()
+ {
+ /* Swing is not designed to be thread-safe, so there is no
+ * need to synchronize the access to the global variable.
+ */
+ if (blackLineBorderUIResource == null)
+ blackLineBorderUIResource = new LineBorderUIResource(Color.black);
+ return blackLineBorderUIResource;
+ }
+
+
+ /**
+ * The wrapped border.
+ */
+ private Border delegate;
+
+
+ /**
+ * Constructs a <code>BorderUIResource</code> for wrapping
+ * a <code>Border</code> object.
+ *
+ * @param delegate the border to be wrapped.
+ */
+ public BorderUIResource(Border delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException();
+
+ this.delegate = delegate;
+ }
+
+
+ /**
+ * Paints the border around an enclosed component by calling
+ * the <code>paintBorder</code> method of the wrapped delegate.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ delegate.paintBorder(c, g, x, y, width, height);
+ }
+
+
+ /**
+ * Measures the width of this border by calling the
+ * <code>getBorderInsets</code> method of the wrapped
+ * delegate.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>, <code>right</code>,
+ * <code>top</code> and <code>bottom</code> fields indicate the
+ * width of the border at the respective edge.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return delegate.getBorderInsets(c);
+ }
+
+
+ /**
+ * Determines whether this border fills every pixel in its area
+ * when painting by calling the <code>isBorderOpaque</code>
+ * method of the wrapped delegate.
+ *
+ * @return <code>true</code> if the border is fully opaque, or
+ * <code>false</code> if some pixels of the background
+ * can shine through the border.
+ */
+ public boolean isBorderOpaque()
+ {
+ return delegate.isBorderOpaque();
+ }
+
+
+ /**
+ * A {@link javax.swing.border.BevelBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class BevelBorderUIResource
+ extends BevelBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = -1275542891108351642L;
+
+ /**
+ * Constructs a BevelBorderUIResource whose colors will be derived
+ * from the background of the enclosed component. The background
+ * color is retrieved each time the border is painted, so a border
+ * constructed by this method will automatically reflect a change
+ * to the component’s background color.
+ *
+ * <p><img src="../border/doc-files/BevelBorder-1.png"
+ * width="500" height="150"
+ * alt="[An illustration showing raised and lowered BevelBorders]" /></p>
+ *
+ * @param bevelType the desired appearance of the border. The value
+ * must be either {@link javax.swing.border.BevelBorder#RAISED}
+ * or {@link javax.swing.border.BevelBorder#LOWERED}.
+ *
+ * @throws IllegalArgumentException if <code>bevelType</code> has
+ * an unsupported value.
+ */
+ public BevelBorderUIResource(int bevelType)
+ {
+ super(bevelType);
+ }
+
+
+ /**
+ * Constructs a BevelBorderUIResource given its appearance type
+ * and two colors for its highlight and shadow.
+ *
+ * <p><img src="../border/doc-files/BevelBorder-2.png" width="500"
+ * height="150" alt="[An illustration showing BevelBorders that were
+ * constructed with this method]" /></p>
+ *
+ * @param bevelType the desired appearance of the border. The value
+ * must be either {@link javax.swing.border.BevelBorder#RAISED}
+ * or {@link javax.swing.border.BevelBorder#LOWERED}.
+ *
+ * @param highlight the color that will be used for the inner side
+ * of the highlighted edges (top and left if if
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}; bottom and right
+ * otherwise). The color for the outer side is a brightened
+ * version of this color.
+ *
+ * @param shadow the color that will be used for the outer side of
+ * the shadowed edges (bottom and right if
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}; top and left
+ * otherwise). The color for the inner side is a brightened
+ * version of this color.
+ *
+ * @throws IllegalArgumentException if <code>bevelType</code> has
+ * an unsupported value.
+ *
+ * @throws NullPointerException if <code>highlight</code> or
+ * <code>shadow</code> is <code>null</code>.
+ */
+ public BevelBorderUIResource(int bevelType,
+ Color highlight,
+ Color shadow)
+ {
+ super(bevelType, highlight, shadow);
+ }
+
+
+ /**
+ * Constructs a BevelBorderUIResource given its appearance type
+ * and all its colors.
+ *
+ * <p><img src="../border/doc-files/BevelBorder-3.png" width="500"
+ * height="150" alt="[An illustration showing BevelBorders that
+ * were constructed with this method]" /></p>
+ *
+ * @param bevelType the desired appearance of the border. The value
+ * must be either {@link javax.swing.border.BevelBorder#RAISED}
+ * or {@link javax.swing.border.BevelBorder#LOWERED}.
+ *
+ * @param highlightOuter the color that will be used for the outer
+ * side of the highlighted edges (top and left if
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}; bottom and right
+ * otherwise).
+ *
+ * @param highlightInner the color that will be used for the inner
+ * side of the highlighted edges.
+ *
+ * @param shadowOuter the color that will be used for the outer
+ * side of the shadowed edges (bottom and right if
+ * <code>bevelType</code> is {@link
+ * javax.swing.border.BevelBorder#RAISED}; top and left
+ * otherwise).
+ *
+ * @param shadowInner the color that will be used for the inner
+ * side of the shadowed edges.
+ *
+ * @throws IllegalArgumentException if <code>bevelType</code> has
+ * an unsupported value.
+ *
+ * @throws NullPointerException if one of the passed colors
+ * is <code>null</code>.
+ */
+ public BevelBorderUIResource(int bevelType,
+ Color highlightOuter,
+ Color highlightInner,
+ Color shadowOuter,
+ Color shadowInner)
+ {
+ super(bevelType,
+ highlightOuter, highlightInner,
+ shadowOuter, shadowInner);
+ }
+ }
+
+
+ /**
+ * A {@link javax.swing.border.CompoundBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class CompoundBorderUIResource
+ extends CompoundBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = 7550017084975167341L;
+
+ /**
+ * Constructs a CompoundBorderUIResource with the specified inside
+ * and outside borders.
+ *
+ * @param outsideBorder the outside border, which is painted to the
+ * outside of both <code>insideBorder</code> and the enclosed
+ * component. It is acceptable to pass <code>null</code>, in
+ * which case no outside border is painted.
+ *
+ * @param insideBorder the inside border, which is painted to
+ * between <code>outsideBorder</code> and the enclosed
+ * component. It is acceptable to pass <code>null</code>, in
+ * which case no inside border is painted.
+ */
+ public CompoundBorderUIResource(Border outsideBorder,
+ Border insideBorder)
+ {
+ super(outsideBorder, insideBorder);
+ }
+ }
+
+
+ /**
+ * An {@link javax.swing.border.EmptyBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * <p><img src="../border/doc-files/EmptyBorder-1.png"
+ * width="290" height="200"
+ * alt="[An illustration of EmptyBorder]" /></p>
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class EmptyBorderUIResource
+ extends EmptyBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = -4914187529340071708L;
+
+ /**
+ * Constructs an empty border given the number of pixels required
+ * on each side.
+ *
+ * @param top the number of pixels that the border will need
+ * for its top edge.
+ *
+ * @param left the number of pixels that the border will need
+ * for its left edge.
+ *
+ * @param bottom the number of pixels that the border will need
+ * for its bottom edge.
+ *
+ * @param right the number of pixels that the border will need
+ * for its right edge.
+ */
+ public EmptyBorderUIResource(int top, int left, int bottom, int right)
+ {
+ super(top, left, bottom, right);
+ }
+
+
+ /**
+ * Constructs an empty border given the number of pixels required
+ * on each side, passed in an Insets object.
+ *
+ * @param insets the Insets for the new border.
+ */
+ public EmptyBorderUIResource(Insets insets)
+ {
+ super(insets);
+ }
+ }
+
+
+ /**
+ * An {@link javax.swing.border.EtchedBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * <p><img src="../border/doc-files/EtchedBorder-1.png" width="500"
+ * height="200" alt="[An illustration of the two EtchedBorder
+ * variants]" /></p>
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class EtchedBorderUIResource
+ extends EtchedBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = -8186391754165296656L;
+
+ /**
+ * Constructs an EtchedBorderUIResource that appears lowered into
+ * the surface. The colors will be derived from the background
+ * color of the enclosed Component when the border gets painted.
+ */
+ public EtchedBorderUIResource()
+ {
+ super();
+ }
+
+
+ /**
+ * Constructs an EtchedBorderUIResource with the specified
+ * appearance. The colors will be derived from the background
+ * color of the enclosed Component when the border gets painted.
+ *
+ * <p><img src="../border/doc-files/EtchedBorder-1.png"
+ * width="500" height="200" alt="[An illustration of the two
+ * EtchedBorder variants]" /></p>
+ *
+ * @param etchType the desired appearance of the border. The value
+ * must be either {@link javax.swing.border.EtchedBorder#RAISED}
+ * or {@link javax.swing.border.EtchedBorder#LOWERED}.
+ *
+ * @throws IllegalArgumentException if <code>etchType</code> has
+ * an unsupported value.
+ */
+ public EtchedBorderUIResource(int etchType)
+ {
+ super(etchType);
+ }
+
+
+ /**
+ * Constructs a lowered EtchedBorderUIResource, explicitly
+ * selecting the colors that will be used for highlight and
+ * shadow.
+ *
+ * @param highlight the color that will be used for painting
+ * the highlight part of the border.
+ *
+ * @param shadow the color that will be used for painting
+ * the shadow part of the border.
+ *
+ * @see EtchedBorderUIResource#EtchedBorderUIResource(int, Color, Color)
+ */
+ public EtchedBorderUIResource(Color highlight, Color shadow)
+ {
+ super(highlight, shadow);
+ }
+
+
+ /**
+ * Constructs an EtchedBorderUIResource with the specified
+ * appearance, explicitly selecting the colors that will be used
+ * for highlight and shadow.
+ *
+ * <p><img src="../border/doc-files/EtchedBorder-2.png" width="500"
+ * height="200" alt="[An illustration that shows which pixels get
+ * painted in what color]" /></p>
+ *
+ * @param etchType the desired appearance of the border. The value
+ * must be either {@link javax.swing.border.EtchedBorder#RAISED}
+ * or {@link javax.swing.border.EtchedBorder#LOWERED}.
+ *
+ * @param highlight the color that will be used for painting
+ * the highlight part of the border.
+ *
+ * @param shadow the color that will be used for painting
+ * the shadow part of the border.
+ *
+ * @throws IllegalArgumentException if <code>etchType</code> has
+ * an unsupported value.
+ */
+ public EtchedBorderUIResource(int etchType,
+ Color highlight, Color shadow)
+ {
+ super(etchType, highlight, shadow);
+ }
+ }
+
+
+ /**
+ * A {@link javax.swing.border.LineBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * <p><img src="../border/doc-files/LineBorder-1.png" width="500"
+ * height="200" alt="[An illustration of two LineBorders]" /></p>
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class LineBorderUIResource
+ extends LineBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = -6171232338180172310L;
+
+ /**
+ * Constructs a LineBorderUIResource given its color. The border
+ * will be one pixel thick and have plain corners.
+ *
+ * @param color the color for drawing the border.
+ */
+ public LineBorderUIResource(Color color)
+ {
+ super(color);
+ }
+
+
+ /**
+ * Constructs a LineBorder given its color and thickness. The
+ * border will have plain corners.
+ *
+ * @param color the color for drawing the border.
+ * @param thickness the width of the line in pixels.
+ */
+ public LineBorderUIResource(Color color, int thickness)
+ {
+ super(color, thickness);
+ }
+
+
+ /* Note: Since JDK1.3, javax.swing.border.LineBorder also has a
+ * constructor which accepts a value for the roundedCorners
+ * property. However, as of JDK1.4.1, the LineBorderUIResource
+ * subclass does not have a corresponding constructor.
+ *
+ * A request for enhancing the Swing API has been filed with Sun:
+ * http://developer.java.sun.com/developer/bugParade/bugs/4879999.html
+ */
+ }
+
+
+ /**
+ * A {@link javax.swing.border.MatteBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * <p><img src="../border/doc-files/MatteBorder-1.png" width="500"
+ * height="150" alt="[An illustration of two MatteBorders]" /></p>
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class MatteBorderUIResource
+ extends MatteBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = -8107923147541851122L;
+
+ /**
+ * Constructs a MatteBorderUIResource given the width on each side
+ * and a fill color.
+ *
+ * <p><img src="../border/doc-files/MatteBorder-2.png" width="500"
+ * height="150" alt="[A picture of a MatteBorder made by this
+ * constructor]" /></p>
+ *
+ * @param top the width of the border at its top edge.
+ * @param left the width of the border at its left edge.
+ * @param bottom the width of the border at its bottom edge.
+ * @param right the width of the border at its right edge.
+ * @param color the color for filling the border.
+ */
+ public MatteBorderUIResource(int top, int left,
+ int bottom, int right,
+ Color color)
+ {
+ super(top, left, bottom, right, color);
+ }
+
+
+ /**
+ * Constructs a MatteBorderUIResource given the width on each side
+ * and an icon for tiling the border area.
+ *
+ * <p><img src="../border/doc-files/MatteBorder-4.png" width="500"
+ * height="150" alt="[A picture of a MatteBorder made by this
+ * constructor]" /></p>
+ *
+ * @param top the width of the border at its top edge.
+ * @param left the width of the border at its left edge.
+ * @param bottom the width of the border at its bottom edge.
+ * @param right the width of the border at its right edge.
+ * @param tileIcon an icon for tiling the border area.
+ */
+ public MatteBorderUIResource(int top, int left,
+ int bottom, int right,
+ Icon tileIcon)
+ {
+ super(top, left, bottom, right, tileIcon);
+ }
+
+
+ /**
+ * Constructs a MatteBorderUIResource given an icon for tiling the
+ * border area. The icon width is used for the border insets at
+ * the left and right edge, the icon height for the top and bottom
+ * edge.
+ *
+ * <p><img src="../border/doc-files/MatteBorder-6.png" width="500"
+ * height="150" alt="[A picture of a MatteBorder made by this
+ * constructor]" /></p>
+ *
+ * @param tileIcon an icon for tiling the border area.
+ */
+ public MatteBorderUIResource(Icon tileIcon)
+ {
+ super(tileIcon);
+ }
+ }
+
+
+ /**
+ * A {@link javax.swing.border.TitledBorder} that also implements the
+ * {@link UIResource} marker interface. This is useful for
+ * implementing pluggable look-and-feels: When switching the current
+ * LookAndFeel, only those borders are replaced that are marked as
+ * {@link UIResource}. For this reason, a look-and-feel should
+ * always install borders that implement <code>UIResource</code>,
+ * such as the borders provided by this class.
+ *
+ * @author Brian Jones (cbj at gnu.org)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class TitledBorderUIResource
+ extends TitledBorder
+ implements UIResource, Serializable
+ {
+ private static final long serialVersionUID = 7667113547406407427L;
+
+ /**
+ * Constructs a TitledBorderUIResource given the text of its title.
+ *
+ * @param title the title text, or <code>null</code> to use no
+ * title text.
+ */
+ public TitledBorderUIResource(String title)
+ {
+ super(title);
+ }
+
+
+ /**
+ * Constructs an initially untitled TitledBorderUIResource
+ * given another border.
+ *
+ * @param border the border underneath the title, or
+ * <code>null</code> to use a default from
+ * the current look and feel.
+ */
+ public TitledBorderUIResource(Border border)
+ {
+ super(border);
+ }
+
+
+ /**
+ * Constructs a TitledBorder given its border and title text.
+ *
+ * @param border the border underneath the title, or
+ * <code>null</code> to use a default from
+ * the current look and feel.
+ *
+ * @param title the title text, or <code>null</code>
+ * to use no title text.
+ */
+ public TitledBorderUIResource(Border border, String title)
+ {
+ super(border, title);
+ }
+
+
+ /**
+ * Constructs a TitledBorderUIResource given its border, title
+ * text, horizontal alignment, and vertical position.
+ *
+ * @param border the border underneath the title, or
+ * <code>null</code> to use a default
+ * from the current look and feel.
+ *
+ * @param title the title text, or <code>null</code>
+ * to use no title text.
+ *
+ * @param titleJustification the horizontal alignment of the title
+ * text in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#LEFT},
+ * {@link javax.swing.border.TitledBorder#CENTER},
+ * {@link javax.swing.border.TitledBorder#RIGHT},
+ * {@link javax.swing.border.TitledBorder#LEADING},
+ * {@link javax.swing.border.TitledBorder#TRAILING}, or
+ * {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
+ *
+ * @param titlePosition the vertical position of the title text
+ * in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#ABOVE_TOP},
+ * {@link javax.swing.border.TitledBorder#TOP},
+ * {@link javax.swing.border.TitledBorder#BELOW_TOP},
+ * {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
+ * or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
+ *
+ * @throws IllegalArgumentException if <code>titleJustification</code>
+ * or <code>titlePosition</code> have an unsupported value.
+ */
+ public TitledBorderUIResource(Border border, String title,
+ int titleJustification,
+ int titlePosition)
+ {
+ super(border, title, titleJustification, titlePosition);
+ }
+
+
+ /**
+ * Constructs a TitledBorder given its border, title text,
+ * horizontal alignment, vertical position, and font.
+ *
+ * @param border the border underneath the title, or
+ * <code>null</code> to use a default
+ * from the current look and feel.
+ *
+ * @param title the title text, or <code>null</code>
+ * to use no title text.
+ *
+ * @param titleJustification the horizontal alignment of the title
+ * text in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#LEFT},
+ * {@link javax.swing.border.TitledBorder#CENTER},
+ * {@link javax.swing.border.TitledBorder#RIGHT},
+ * {@link javax.swing.border.TitledBorder#LEADING},
+ * {@link javax.swing.border.TitledBorder#TRAILING}, or
+ * {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
+ *
+ * @param titlePosition the vertical position of the title text
+ * in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#ABOVE_TOP},
+ * {@link javax.swing.border.TitledBorder#TOP},
+ * {@link javax.swing.border.TitledBorder#BELOW_TOP},
+ * {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
+ * or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
+ *
+ * @param titleFont the font for the title text, or <code>null</code>
+ * to use a default from the current look and feel.
+ *
+ * @throws IllegalArgumentException if <code>titleJustification</code>
+ * or <code>titlePosition</code> have an unsupported value.
+ */
+ public TitledBorderUIResource(Border border, String title,
+ int titleJustification,
+ int titlePosition,
+ Font titleFont)
+ {
+ super(border, title, titleJustification, titlePosition,
+ titleFont);
+ }
+
+
+ /**
+ * Constructs a TitledBorder given its border, title text,
+ * horizontal alignment, vertical position, font, and color.
+ *
+ * @param border the border underneath the title, or
+ * <code>null</code> to use a default
+ * from the current look and feel.
+ *
+ * @param title the title text, or <code>null</code>
+ * to use no title text.
+ *
+ * @param titleJustification the horizontal alignment of the title
+ * text in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#LEFT},
+ * {@link javax.swing.border.TitledBorder#CENTER},
+ * {@link javax.swing.border.TitledBorder#RIGHT},
+ * {@link javax.swing.border.TitledBorder#LEADING},
+ * {@link javax.swing.border.TitledBorder#TRAILING}, or
+ * {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
+ *
+ * @param titlePosition the vertical position of the title text
+ * in relation to the border. The value must be one of
+ * {@link javax.swing.border.TitledBorder#ABOVE_TOP},
+ * {@link javax.swing.border.TitledBorder#TOP},
+ * {@link javax.swing.border.TitledBorder#BELOW_TOP},
+ * {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BOTTOM},
+ * {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
+ * or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
+ *
+ * @param titleFont the font for the title text, or <code>null</code>
+ * to use a default from the current look and feel.
+ *
+ * @param titleColor the color for the title text, or <code>null</code>
+ * to use a default from the current look and feel.
+ *
+ * @throws IllegalArgumentException if <code>titleJustification</code>
+ * or <code>titlePosition</code> have an unsupported value.
+ */
+ public TitledBorderUIResource(Border border, String title,
+ int titleJustification, int titlePosition,
+ Font titleFont, Color titleColor)
+ {
+ super(border, title, titleJustification, titlePosition,
+ titleFont, titleColor);
+ }
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ButtonUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ButtonUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ButtonUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ButtonUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* ButtonUI.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JButton</code>.
+ *
+ * @see javax.swing.JButton
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ButtonUI extends ComponentUI
+{
+ // This abstract class does not define any methods of its own.
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ColorChooserUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JColorChooser</code>.
+ *
+ * @see javax.swing.JColorChooser
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ColorChooserUI extends ComponentUI
+{
+ /**
+ * Constructs a ColorChooserUI.
+ */
+ public ColorChooserUI()
+ {
+ /* The constructor does not do anything. */
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ColorUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* ColorUIResource.java
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Color;
+
+
+/**
+ * A Color that is marked as <code>UIResource</code>, which indicates that
+ * the color has been installed by a pluggable LookAndFeel. Such colors
+ * are replaced when the LookAndFeel changes.
+ *
+ * @see java.awt.Color
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class ColorUIResource extends Color implements UIResource
+{
+ /**
+ * Constructs a <code>ColorUIResource</code> using the specified
+ * red, green, and blue values, which must be given as integers in
+ * the range of 0-255. The alpha channel value will default to 255,
+ * meaning that the color is fully opaque.
+ *
+ * @param r the red intensity, which must be in the range [0 .. 255].
+ * @param g the green intensity, which must be in the range [0 .. 255].
+ * @param b the blue intensity, which must be in the range [0 .. 255].
+ *
+ * @throws IllegalArgumentException if any of the values is outside the
+ * specified range.
+ */
+ public ColorUIResource(int r, int g, int b)
+ {
+ super(r, g, b);
+ }
+
+
+ /**
+ * Constructs a <code>ColorUIResource</code> using the specified
+ * RGB value. The blue value is in bits 0-7, green in bits 8-15, and
+ * red in bits 16-23. The other bits are ignored. The alpha value is set
+ * to 255, meaning that the color is fully opaque.
+ *
+ * @param rgb the rgb value, as discussed above.
+ */
+ public ColorUIResource(int rgb)
+ {
+ super(rgb);
+ }
+
+
+ /**
+ * Constructs a <code>ColorUIResource</code> using the specified
+ * red, green, and blue intensities, which must be given as floats in
+ * the range of 0-1. The alpha channel value will default to 1.0f,
+ * meaning that the color is fully opaque.
+ *
+ * @param r the red intensity, which must be in the range [0.0 .. 1.0].
+ * @param g the green intensity, which must be in the range [0.0 .. 1.0].
+ * @param b the blue intensity, which must be in the range [0.0 .. 1.0].
+ *
+ * @throws IllegalArgumentException if any of the values is outside the
+ * specified range.
+ */
+ public ColorUIResource(float r, float g, float b)
+ {
+ super(r, g, b);
+ }
+
+
+ /**
+ * Constructs a <code>ColorUIResource</code>, using the intensities
+ * of another color.
+ *
+ * @param c the color whose intensities will be considered when
+ * constructing this <code>ColorUIResource</code> (<code>null</code>
+ * not permitted).
+ *
+ * @throws NullPointerException if <code>c</code> is <code>null</code>.
+ */
+ public ColorUIResource(Color c)
+ {
+ super(c.getRGB());
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComboBoxUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComboBoxUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComboBoxUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComboBoxUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* ComboBoxUI.java --
+ Copyright (C) 2002, 2003, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+import javax.swing.JComboBox;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a {@link JComboBox}.
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ComboBoxUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ComboBoxUI</code>.
+ */
+ public ComboBoxUI()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Sets the visibility of the popup button.
+ *
+ * @param c the <code>JComboBox</code> whose popup
+ * is shown or hidden.
+ *
+ * @param visible <code>true</code> to show the popup, <code>false</code>
+ * to hide it.
+ */
+ public abstract void setPopupVisible(JComboBox c, boolean visible);
+
+ /**
+ * Determines whether the popup button is currently visible.
+ *
+ * @param c the <code>JComboBox</code> whose popup visibility
+ * is retrieved.
+ *
+ * @return <code>true</code> if the popup button is currently
+ * visible, <code>false</code> otherwise.
+ */
+ public abstract boolean isPopupVisible(JComboBox c);
+
+ /**
+ * Determines whether the combo box can receive input focus.
+ *
+ * @param c <code>JComboBox</code> whose focus traversability
+ * is to be retrieved.
+ *
+ * @return <code>true</code> if <code>c</code> can receive
+ * input focus, <code>false</code> otherwise.
+ */
+ public abstract boolean isFocusTraversable(JComboBox c);
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentInputMapUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentInputMapUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentInputMapUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentInputMapUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* ComponentInputMapUIResource.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+import javax.swing.ComponentInputMap;
+import javax.swing.JComponent;
+
+
+/**
+ * A <code>ComponentInputMap</code> that implements the {@link UIResource}
+ * interface to indicate that it belongs to a pluggable
+ * LookAndFeel.
+ *
+ * @see javax.swing.ComponentInputMap
+ * @see javax.swing.InputMap
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class ComponentInputMapUIResource extends ComponentInputMap
+ implements UIResource
+{
+ /**
+ * Constructs a new <code>ComponentInputMapUIResource</code>.
+ *
+ * @param component the <code>JComponent</code> associated with
+ * this <code>InputMap</code>.
+ */
+ public ComponentInputMapUIResource(JComponent component)
+ {
+ super(component);
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ComponentUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,331 @@
+/* ComponentUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+
+/**
+ * The abstract base class for all delegates that provide the
+ * pluggable look and feel for Swing components. User applications
+ * should not need to access this class; it is internal to Swing
+ * and the look-and-feel implementations.
+ *
+ * <p><img src="doc-files/ComponentUI-1.png" width="700" height="550"
+ * alt="[UML diagram illustrating the architecture for pluggable
+ * look and feels]" /></p>
+ *
+ * <p>Components such as {@link javax.swing.JSlider} do not directly
+ * implement operations related to the look and feel of the user
+ * interface, such as painting or layout. Instead, they use a delegate
+ * object for all such tasks. In the case of <code>JSlider</code>, the
+ * user interface would be provided by some concrete subclass of
+ * {@link javax.swing.plaf.SliderUI}.
+ *
+ * <p>Soon after its creation, a <code>ComponentUI</code> will be sent
+ * an {@link #installUI} message. The <code>ComponentUI</code> will
+ * react by setting properties such as the border or the background
+ * color of the <code>JComponent</code> for which it provides its
+ * services. Soon before the end of its lifecycle, the
+ * <code>ComponentUI</code> will receive an {@link #uninstallUI}
+ * message, at which time the <code>ComponentUI</code> is expected to
+ * undo any changes.</p>
+ *
+ * <p>Note that the <code>ui</code> of a <code>JComponent</code>
+ * changes whenever the user switches between look and feels. For
+ * example, the <code>ui</code> property of a <code>JSlider</code>
+ * could change from an instance of <code>MetalSliderUI</code> to an
+ * instance of <code>FooSliderUI</code>. This switch can happen at any
+ * time, but it will always be performed from inside the Swing thread.</p>
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ComponentUI
+{
+ /**
+ * Constructs a new UI delegate.
+ */
+ public ComponentUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Sets up the specified component so it conforms the the design
+ * guidelines of the implemented look and feel. When the look and
+ * feel changes, a <code>ComponentUI</code> delegate is created.
+ * The delegate object then receives an <code>installUI</code>
+ * message.
+ *
+ * <p>This method should perform the following tasks:</p>
+ *
+ * <ul>
+ * <li>Set visual properties such as borders, fonts, colors, or
+ * icons. However, no change should be performed for those
+ * properties whose values have been directly set by the client
+ * application. To allow the distinction, LookAndFeels are expected
+ * to use values that implement the {@link UIResource} marker
+ * interface, such as {@link BorderUIResource} or {@link
+ * ColorUIResource}.</li>
+ * <li>If necessary, install a {@link java.awt.LayoutManager}.</li>
+ * <li>Embed custom sub-components. For instance, the UI delegate
+ * for a {@link javax.swing.JSplitPane} might install a special
+ * component for the divider.</li>
+ * <li>Register event listeners.</li>
+ * <li>Set up properties related to keyborad navigation, such as
+ * mnemonics or focus traversal policies.</li>
+ * </ul>
+ *
+ * @param c the component for which this delegate will provide
+ * services.
+ *
+ * @see #uninstallUI
+ * @see javax.swing.JComponent#setUI
+ * @see javax.swing.JComponent#updateUI
+ */
+ public void installUI(JComponent c)
+ {
+ // The default implementation does not change any properties.
+ }
+
+
+ /**
+ * Puts the specified component into the state it had before
+ * {@link #installUI} was called.
+ *
+ * @param c the component for which this delegate has provided
+ * services.
+ *
+ * @see #installUI
+ * @see javax.swing.JComponent#setUI
+ * @see javax.swing.JComponent#updateUI
+ */
+ public void uninstallUI(JComponent c)
+ {
+ // The default implementation does not change any properties.
+ }
+
+
+ /**
+ * Paints the component according to the design guidelines
+ * of the look and feel. Most subclasses will want to override
+ * this method.
+ *
+ * @param g the graphics for painting.
+ *
+ * @param c the component for which this delegate performs
+ * services.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ // Nothing is done here. This method is meant to be overridden by
+ // subclasses.
+ }
+
+
+ /**
+ * Fills the specified component with its background color
+ * (unless the <code>opaque</code> property is <code>false</code>)
+ * before calling {@link #paint}.
+ *
+ * <p>It is unlikely that a subclass needs to override this method.
+ * The actual rendering should be performed by the {@link #paint}
+ * method.
+ *
+ * @param g the graphics for painting.
+ *
+ * @param c the component for which this delegate performs
+ * services.
+ *
+ * @see #paint
+ * @see javax.swing.JComponent#paintComponent
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ if (c.isOpaque())
+ {
+ Color oldColor = g.getColor();
+ g.setColor(c.getBackground());
+ g.fillRect(0, 0, c.getWidth(), c.getHeight());
+ g.setColor(oldColor);
+ }
+ paint(g, c);
+ }
+
+ /**
+ * Determines the preferred size of a component. The default
+ * implementation returns <code>null</code>, which means that
+ * <code>c</code>’s layout manager should be asked to
+ * calculate the preferred size.
+ *
+ * @param c the component for which this delegate performs services.
+ *
+ * @return the preferred size, or <code>null</code> to indicate that
+ * <code>c</code>’s layout manager should be asked
+ * for the preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return null;
+ }
+
+
+ /**
+ * Determines the minimum size of a component. The default
+ * implementation calls {@link #getPreferredSize}, but subclasses
+ * might want to override this.
+ *
+ * @param c the component for which this delegate performs services.
+ *
+ * @return the minimum size, or <code>null</code> to indicate that
+ * <code>c</code>’s layout manager should be asked
+ * to calculate the minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+
+ /**
+ * Determines the maximum size of a component. The default
+ * implementation calls {@link #getPreferredSize}, but subclasses
+ * might want to override this.
+ *
+ * @param c the component for which this delegate performs services.
+ *
+ * @return the maximum size, or <code>null</code> to indicate that
+ * <code>c</code>’s layout manager should be asked
+ * to calculate the maximum size.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+
+ /**
+ * Determines whether a click into the component at a specified
+ * location is considered as having hit the component. The default
+ * implementation checks whether the point falls into the
+ * component’s bounding rectangle. Some subclasses might want
+ * to override this, for example in the case of a rounded button.
+ *
+ * @param c the component for which this delegate performs services.
+ *
+ * @param x the x coordinate of the point, relative to the local
+ * coordinate system of the component. Zero would be be
+ * component’s left edge, irrespective of the location
+ * inside its parent.
+ *
+ * @param y the y coordinate of the point, relative to the local
+ * coordinate system of the component. Zero would be be
+ * component’s top edge, irrespective of the location
+ * inside its parent.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ /* JComponent.contains calls the ui delegate for hit
+ * testing. Therefore, endless mutual recursion would result if we
+ * called c.contains(x, y) here.
+ *
+ * The previous Classpath implementation called the deprecated
+ * method java.awt.Component.inside. In the Sun implementation, it
+ * can be observed that inside, other than contains, does not call
+ * the ui delegate. But that inside() behaves different to
+ * contains() clearly is in violation of the method contract, and
+ * it is not something that a good implementation should rely upon
+ * -- even if Classpath ends up being forced to replicate this
+ * apparent bug of the Sun implementation.
+ */
+ return (x >= 0) && (x < c.getWidth())
+ && (y >= 0) && (y < c.getHeight());
+ }
+
+
+ /**
+ * Creates a delegate object for the specified component. Users
+ * should use the <code>createUI</code> method of a suitable
+ * subclass. The implementation of <code>ComponentUI</code>
+ * always throws an error.
+ *
+ * @param c the component for which a UI delegate is requested.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ throw new Error(
+ "javax.swing.plaf.ComponentUI does not implement createUI; call "
+ + "createUI on a subclass.");
+ }
+
+
+ /**
+ * Counts the number of accessible children in the component. The
+ * default implementation delegates the inquiry to the {@link
+ * javax.accessibility.AccessibleContext} of <code>c</code>.
+ *
+ * @param c the component whose accessible children
+ * are to be counted.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ return c.getAccessibleContext().getAccessibleChildrenCount();
+ }
+
+
+ /**
+ * Returns the specified accessible child of the component. The
+ * default implementation delegates the inquiry to the {@link
+ * javax.accessibility.AccessibleContext} of <code>c</code>.
+ *
+ * @param i the index of the accessible child, starting at zero.
+ *
+ * @param c the component whose <code>i</code>-th accessible child
+ * is requested.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ return c.getAccessibleContext().getAccessibleChild(i);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopIconUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopIconUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopIconUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopIconUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,56 @@
+/* DesktopIconUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a desktop icon.
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class DesktopIconUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>DesktopIconUI</code>.
+ */
+ public DesktopIconUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DesktopPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* DesktopPaneUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JDesktopPane</code>.
+ *
+ * @see javax.swing.JDesktopPane
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class DesktopPaneUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>DesktopPaneUI</code>.
+ */
+ public DesktopPaneUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DimensionUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DimensionUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DimensionUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/DimensionUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* DimensionUIResource.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Dimension;
+
+/**
+ * A Dimension that is marked as <code>UIResource</code>, which
+ * indicates that it has been installed by a pluggable
+ * LookAndFeel. Such dimensions are replaced when the LookAndFeel
+ * changes.
+ *
+ * @see java.awt.Dimension
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class DimensionUIResource extends Dimension implements UIResource
+{
+ /**
+ * Constructs a new DimensionUIResource, given its width and height.
+ *
+ * @param width the width in pixels.
+ * @param height the height in pixels.
+ */
+ public DimensionUIResource(int width, int height)
+ {
+ super(width, height);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FileChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FileChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FileChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FileChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,138 @@
+/* FileChooserUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileView;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JFileChooser</code>.
+ *
+ * @see javax.swing.JFileChooser
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class FileChooserUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>FileChooserUI</code>.
+ */
+ public FileChooserUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Returns a <code>FileFilter</code> that accepts every file. While
+ * the filtering itself is not specific to any look and feel, the
+ * text returned by <code>FileFilter.getDescription()</code> need
+ * not be the same across all look and feels.
+ *
+ * @param chooser the <code>JFileChooser</code> for which
+ * a <code>FileFilter</code> is requested.
+ *
+ * @see javax.swing.JFileChooser#getAcceptAllFileFilter
+ * @see javax.swing.filechooser.FileFilter#getDescription
+ */
+ public abstract FileFilter getAcceptAllFileFilter(JFileChooser chooser);
+
+
+ /**
+ * Returns a view to a file, which is able to retrieve its name,
+ * icon, and other properties that are relevant for presenting
+ * the file to the user.
+ *
+ * @param chooser the <code>JFileChooser</code> for which
+ * a <code>FileFilter</code> is requested.
+ */
+ public abstract FileView getFileView(JFileChooser chooser);
+
+
+ /**
+ * Determines which text is appropriate for the approve button
+ * according to the design guidelines of the implemented
+ * look and feel.
+ *
+ * @param chooser the <code>JFileChooser</code> whose
+ * button text is requested.
+ *
+ * @see javax.swing.JFileChooser#getApproveButtonText
+ */
+ public abstract String getApproveButtonText(JFileChooser chooser);
+
+
+ /**
+ * Determines which text is appropriate for the title bar of a
+ * <code>JFileChooser</code> according to the design guidelines of
+ * the implemented look and feel.
+ *
+ * @param chooser the <code>JFileChooser</code> whose
+ * dialog title is requested.
+ *
+ * @see javax.swing.JFileChooser#getDialogTitle
+ */
+ public abstract String getDialogTitle(JFileChooser chooser);
+
+
+ /**
+ * Refreshes the currently displayed directory.
+ *
+ * @param chooser the <code>JFileChooser</code> whose
+ * dialog title needs re-scanning.
+ */
+ public abstract void rescanCurrentDirectory(JFileChooser chooser);
+
+
+ /**
+ * Ensures that a specified file is visible in the
+ * <code>JFileChooser</code>
+ *
+ * @param chooser the <code>JFileChooser</code> that
+ * should display the file <code>file</code>.
+ *
+ * @param file the file that needs to be made visible.
+ */
+ public abstract void ensureFileIsVisible(JFileChooser chooser, File file);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FontUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FontUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FontUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/FontUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* FontUIResource.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Font;
+
+
+/**
+ * A font that is marked as <code>UIResource</code>, which
+ * indicates that it has been installed by a pluggable
+ * LookAndFeel. Such dimensions are replaced when the LookAndFeel
+ * changes.
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class FontUIResource extends Font implements UIResource
+{
+ /**
+ * Constructs a new <code>FontUIResource</code> given
+ * the name, style and size of the font.
+ *
+ * @param name the name of the font. A number of
+ * “logical” names are supported by any Java
+ * implementation. These are
+ * <code>“Dialog”</code>,
+ * <code>“DialogInput”</code>,
+ * <code>“Monospaced”</code>,
+ * <code>“Serif”</code>, and
+ * <code>“SansSerif”</code>.
+ *
+ * @param style the style of the font, for instance {@link
+ * java.awt.Font#BOLD} or {@link java.awt.Font#PLAIN}.
+ *
+ * @param size the size of the font in typographic points, for
+ * instance 10, 12 or 13. Designers of LookAndFeels should be
+ * aware that some languages (like Japanese and Chinese) have
+ * glyphs that are too complex to be legible at small point
+ * sizes.
+ */
+ public FontUIResource(String name, int style, int size)
+ {
+ super(name, style, size);
+ }
+
+
+ /**
+ * Constructs a new <code>FontUIResource</code> given
+ * an existing font.
+ *
+ * @param f the font that serves as a template.
+ */
+ public FontUIResource(Font f)
+ {
+ /* This implementation will get rid of many font properties,
+ * such as skewing, values of multiple master design axes,
+ * etc., unless they get encoded into the name. It probably
+ * is not a problem for LookAndFeels because user interfaces
+ * are usually not very advanced with respect to typography.
+ */
+ super(f.getName(), f.getStyle(), f.getSize());
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/IconUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/IconUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/IconUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/IconUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,124 @@
+/* IconUIResource.java --
+ Copyright (C) 2002, 2003, 2004, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+
+/**
+ * An icon that is marked as <code>UIResource</code>, which
+ * indicates that it has been installed by a pluggable
+ * LookAndFeel. Such icons are replaced when the LookAndFeel
+ * changes.
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class IconUIResource implements Icon, UIResource, Serializable
+{
+ /**
+ * Verified using the <code>serialver</code> tool of Sun JDK 1.4.1_01
+ * on GNU/Linux 2.4.18.
+ */
+ static final long serialVersionUID = 3327049506004830542L;
+
+
+ /**
+ * The icon that is wrapped by this <code>IconUIResource</code> (never
+ * <code>null</code>).
+ */
+ private Icon delegate;
+
+
+ /**
+ * Constructs a <code>IconUIResource</code> that wraps another
+ * icon. All messages are forwarded to the delegate icon.
+ *
+ * @param delegate the icon that is wrapped by this
+ * <code>IconUIResource</code> (<code>null</code> not permitted).
+ */
+ public IconUIResource(Icon delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null 'delegate' argument.");
+ this.delegate = delegate;
+ }
+
+
+ /**
+ * Paints the icon by asking the delegate icon to paint itself.
+ *
+ * @param c the Component whose icon is being painted. Some icons
+ * use this argument to retrieve properties like the
+ * background color.
+ *
+ * @param g the graphics into which the icon will be painted.
+ *
+ * @param x the horizontal position of the icon.
+ *
+ * @param y the vertical position of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ delegate.paintIcon(c, g, x, y);
+ }
+
+
+ /**
+ * Returns the width of the icon in pixels. The implementation
+ * determines and returns the width of the delegate icon.
+ */
+ public int getIconWidth()
+ {
+ return delegate.getIconWidth();
+ }
+
+
+ /**
+ * Returns the height of the icon in pixels. The implementation
+ * determines and returns the height of the delegate icon.
+ */
+ public int getIconHeight()
+ {
+ return delegate.getIconHeight();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InputMapUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InputMapUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InputMapUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InputMapUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* InputMapUIResource.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+import javax.swing.InputMap;
+
+
+/**
+ * An <code>InputMap</code> that is marked as <code>UIResource</code>,
+ * which indicates that it has been installed by a pluggable
+ * LookAndFeel. Such dimensions are replaced when the LookAndFeel
+ * changes.
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class InputMapUIResource extends InputMap implements UIResource
+{
+ /**
+ * Constructs a new <code>InputMapUIResource</code>.
+ */
+ public InputMapUIResource()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InsetsUIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InsetsUIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InsetsUIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InsetsUIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* InsetsUIResource.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Insets;
+import java.io.Serializable;
+
+
+/**
+ * An <code>Insets</code> that is marked as <code>UIResource</code>,
+ * which indicates that it has been installed by a pluggable
+ * LookAndFeel. Such insets are replaced when the LookAndFeel changes.
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class InsetsUIResource extends Insets
+ implements Cloneable, UIResource, Serializable
+{
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = 5622110143266315421L;
+
+
+ /**
+ * Constructs a new <code>InsetsUIResource</code> given the
+ * inset at each edge.
+ *
+ * @param top the inset at the top, in pixels.
+ * @param left the inset at the left, in pixels.
+ * @param bottom the inset at the bottom, in pixels.
+ * @param right the inset at the right, in pixels.
+ */
+ public InsetsUIResource(int top, int left, int bottom, int right)
+ {
+ super(top, left, bottom, right);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InternalFrameUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InternalFrameUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InternalFrameUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/InternalFrameUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* InternalFrameUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JInternalFrame</code>.
+ *
+ * @see javax.swing.JInternalFrame
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class InternalFrameUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>InternalFrameUI</code>.
+ */
+ public InternalFrameUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/LabelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/LabelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/LabelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/LabelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* LabelUI.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JLabel</code>.
+ *
+ * @see javax.swing.JLabel
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class LabelUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>LabelUI</code>.
+ */
+ public LabelUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ListUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ListUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ListUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ListUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,114 @@
+/* ListUI.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+
+import javax.swing.JList;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JList</code>.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ListUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ListUI</code>.
+ */
+ public ListUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Determines the cell index which is the closest to the specified
+ * location. The find out whether the returned cell actually
+ * contains the location, the caller should also use {@link
+ * #getCellBounds}.
+ *
+ * @param list the <code>JList</code> for which this delegate object
+ * provides the pluggable user interface.
+ *
+ * @param location a point in the <code>JList</code> coordinate
+ * system.
+ *
+ * @return the index of the closest cell, or -1 if the list model
+ * is empty.
+ */
+ public abstract int locationToIndex(JList list, Point location);
+
+
+ /**
+ * Determines the location of the specified cell.
+ *
+ * @param list the <code>JList</code> for which this delegate object
+ * provides the pluggable user interface.
+ *
+ * @param index the zero-based index of the cell whose location shall be
+ * determined.
+ *
+ * @return the position of the top left corner of the cell in the
+ * <code>JList</code> coordinate system, or <code>null</code>
+ * if <code>cell</code> does not designate a valid cell.
+ */
+ public abstract Point indexToLocation(JList list, int index);
+
+
+ /**
+ * Determines the bounding box of the rectangle spanned by
+ * two list indices.
+ *
+ * @param list the <code>JList</code> for which this delegate object
+ * provides the pluggable user interface.
+ *
+ * @param index1 the zero-based index of the first cell.
+ *
+ * @param index2 the zero-based index of the second cell.
+ *
+ * @return the spanned rectangle, or <code>null</code> if either
+ * <code>index1</code> or <code>index2</code> does not
+ * designate a valid cell.
+ */
+ public abstract Rectangle getCellBounds(JList list,
+ int index1, int index2);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* MenuBarUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JMenuBar</code>.
+ *
+ * @see javax.swing.JMenuBar
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class MenuBarUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>MenuBarUI</code>.
+ */
+ public MenuBarUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuItemUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuItemUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuItemUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/MenuItemUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* MenuItemUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JMenuItem</code>.
+ *
+ * @see javax.swing.JMenuItem
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class MenuItemUI extends ButtonUI
+{
+ /**
+ * Constructs a new <code>MenuItemUI</code>.
+ */
+ public MenuItemUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/OptionPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/OptionPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/OptionPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/OptionPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* OptionPaneUI.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+import javax.swing.JOptionPane;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JOptionPane</code>.
+ *
+ * @see javax.swing.JOptionPane
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class OptionPaneUI
+ extends ComponentUI
+{
+ /**
+ * Gives keyboard input focus to the component that represents
+ * the default value.
+ *
+ * @param pane the <code>JOptionPane</code> for which this delegate
+ * object provides the pluggable user interface.
+ */
+ public abstract void selectInitialValue(JOptionPane pane);
+
+
+ /**
+ * Determines whether the user has provided custom components
+ * for the options or the message.
+ *
+ * @param pane the <code>JOptionPane</code> for which this delegate
+ * object provides the pluggable user interface.
+ *
+ * @return <code>true</code> if the user has supplied any custom
+ * components; <code>false</code> if all components are
+ * provided by Swing or a LookAndFeel.
+ */
+ public abstract boolean containsCustomComponents(JOptionPane pane);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PanelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PanelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PanelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PanelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* PanelUI.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JPanel</code>.
+ *
+ * @see javax.swing.JPanel
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class PanelUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>PanelUI</code>.
+ */
+ public PanelUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PopupMenuUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PopupMenuUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PopupMenuUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/PopupMenuUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* PopupMenuUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.event.MouseEvent;
+
+import javax.swing.JPopupMenu;
+import javax.swing.Popup;
+import javax.swing.PopupFactory;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JPopupMenu</code>.
+ *
+ * @see javax.swing.JPopupMenu
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class PopupMenuUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>PopupMenuUI</code>.
+ */
+ public PopupMenuUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Tests whether or not a mouse event triggers a popup menu.
+ *
+ * <p>The default implementation calls
+ * <code>event.isPopupTrigger()</code>, which checks for the gesture
+ * that is common for the platform on which the application runs. If
+ * a look and feel wants to employ non-standard conventions for
+ * triggering a popup menu, it can override this method.
+ *
+ * @param event the event to check.
+ *
+ * @return <code>true</code> if the event triggers a popup menu;
+ * <code>false</code> otherwise.
+ *
+ * @since 1.3
+ */
+ public boolean isPopupTrigger(MouseEvent event)
+ {
+ return event.isPopupTrigger();
+ }
+
+
+ /**
+ * Creates a <code>Popup</code> for displaying the popup menu. The
+ * default implementation uses the {@link javax.swing.PopupFactory}
+ * for retrieving a suitable <code>Popup</code>, but subclasses
+ * might want to override this method if a LookAndFeel needs special
+ * Popups.
+ *
+ * @param popup the <code>JPopupMenu</code> for whose display
+ * a <code>Popup</code> is needed.
+ *
+ * @param x the horizontal position where the popup will be
+ * displayed.
+ *
+ * @param y the vertical position where the popup will be
+ * displayed.
+ *
+ * @return a <code>Popup</code> for showing and hiding
+ * the menu.
+ *
+ * @since 1.4
+ */
+ public Popup getPopup(JPopupMenu popup, int x, int y)
+ {
+ return PopupFactory.getSharedInstance().getPopup(
+ /* origin/owner of the popup */ popup.getInvoker(),
+ /* contents */ popup,
+ x, y);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ProgressBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ProgressBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ProgressBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ProgressBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ProgressBarUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JProgressBar</code>.
+ *
+ * @see javax.swing.JProgressBar
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ProgressBarUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ProgressBarUI</code>.
+ */
+ public ProgressBarUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/RootPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/RootPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/RootPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/RootPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* RootPaneUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JRootPane</code>.
+ *
+ * @see javax.swing.JRootPane
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class RootPaneUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>RootPaneUI</code>.
+ */
+ public RootPaneUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* ScrollBarUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JScrollBar</code>.
+ *
+ * @see javax.swing.JScrollBar
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ScrollBarUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ScrollBarUI</code>.
+ */
+ public ScrollBarUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ScrollPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ScrollPaneUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JScrollPane</code>.
+ *
+ * @see javax.swing.JScrollPane
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ScrollPaneUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ScrollPaneUI</code>.
+ */
+ public ScrollPaneUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SeparatorUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SeparatorUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SeparatorUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SeparatorUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* SeparatorUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JSeparator</code>.
+ *
+ * @see javax.swing.JSeparator
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class SeparatorUI
+ extends ComponentUI
+{
+ /**
+ * Constructs a new <code>SeparatorUI</code>.
+ */
+ public SeparatorUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SliderUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SliderUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SliderUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SliderUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* SliderUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JSlider</code>.
+ *
+ * @see javax.swing.JSlider
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class SliderUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>SliderUI</code>.
+ */
+ public SliderUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SpinnerUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SpinnerUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SpinnerUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SpinnerUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* SpinnerUI.java --
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JSpinner</code>.
+ *
+ * @since 1.4
+ * @see javax.swing.JSpinner
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class SpinnerUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>SpinnerUI</code>.
+ */
+ public SpinnerUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SplitPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SplitPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SplitPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/SplitPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* SplitPaneUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Graphics;
+
+import javax.swing.JSplitPane;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JSplitPane</code>.
+ *
+ * @see javax.swing.JSplitPane
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class SplitPaneUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>SplitPaneUI</code>.
+ */
+ public SplitPaneUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Moves the divider to the location which best respects
+ * the preferred sizes of the children.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ */
+ public abstract void resetToPreferredSizes(JSplitPane pane);
+
+
+ /**
+ * Moves the divider to the specified location.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ *
+ * @param location the new location of the divider.
+ */
+ public abstract void setDividerLocation(JSplitPane pane,
+ int location);
+
+
+ /**
+ * Determines the current location of the divider.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ *
+ * @return the current location of the divider.
+ */
+ public abstract int getDividerLocation(JSplitPane pane);
+
+
+ /**
+ * Determines the minimum location of the divider.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ *
+ * @return the leftmost (or topmost) possible location
+ * of the divider.
+ */
+ public abstract int getMinimumDividerLocation(JSplitPane pane);
+
+
+ /**
+ * Determines the maximum location of the divider.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ *
+ * @return the bottommost (or rightmost) possible location
+ * of the divider.
+ */
+ public abstract int getMaximumDividerLocation(JSplitPane pane);
+
+
+ /**
+ * Called by the <code>JSplitPane</code> after it has finished
+ * painting its children.
+ *
+ * @param pane the <code>JSplitPane</code> for thich this
+ * delegate provides the look and feel.
+ *
+ * @param g the Graphics used for painting.
+ */
+ public abstract void finishedPaintingChildren(JSplitPane pane,
+ Graphics g);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TabbedPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TabbedPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TabbedPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TabbedPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* TabbedPaneUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Rectangle;
+
+import javax.swing.JTabbedPane;
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JTabbedPane</code>.
+ *
+ * @see javax.swing.JTabbedPane
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class TabbedPaneUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>TabbedPaneUI</code>.
+ */
+ public TabbedPaneUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Determines which tab lies at a given position.
+ *
+ * @param pane the <code>JTabbedPane</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param x the horizontal position, where zero is the left
+ * edge of <code>pane</code>.
+ *
+ * @param y the vertical position, where zero is the top
+ * edge of <code>pane</code>.
+ *
+ * @return the zero-based index of the tab, or -1 if no
+ * tab is at the specified position.
+ */
+ public abstract int tabForCoordinate(JTabbedPane pane,
+ int x, int y);
+
+
+ /**
+ * Calculates the bounding box of a tab.
+ *
+ * @param pane the <code>JTabbedPane</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param index the index of the tab, which must be an integer
+ * in the range <code>[0 .. pane.getTabCount() - 1]</code>.
+ *
+ * @return the bounding box of the <code>index</code>-th tab,
+ * in the coordinate system of <code>pane</code>.
+ */
+ public abstract Rectangle getTabBounds(JTabbedPane pane, int index);
+
+
+ /**
+ * Determines how many runs are used to display tabs.
+ *
+ * @param pane the <code>JTabbedPane</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @return the number of tab runs.
+ *
+ * @see javax.swing.JTabbedPane#getTabRunCount()
+ */
+ public abstract int getTabRunCount(JTabbedPane pane);
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableHeaderUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableHeaderUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableHeaderUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableHeaderUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* TableHeaderUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JTableHeader</code>.
+ *
+ * @see javax.swing.table.JTableHeader
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class TableHeaderUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>TableHeaderUI</code>.
+ */
+ public TableHeaderUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TableUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* TableUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JTable</code>.
+ *
+ * @see javax.swing.JTable
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class TableUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>TableUI</code>.
+ */
+ public TableUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TextUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TextUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TextUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TextUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,281 @@
+/* TextUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.Position;
+import javax.swing.text.View;
+
+/**
+ * An abstract base class for delegates that provide the user
+ * interface for text editors.
+ *
+ * @see javax.swing.text.JTextComponent
+ *
+ * @author Ronald Veldema (rveldema at cs.vu.nl)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class TextUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>TextUI</code>.
+ */
+ public TextUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Calculates the geometric extent of the character at the
+ * given offset.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param pos the zero-based index of the character into the
+ * document model.
+ *
+ * @return the bounding box of the character at index
+ * <code>pos</code>, in view coordinates.
+ *
+ * @throws BadLocationException if <code>pos</code> does not
+ * designate a valid position in the document model.
+ *
+ * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
+ */
+ public abstract Rectangle modelToView(JTextComponent tc, int pos)
+ throws BadLocationException;
+
+
+ /**
+ * Calculates the geometric extent of the character at the
+ * given offset.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param pos the zero-based index of the character into the
+ * document model.
+ *
+ * @param bias whether to take the character before or after the
+ * caret position indicated by <code>pos</code>. The value
+ * must be either {@link
+ * javax.swing.text.Position.Bias#Backward} or {@link
+ * javax.swing.text.Position.Bias#Forward}.
+ *
+ * @return the bounding box of the character at index
+ * <code>pos</code>, in view coordinates.
+ *
+ * @throws BadLocationException if <code>pos</code> does not
+ * designate a valid position in the document model.
+ *
+ * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
+ */
+ public abstract Rectangle modelToView(JTextComponent tc, int pos,
+ Position.Bias bias)
+ throws BadLocationException;
+
+
+ /**
+ * Finds the caret position which is closest to the specified visual
+ * location.
+ *
+ * @param t the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param pt the position in view coordinates.
+ *
+ * @return the caret position which is closest to <code>loc</code>.
+ *
+ * @see #viewToModel(JTextComponent, Point, Position.Bias[])
+ */
+ public abstract int viewToModel(JTextComponent t, Point pt);
+
+
+ /**
+ * Finds the caret position which is closest to the specified visual
+ * location.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param loc the position in view coordinates.
+ *
+ * @param outBias an array whose size must be at least one.
+ * After the call, <code>outBias[0]</code> will indicate
+ * whether <code>loc</code> is in the glyph before
+ * (<code>Position.Bias.Backward</code>) or after
+ * (<code>Position.Bias.Forward</code>) the returned
+ * caret position.
+ *
+ * @return the caret position which is closest to <code>loc</code>.
+ */
+ public abstract int viewToModel(JTextComponent tc, Point loc,
+ Position.Bias[] outBias);
+
+
+
+ /**
+ * Calculates the caret position that is visually next to the given
+ * position. This is useful to determine where to move the caret
+ * after the user has pressed an arrow key.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param pos the current caret position, a zero-based index
+ * into the document model.
+ *
+ * @param bias whether to take the character before or after the
+ * caret position indicated by <code>pos</code>. The value
+ * must be either {@link
+ * javax.swing.text.Position.Bias#Backward} or {@link
+ * javax.swing.text.Position.Bias#Forward}.
+ *
+ * @param direction the visual direction. Pass
+ * {@link javax.swing.SwingConstants#WEST} for the left
+ * arrow key, {@link javax.swing.SwingConstants#EAST}
+ * for the right arrow key, {@link
+ * javax.swing.SwingConstants#NORTH} for the up arrow
+ * key, or {@link javax.swing.SwingConstants#SOUTH}
+ * for the down arrow key.
+ *
+ * @throws BadLocationException if <code>pos</code> does not
+ * designate a valid position in the document model.
+ *
+ * @throws IllegalArgumentException if <code>direction</code>
+ * is not one of <code>Position.Bias.Forward</code>
+ * or <code>Position.Bias.Backward</code>.
+ */
+ public abstract int getNextVisualPositionFrom(JTextComponent tc,
+ int pos,
+ Position.Bias bias,
+ int direction,
+ Position.Bias[] outBias)
+ throws BadLocationException;
+
+
+ /**
+ * Repaints a range of characters.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param start the first character in the range that needs
+ * painting, indicated as an index into the document model.
+ *
+ * @param end the last character in the range that needs
+ * painting, indicated as an index into the document model.
+ * <code>end</code> must be greater than or equal to
+ * <code>start</code>.
+ */
+ public abstract void damageRange(JTextComponent tc, int start, int end);
+
+
+ /**
+ * Repaints a range of characters, also specifying the bias for the
+ * start and end of the range.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param start the first character in the range that needs
+ * painting, indicated as an index into the document model.
+ *
+ * @param end the last character in the range that needs
+ * painting, indicated as an index into the document model.
+ * <code>end</code> must be greater than or equal to
+ * <code>start</code>.
+ */
+ public abstract void damageRange(JTextComponent tc,
+ int start, int end,
+ Position.Bias startBias,
+ Position.Bias endBias);
+
+
+ /**
+ * Retrieves the <code>EditorKit</code> managing policies and
+ * persistent state.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @return the <code>EditorKit</code> used by <code>tc</code>.
+ */
+ public abstract EditorKit getEditorKit(JTextComponent tc);
+
+
+ /**
+ * Retrieves the root of the view tree that visually presents
+ * the text.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @return the root <code>View</code> used by <code>tc</code>.
+ */
+ public abstract View getRootView(JTextComponent tc);
+
+
+ /**
+ * Returns a String for presenting a tool tip at the specified
+ * location.
+ *
+ * @param tc the <code>JTextComponent</code> for which this
+ * delegate object provides the user interface.
+ *
+ * @param loc the location for which the tool tip is requested.
+ *
+ * @return the text for the tool tip, or <code>null</code> to
+ * display no tool tip.
+ *
+ * @since 1.4
+ */
+ public String getToolTipText(JTextComponent tc, Point loc)
+ {
+ return null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ToolBarUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JToolBar</code>.
+ *
+ * @see javax.swing.JToolBar
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ToolBarUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ToolBarUI</code>.
+ */
+ public ToolBarUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolTipUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolTipUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolTipUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ToolTipUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ToolTipUI.java --
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JToolTip</code>.
+ *
+ * @see javax.swing.JToolTip
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ToolTipUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ToolTipUI</code>.
+ */
+ public ToolTipUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TreeUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TreeUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TreeUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/TreeUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,211 @@
+/* TreeUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+import java.awt.Rectangle;
+
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+
+/**
+ * An abstract base class for delegates that provide the user
+ * interface for <code>JTree</code>.
+ *
+ * @see javax.swing.JTree
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class TreeUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>TreeUI</code>.
+ */
+ public TreeUI()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Determines the geometric extent of the label that is
+ * drawn for a path.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @param path the path whose label extent is requested.
+ *
+ * @return a rectangle enclosing the label, or <code>null</code>
+ * if <code>path</code> contains invalid nodes.
+ */
+ public abstract Rectangle getPathBounds(JTree tree, TreePath path);
+
+
+ /**
+ * Creates a <code>TreePath</code> for the specified row.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @param row the index of the row, which should be a number
+ * in the range <code>[0, getRowCount(tree) - 1]</code>.
+ *
+ * @return a <code>TreePath</code> for the specified row, or
+ * <code>null</code> if <code>row</code> is outside
+ * the valid range.
+ */
+ public abstract TreePath getPathForRow(JTree tree, int row);
+
+
+ /**
+ * Determines in which row a <code>TreePath</code> is currently
+ * being displayed.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @param path the path for which the caller wants to know
+ * in which row it is being displayed.
+ *
+ * @return a number in the range <code>[0, getRowCount(tree)
+ * - 1]</code> if the path is currently on display;
+ * <code>-1</code> if the path is not shown to the
+ * user.
+ */
+ public abstract int getRowForPath(JTree tree, TreePath path);
+
+
+ /**
+ * Counts how many rows are currently displayed.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @return the number of visible rows.
+ */
+ public abstract int getRowCount(JTree tree);
+
+
+ /**
+ * Finds the path that is closest to the specified position.
+ *
+ * <p><img src="doc-files/TreeUI-1.png" width="300" height="250"
+ * alt="[A screen shot of a JTree]" />
+ *
+ * <p>As shown by the above illustration, the bounds of the
+ * closest path do not necessarily need to contain the passed
+ * location.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @param x the horizontal location, relative to the origin
+ * of <code>tree</code>.
+ *
+ * @param y the vertical location, relative to the origin
+ * of <code>tree</code>.
+ *
+ * @return the closest path, or <code>null</code> if the
+ * tree is currenlty not displaying any paths at all.
+ */
+ public abstract TreePath getClosestPathForLocation(JTree tree,
+ int x, int y);
+
+
+ /**
+ * Determines whether the user is currently editing a tree cell.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @see #getEditingPath
+ */
+ public abstract boolean isEditing(JTree tree);
+
+
+ /**
+ * Stops editing a tree cell, committing the entered value into the
+ * tree’s model. If no editing session is active, or if the
+ * active editor does not agree to stopping, nothing happens. In
+ * some look and feels, this action happens when the user has
+ * pressed the enter key.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @return <code>false</code> if the editing still goes on because
+ * the cell editor has objected to stopping the session;
+ * <code>true</code> if editing has been stopped.
+ */
+ public abstract boolean stopEditing(JTree tree);
+
+
+ /**
+ * Cancels editing a tree cell, discarding any entered value.
+ * If no editing session is active, nothing happens. The cell
+ * editor is not given an opportunity to veto the canceling.
+ * In some look and feels, this action happens when the user has
+ * pressed the escape key.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ */
+ public abstract void cancelEditing(JTree tree);
+
+
+ /**
+ * Starts a session to edit a tree cell. If the cell editor
+ * rejects editing the cell, it will just be selected.
+ *
+ * @param tree the <code>JTree</code> for which this delegate
+ * object provides the user interface.
+ *
+ * @param path the cell to edit.
+ */
+ public abstract void startEditingAtPath(JTree tree, TreePath path);
+
+
+ /**
+ * Retrieves the tree cell that is currently being edited.
+ *
+ * @return the currently edited path, or <code>null</code>
+ * if no editing session is currently active.
+ */
+ public abstract TreePath getEditingPath(JTree tree);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/UIResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/UIResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/UIResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/UIResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* UIResource.java
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+/**
+ * This public interface is used to designate which objects were created by
+ * {@link ComponentUI} delegates. When uninstalling the user public interface
+ * renderer with <code>ComponentUI.uninstallUI()</code> the renderer
+ * property is set to <code>null</code>.
+ * <br>
+ * A comparison against null can be used with all properties except for
+ * the <code>java.awt.Component</code> properties font, foreground, and
+ * background. The container can provide the value of the properties if
+ * they are initialized or set to <code>null</code>.
+ *
+ * @author Brian Jones
+ *
+ * @see ComponentUI
+ */
+public interface UIResource
+{
+ // This is a marker interface and declares no methods.
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ViewportUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ViewportUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ViewportUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/ViewportUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* ViewportUI.java
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf;
+
+
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JViewport</code>.
+ *
+ * @see javax.swing.JViewport
+ *
+ * @author Andrew Selkirk (aselkirk at sympatico.ca)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ViewportUI extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ViewportUI</code>.
+ */
+ public ViewportUI()
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,422 @@
+/* BasicArrowButton.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Polygon;
+
+import javax.swing.ButtonModel;
+import javax.swing.JButton;
+import javax.swing.SwingConstants;
+
+/**
+ * A button that displays an arrow (triangle) that points {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} or {@link #WEST}. This button is used by
+ * the {@link BasicComboBoxUI} class.
+ *
+ * @see BasicComboBoxUI#createArrowButton
+ */
+public class BasicArrowButton extends JButton implements SwingConstants
+{
+
+ /**
+ * The direction that the arrow points.
+ *
+ * @see #getDirection()
+ */
+ protected int direction;
+
+ /**
+ * The color the arrow is painted in if disabled and the bottom and right
+ * edges of the button.
+ * This is package-private to avoid an accessor method.
+ */
+ transient Color shadow = Color.GRAY;
+
+ /**
+ * The color the arrow is painted in if enabled and the bottom and right
+ * edges of the button.
+ * This is package-private to avoid an accessor method.
+ */
+ transient Color darkShadow = new Color(102, 102, 102);
+
+ /**
+ * The top and left edges of the button.
+ * This is package-private to avoid an accessor method.
+ */
+ transient Color highlight = Color.WHITE;
+
+ /**
+ * Creates a new <code>BasicArrowButton</code> object with an arrow pointing
+ * in the specified direction. If the <code>direction</code> is not one of
+ * the specified constants, no arrow is drawn.
+ *
+ * @param direction The direction the arrow points in (one of:
+ * {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ */
+ public BasicArrowButton(int direction)
+ {
+ super();
+ setDirection(direction);
+ setFocusable(false);
+ }
+
+ /**
+ * Creates a new BasicArrowButton object with the given colors and
+ * direction.
+ *
+ * @param direction The direction to point in (one of:
+ * {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ * @param background The background color.
+ * @param shadow The shadow color.
+ * @param darkShadow The dark shadow color.
+ * @param highlight The highlight color.
+ */
+ public BasicArrowButton(int direction, Color background, Color shadow,
+ Color darkShadow, Color highlight)
+ {
+ this(direction);
+ setBackground(background);
+ this.shadow = shadow;
+ this.darkShadow = darkShadow;
+ this.highlight = highlight;
+ setFocusable(false);
+ }
+
+ /**
+ * Returns whether the focus can traverse to this component. This method
+ * always returns <code>false</code>.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isFocusTraversable()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ *
+ * @return The direction of the arrow.
+ */
+ public int getDirection()
+ {
+ return direction;
+ }
+
+ /**
+ * Sets the direction of the arrow.
+ *
+ * @param dir The new direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ */
+ public void setDirection(int dir)
+ {
+ this.direction = dir;
+ }
+
+ /**
+ * Paints the arrow button. The painting is delegated to the
+ * paintTriangle method.
+ *
+ * @param g The Graphics object to paint with.
+ */
+ public void paint(Graphics g)
+ {
+ super.paint(g);
+
+ int height = getHeight();
+ int size = height / 4;
+
+ int x = (getWidth() - size) / 2;
+ int y = (height - size) / 2;
+
+ ButtonModel m = getModel();
+ if (m.isArmed())
+ {
+ x++;
+ y++;
+ }
+
+ paintTriangle(g, x, y, size, direction, isEnabled());
+ }
+
+ /**
+ * Returns the preferred size of the arrow button.
+ *
+ * @return The preferred size (always 16 x 16).
+ */
+ public Dimension getPreferredSize()
+ {
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(16, 16);
+ }
+
+ /**
+ * Returns the minimum size of the arrow button.
+ *
+ * @return The minimum size (always 5 x 5).
+ */
+ public Dimension getMinimumSize()
+ {
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(5, 5);
+ }
+
+ /**
+ * Returns the maximum size of the arrow button.
+ *
+ * @return The maximum size (always Integer.MAX_VALUE x Integer.MAX_VALUE).
+ */
+ public Dimension getMaximumSize()
+ {
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Paints a triangle with the given size, location and direction. It is
+ * difficult to explain the rationale behind the positioning of the triangle
+ * relative to the given (x, y) position - by trial and error we seem to
+ * match the behaviour of the reference implementation (which is missing a
+ * specification for this method).
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the triangle's location.
+ * @param y the y-coordinate for the triangle's location.
+ * @param size the arrow size (depth).
+ * @param direction the direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ public void paintTriangle(Graphics g, int x, int y, int size, int direction,
+ boolean isEnabled)
+ {
+ Color savedColor = g.getColor();
+ switch (direction)
+ {
+ case NORTH:
+ paintTriangleNorth(g, x, y, size, isEnabled);
+ break;
+ case SOUTH:
+ paintTriangleSouth(g, x, y, size, isEnabled);
+ break;
+ case LEFT:
+ case WEST:
+ paintTriangleWest(g, x, y, size, isEnabled);
+ break;
+ case RIGHT:
+ case EAST:
+ paintTriangleEast(g, x, y, size, isEnabled);
+ break;
+ }
+ g.setColor(savedColor);
+ }
+
+ /**
+ * Paints an upward-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleNorth(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 2) / 2;
+ int tipY = y;
+ int baseX1 = tipX - (size - 1);
+ int baseX2 = tipX + (size - 1);
+ int baseY = y + (size - 1);
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX1, baseY);
+ triangle.addPoint(baseX2, baseY);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX1 + 1, baseY + 1, baseX2 + 1, baseY + 1);
+ }
+ }
+
+ /**
+ * Paints an downward-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleSouth(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 2) / 2;
+ int tipY = y + (size - 1);
+ int baseX1 = tipX - (size - 1);
+ int baseX2 = tipX + (size - 1);
+ int baseY = y;
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX1, baseY);
+ triangle.addPoint(baseX2, baseY);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(tipX + 1, tipY, baseX2, baseY + 1);
+ g.drawLine(tipX + 1, tipY + 1, baseX2 + 1, baseY + 1);
+ }
+ }
+
+ /**
+ * Paints a right-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleEast(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 1);
+ int tipY = y + (size - 2) / 2;
+ int baseX = x;
+ int baseY1 = tipY - (size - 1);
+ int baseY2 = tipY + (size - 1);
+
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX, baseY1);
+ triangle.addPoint(baseX, baseY2);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX + 1, baseY2, tipX, tipY + 1);
+ g.drawLine(baseX + 1, baseY2 + 1, tipX + 1, tipY + 1);
+ }
+ }
+
+ /**
+ * Paints a left-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleWest(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x;
+ int tipY = y + (size - 2) / 2;
+ int baseX = x + (size - 1);
+ int baseY1 = tipY - (size - 1);
+ int baseY2 = tipY + (size - 1);
+
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX, baseY1);
+ triangle.addPoint(baseX, baseY2);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX + 1, baseY1 + 1, baseX + 1, baseY2 + 1);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1768 @@
+/* BasicBorders.java --
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.io.Serializable;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
+import javax.swing.JButton;
+import javax.swing.JPopupMenu;
+import javax.swing.JSplitPane;
+import javax.swing.JToolBar;
+import javax.swing.UIManager;
+import javax.swing.border.AbstractBorder;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.plaf.BorderUIResource;
+import javax.swing.plaf.UIResource;
+import javax.swing.text.JTextComponent;
+
+/**
+ * Provides various borders for the Basic look and feel.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class BasicBorders
+{
+ /**
+ * A MarginBorder that gets shared by multiple components.
+ * Created on demand by the private helper function {@link
+ * #getMarginBorder()}.
+ */
+ private static MarginBorder sharedMarginBorder;
+
+
+ /**
+ * Returns a border for drawing push buttons.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“Button.shadow”</code>,
+ * <code>“Button.darkShadow”</code>,
+ * <code>“Button.light”</code>, and
+ * <code>“Button.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.ButtonBorder-1.png" width="300"
+ * height="170" alt="[A screen shot of the returned border]" />
+ *
+ * @return a {@link
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link ButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
+ */
+ public static Border getButtonBorder()
+ {
+ Border outer;
+
+ /* The keys for UIDefaults have been determined by writing a
+ * test program that dumps the UIDefaults to stdout; that program
+ * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
+ * the key "light" is usually called "highlight", and "highlight"
+ * is usually called "lightHighlight".
+ */
+ outer = new ButtonBorder(UIManager.getColor("Button.shadow"),
+ UIManager.getColor("Button.darkShadow"),
+ UIManager.getColor("Button.light"),
+ UIManager.getColor("Button.highlight"));
+
+ /* While the inner border is shared between multiple buttons,
+ * we do not share the outer border because ButtonBorders store
+ * their border colors. We cannot guarantee that the colors
+ * (which come from UIDefaults) are unchanged between invocations
+ * of getButtonBorder. We could store the last colors, and share
+ * the button border if the colors are the same as in the last
+ * invocation, but it probably is not worth the effort.
+ */
+ return new BorderUIResource.CompoundBorderUIResource(
+ outer,
+ /* inner */ getMarginBorder());
+ }
+
+
+ /**
+ * Returns a border for drawing radio buttons.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“RadioButton.shadow”</code>,
+ * <code>“RadioButton.darkShadow”</code>,
+ * <code>“RadioButton.light”</code>, and
+ * <code>“RadioButton.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.RadioButtonBorder-1.png" width="300"
+ * height="135" alt="[A screen shot of the returned border]" />
+ *
+ * @return a {@link
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link RadioButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
+ */
+ public static Border getRadioButtonBorder()
+ {
+ Border outer;
+
+ /* The keys for UIDefaults have been determined by writing a
+ * test program that dumps the UIDefaults to stdout; that program
+ * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
+ * the key "light" is usually called "highlight", and "highlight"
+ * is usually called "lightHighlight".
+ */
+ outer = new RadioButtonBorder(
+ UIManager.getColor("RadioButton.shadow"),
+ UIManager.getColor("RadioButton.darkShadow"),
+ UIManager.getColor("RadioButton.light"),
+ UIManager.getColor("RadioButton.highlight"));
+
+ /* While the inner border is shared between multiple buttons, we
+ * do not share the outer border because RadioButtonBorders, being
+ * ButtonBorders, store their border colors. We cannot guarantee
+ * that the colors (which come from UIDefaults) are unchanged
+ * between invocations of getButtonBorder. We could store the last
+ * colors, and share the button border if the colors are the same
+ * as in the last invocation, but it probably is not worth the
+ * effort.
+ */
+ return new BorderUIResource.CompoundBorderUIResource(
+ outer,
+ /* inner */ getMarginBorder());
+ }
+
+
+ /**
+ * Returns a border for drawing toggle buttons.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“ToggleButton.shadow”</code>,
+ * <code>“ToggleButton.darkShadow”</code>,
+ * <code>“ToggleButton.light”</code>, and
+ * <code>“ToggleButton.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.ToggleButtonBorder-1.png" width="270"
+ * height="135" alt="[A screen shot of the returned border]" />
+ *
+ * @return a {@link
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link ToggleButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
+ */
+ public static Border getToggleButtonBorder()
+ {
+ Border outer;
+
+ /* The keys for UIDefaults have been determined by writing a
+ * test program that dumps the UIDefaults to stdout; that program
+ * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
+ * the key "light" is usually called "highlight", and "highlight"
+ * is usually called "lightHighlight".
+ */
+ outer = new ToggleButtonBorder(
+ UIManager.getColor("ToggleButton.shadow"),
+ UIManager.getColor("ToggleButton.darkShadow"),
+ UIManager.getColor("ToggleButton.light"),
+ UIManager.getColor("ToggleButton.highlight"));
+
+ /* While the inner border is shared between multiple buttons, we
+ * do not share the outer border because ToggleButtonBorders, being
+ * ButtonBorders, store their border colors. We cannot guarantee
+ * that the colors (which come from UIDefaults) are unchanged
+ * between invocations of getButtonBorder. We could store the last
+ * colors, and share the button border if the colors are the same
+ * as in the last invocation, but it probably is not worth the
+ * effort.
+ */
+ return new BorderUIResource.CompoundBorderUIResource(
+ outer,
+ /* inner */ getMarginBorder());
+ }
+
+
+ /**
+ * Returns a border for drawing a two-pixel thick separator line
+ * below menu bars.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“MenuBar.shadow”</code> and
+ * <code>“MenuBar.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.MenuBarBorder-1.png" width="500"
+ * height="140" alt="[A screen shot of a JMenuBar with this border]" />
+ *
+ * @return a {@link MenuBarBorder}.
+ *
+ * @see javax.swing.JMenuBar
+ */
+ public static Border getMenuBarBorder()
+ {
+ /* See comment in methods above for why this border is not shared. */
+ return new MenuBarBorder(UIManager.getColor("MenuBar.shadow"),
+ UIManager.getColor("MenuBar.highlight"));
+ }
+
+
+ /**
+ * Returns a border for drawing a one-pixel thick border around
+ * split panes that are interrupted where the divider joins the
+ * border.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“SplitPane.darkShadow”</code> and
+ * <code>“SplitPane.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * @return a {@link SplitPaneBorder}.
+ *
+ * @see javax.swing.JSplitPane
+ * @see #getSplitPaneDividerBorder()
+ */
+ public static Border getSplitPaneBorder()
+ {
+ /* See comment in methods above for why this border is not shared. */
+ return new SplitPaneBorder(UIManager.getColor("SplitPane.highlight"),
+ UIManager.getColor("SplitPane.darkShadow"));
+ }
+
+
+ /**
+ * Returns a border for drawing a one-pixel thick border around
+ * the divider of split panes.
+ *
+ * <p>The colors of the edges that are adjacent to the child components
+ * of the <code>JSplitPane</code> are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“SplitPane.darkShadow”</code> and
+ * <code>“SplitPane.highlight”</code>. The color of the
+ * other two edges is the background color of the divider.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneDividerBorder-1.png"
+ * width="520" height="200" alt=
+ * "[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * @return an instance of <code>SplitPaneDividerBorder</code>, which is
+ * not a public API class of this package.
+ *
+ * @see javax.swing.JSplitPane
+ * @see javax.swing.plaf.basic.BasicSplitPaneDivider
+ * @see #getSplitPaneBorder()
+ *
+ * @since 1.3
+ */
+ public static Border getSplitPaneDividerBorder()
+ {
+ /* See comment in methods above for why this border is not shared. */
+ return new SplitPaneDividerBorder();
+ }
+
+
+ /**
+ * Returns a border for drawing a border around a text field
+ * that makes the field appear as etched into the surface.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“TextField.shadow”</code>,
+ * <code>“TextField.darkShadow”</code>,
+ * <code>“TextField.light”</code>, and
+ * <code>“TextField.highlight”</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.FieldBorder-1.png" width="500"
+ * height="200" alt="[A screen shot of a border returned by
+ * this method]" />
+ *
+ * @return an instance of {@link FieldBorder}.
+ *
+ * @see javax.swing.JTextField
+ * @see javax.swing.text.JTextComponent
+ */
+ public static Border getTextFieldBorder()
+ {
+ /* See comment in methods above for why this border is not shared. */
+ return new FieldBorder(
+ UIManager.getColor("TextField.shadow"),
+ UIManager.getColor("TextField.darkShadow"),
+ UIManager.getColor("TextField.light"),
+ UIManager.getColor("TextField.highlight"));
+ }
+
+
+ /**
+ * Returns a two-pixel thick, green
+ * <code>LineBorderUIResource</code>. This is so ugly that look and
+ * feels better use different borders for their progress bars, or
+ * they will look really terrible.
+ *
+ * <p><img src="doc-files/BasicBorders-1.png" width="120" height="80"
+ * alt="[A screen shot of a border returned by this method]" />
+ */
+ public static Border getProgressBarBorder()
+ {
+ /* There does not seem to exist a way to parametrize the color
+ * or thickness of the border through UIDefaults.
+ */
+ return new BorderUIResource.LineBorderUIResource(Color.green, 2);
+ }
+
+
+ /**
+ * Returns a border that is composed of a raised bevel border and a
+ * one-pixel thick line border.
+ *
+ * <p><img src="doc-files/BasicBorders-2.png" width="300" height="200"
+ * alt="[A screen shot of a border returned by this method]" />
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“InternalFrame.borderShadow”</code>,
+ * <code>“InternalFrame.borderDarkShadow”</code>,
+ * <code>“InternalFrame.borderLight”</code>,
+ * <code>“InternalFrame.borderHighlight”</code>, and
+ * (for the inner one-pixel thick line)
+ * <code>“InternalFrame.borderColor”</code>.
+ */
+ public static Border getInternalFrameBorder()
+ {
+ Color shadow, darkShadow, highlight, lightHighlight, line;
+
+ /* See comment in methods above for why this border is not shared. */
+ shadow = UIManager.getColor("InternalFrame.borderShadow");
+ darkShadow = UIManager.getColor("InternalFrame.borderDarkShadow");
+ highlight = UIManager.getColor("InternalFrame.borderLight");
+ lightHighlight = UIManager.getColor("InternalFrame.borderHighlight");
+ line = UIManager.getColor("InternalFrame.borderColor");
+
+ return new BorderUIResource.CompoundBorderUIResource(
+ /* outer border */
+ new BorderUIResource.BevelBorderUIResource(
+ BevelBorder.RAISED,
+ (highlight != null) ? highlight : Color.lightGray,
+ (lightHighlight != null) ? lightHighlight : Color.white,
+ (darkShadow != null) ? darkShadow : Color.black,
+ (shadow != null) ? shadow : Color.gray),
+
+ /* inner border */
+ new BorderUIResource.LineBorderUIResource(
+ (line != null) ? line : Color.lightGray));
+ }
+
+
+ /**
+ * Returns a shared MarginBorder.
+ */
+ static Border getMarginBorder() // intentionally not public
+ {
+ /* Swing is not designed to be thread-safe, so there is no
+ * need to synchronize the access to the global variable.
+ */
+ if (sharedMarginBorder == null)
+ sharedMarginBorder = new MarginBorder();
+
+ return sharedMarginBorder;
+ }
+
+
+ /**
+ * A border whose appearance depends on the state of
+ * the enclosed button.
+ *
+ * <p><img src="doc-files/BasicBorders.ButtonBorder-1.png" width="300"
+ * height="170" alt="[A screen shot of this border]" />
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class ButtonBorder
+ extends AbstractBorder
+ implements Serializable, UIResource
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = -157053874580739687L;
+
+
+ /**
+ * The color for drawing the shaded parts of the border.
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ protected Color shadow;
+
+
+ /**
+ * The color for drawing the dark shaded parts of the border.
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ protected Color darkShadow;
+
+
+ /**
+ * The color for drawing the highlighted parts of the border.
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ protected Color highlight;
+
+
+ /**
+ * The color for drawing the bright highlighted parts of the border.
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ protected Color lightHighlight;
+
+
+ /**
+ * Constructs a new border for drawing a button in the Basic
+ * look and feel.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public ButtonBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.gray;
+ this.darkShadow = (darkShadow != null) ? darkShadow : Color.black;
+ this.highlight = (highlight != null) ? highlight : Color.lightGray;
+ this.lightHighlight = (lightHighlight != null)
+ ? lightHighlight
+ : Color.white;
+ }
+
+
+ /**
+ * Paints the ButtonBorder around a given component.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ ButtonModel bmodel = null;
+
+ if (c instanceof AbstractButton)
+ bmodel = ((AbstractButton) c).getModel();
+
+ BasicGraphicsUtils.drawBezel(
+ g, x, y, width, height,
+ /* pressed */ (bmodel != null)
+ && /* mouse button pressed */ bmodel.isPressed()
+ && /* mouse inside */ bmodel.isArmed(),
+ /* default */ (c instanceof JButton)
+ && ((JButton) c).isDefaultButton(),
+ shadow, darkShadow, highlight, lightHighlight);
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * <p>Although the thickness of the actually painted border
+ * depends on the state of the enclosed component, this
+ * measurement always returns the same amount of pixels. Indeed,
+ * it would be rather confusing if a button was appearing to
+ * change its size depending on whether it is pressed or not.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ /* There is no obvious reason for overriding this method, but we
+ * try to have exactly the same API as the Sun reference
+ * implementation.
+ */
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * <p>Although the thickness of the actually painted border
+ * depends on the state of the enclosed component, this
+ * measurement always returns the same amount of pixels. Indeed,
+ * it would be rather confusing if a button was appearing to
+ * change its size depending on whether it is pressed or not.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets(Component)
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ /* The exact amount has been determined using a test program
+ * that was run on the Sun reference implementation. With
+ * Apple/Sun JDK 1.3.1 on MacOS X 10.1.5, the result is
+ * [3, 3, 3, 3]. With Sun JDK 1.4.1_01 on Linux/x86, the
+ * result is [2, 3, 3, 3]. We use the values from the 1.4.1_01
+ * release.
+ */
+ if (insets == null)
+ return new Insets(2, 3, 3, 3);
+
+ insets.top = 2;
+ insets.bottom = insets.left = insets.right = 3;
+ return insets;
+ }
+ }
+
+
+ /**
+ * A border that makes its enclosed component appear as lowered
+ * into the surface. Typically used for text fields.
+ *
+ * <p><img src="doc-files/BasicBorders.FieldBorder-1.png" width="500"
+ * height="200" alt="[A screen shot of this border]" />
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class FieldBorder
+ extends AbstractBorder
+ implements UIResource
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = 949220756998454908L;
+
+
+ /**
+ * The color for drawing the outer half of the top and left
+ * edges.
+ */
+ protected Color shadow;
+
+
+ /**
+ * The color for drawing the inner half of the top and left
+ * edges.
+ */
+ protected Color darkShadow;
+
+
+ /**
+ * The color for drawing the inner half of the bottom and right
+ * edges.
+ */
+ protected Color highlight;
+
+
+ /**
+ * The color for drawing the outer half of the bottom and right
+ * edges.
+ */
+ protected Color lightHighlight;
+
+
+ /**
+ * Constructs a new border for drawing a text field in the Basic
+ * look and feel.
+ *
+ * @param shadow the color for drawing the outer half
+ * of the top and left edges.
+ *
+ * @param darkShadow the color for drawing the inner half
+ * of the top and left edges.
+ *
+ * @param highlight the color for drawing the inner half
+ * of the bottom and right edges.
+ *
+ * @param lightHighlight the color for drawing the outer half
+ * of the bottom and right edges.
+ */
+ public FieldBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.gray;
+ this.darkShadow = (darkShadow != null) ? darkShadow : Color.black;
+ this.highlight = (highlight != null) ? highlight : Color.lightGray;
+ this.lightHighlight = (lightHighlight != null)
+ ? lightHighlight : Color.white;
+ }
+
+
+ /**
+ * Paints the FieldBorder around a given component.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ BasicGraphicsUtils.drawEtchedRect(g, x, y, width, height,
+ shadow, darkShadow,
+ highlight, lightHighlight);
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ * If <code>c</code> is an instance of {@link
+ * javax.swing.text.JTextComponent}, its margin is
+ * added to the border size.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * @param c the component whose border is to be measured.
+ * If <code>c</code> is an instance of {@link
+ * javax.swing.text.JTextComponent}, its margin is
+ * added to the border size.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets(Component)
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ if (insets == null)
+ insets = new Insets(2, 2, 2, 2);
+ else
+ insets.top = insets.left = insets.bottom = insets.right = 2;
+
+ if (c instanceof JTextComponent)
+ {
+ Insets margin = ((JTextComponent) c).getMargin();
+ insets.top += margin.top;
+ insets.left += margin.left;
+ insets.bottom += margin.bottom;
+ insets.right += margin.right;
+ }
+
+ return insets;
+ }
+ }
+
+
+ /**
+ * An invisible, but spacing border whose margin is determined
+ * by calling the <code>getMargin()</code> method of the enclosed
+ * component. If the enclosed component has no such method,
+ * this border will not occupy any space.
+ *
+ * <p><img src="doc-files/BasicBorders.MarginBorder-1.png" width="325"
+ * height="200" alt="[An illustration that shows how MarginBorder
+ * determines its borders]" />
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class MarginBorder
+ extends AbstractBorder
+ implements Serializable, UIResource
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = -3035848353448896090L;
+
+
+ /**
+ * Constructs a new MarginBorder.
+ */
+ public MarginBorder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>, <code>right</code>,
+ * <code>top</code> and <code>bottom</code> fields indicate the
+ * width of the border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, new Insets(0, 0, 0, 0));
+ }
+
+
+ /**
+ * Determines the insets of this border by calling the
+ * <code>getMargin()</code> method of the enclosed component. The
+ * resulting margin will be stored into the the <code>left</code>,
+ * <code>right</code>, <code>top</code> and <code>bottom</code>
+ * fields of the passed <code>insets</code> parameter.
+ *
+ * <p>Unfortunately, <code>getMargin()</code> is not a method of
+ * {@link javax.swing.JComponent} or some other common superclass
+ * of things with margins. While reflection could be used to
+ * determine the existence of this method, this would be slow on
+ * many virtual machines. Therefore, the current implementation
+ * knows about {@link javax.swing.AbstractButton#getMargin()},
+ * {@link javax.swing.JPopupMenu#getMargin()}, {@link
+ * javax.swing.JToolBar#getMargin()}, and {@link
+ * javax.swing.text.JTextComponent}. If <code>c</code> is an
+ * instance of a known class, the respective
+ * <code>getMargin()</code> method is called to determine the
+ * correct margin. Otherwise, a zero-width margin is returned.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return the same object that was passed for <code>insets</code>,
+ * but with changed fields.
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ Insets margin = null;
+
+ /* This is terrible object-oriented design. See the above Javadoc
+ * for an excuse.
+ */
+ if (c instanceof AbstractButton)
+ margin = ((AbstractButton) c).getMargin();
+ else if (c instanceof JPopupMenu)
+ margin = ((JPopupMenu) c).getMargin();
+ else if (c instanceof JToolBar)
+ margin = ((JToolBar) c).getMargin();
+ else if (c instanceof JTextComponent)
+ margin = ((JTextComponent) c).getMargin();
+
+ if (margin == null)
+ insets.top = insets.left = insets.bottom = insets.right = 0;
+ else
+ {
+ insets.top = margin.top;
+ insets.left = margin.left;
+ insets.bottom = margin.bottom;
+ insets.right = margin.right;
+ }
+
+ return insets;
+ }
+ }
+
+
+ /**
+ * A border for drawing a separator line below JMenuBar.
+ *
+ * <p><img src="doc-files/BasicBorders.MenuBarBorder-1.png" width="500"
+ * height="140" alt="[A screen shot of a JMenuBar with this border]" />
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class MenuBarBorder
+ extends AbstractBorder
+ implements UIResource
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = -6909056571935227506L;
+
+
+ /**
+ * The shadow color, which is used for the upper line of the
+ * two-pixel thick bottom edge.
+ */
+ private Color shadow;
+
+
+ /**
+ * The highlight color, which is used for the lower line of the
+ * two-pixel thick bottom edge.
+ */
+ private Color highlight;
+
+
+ /**
+ * Constructs a new MenuBarBorder for drawing a JMenuBar in
+ * the Basic look and feel.
+ *
+ * <p><img src="doc-files/BasicBorders.MenuBarBorder-1.png" width="500"
+ * height="140" alt="[A screen shot of a JMenuBar with this
+ * border]" />
+ *
+ * @param shadow the shadow color, which is used for the upper
+ * line of the two-pixel thick bottom edge.
+ *
+ * @param highlight the shadow color, which is used for the lower
+ * line of the two-pixel thick bottom edge.
+ */
+ public MenuBarBorder(Color shadow, Color highlight)
+ {
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.gray;
+ this.highlight = (highlight != null) ? highlight : Color.white;
+ }
+
+
+ /**
+ * Paints the MenuBarBorder around a given component.
+ *
+ * @param c the component whose border is to be painted, usually
+ * an instance of {@link javax.swing.JMenuBar}.
+ *
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ Color oldColor;
+
+ /* To understand this code, it might be helpful to look at the
+ * image "BasicBorders.MenuBarBorder-1.png" that is included
+ * with the JavaDoc. It is located in the "doc-files"
+ * subdirectory.
+ */
+ oldColor = g.getColor();
+ y = y + height - 2;
+ try
+ {
+ g.setColor(shadow);
+ g.drawLine(x, y, x + width - 2, y);
+ g.drawLine(x, y + 1, x, y + 1);
+ g.drawLine(x + width - 2, y + 1, x + width - 2, y + 1);
+
+ g.setColor(highlight);
+ g.drawLine(x + 1, y + 1, x + width - 3, y + 1);
+ g.drawLine(x + width - 1, y, x + width - 1, y + 1);
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ /* There is no obvious reason for overriding this method, but we
+ * try to have exactly the same API as the Sun reference
+ * implementation.
+ */
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets(Component)
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ /* The exact amount has been determined using a test program
+ * that was run on the Apple/Sun JDK 1.3.1 on MacOS X, and the
+ * Sun JDK 1.4.1_01 on GNU/Linux for x86. Both gave [0,0,2,0],
+ * which was expected from looking at the screen shot.
+ */
+ if (insets == null)
+ return new Insets(0, 0, 2, 0);
+
+ insets.left = insets.right = insets.top = 0;
+ insets.bottom = 2;
+ return insets;
+ }
+ }
+
+
+ /**
+ * A border for drawing radio buttons in the Basic look and feel.
+ *
+ * <p><img src="doc-files/BasicBorders.RadioButtonBorder-1.png" width="300"
+ * height="135" alt="[A screen shot of this border]" />
+ *
+ * <p>Note about the screen shot: Normally, the
+ * <code>borderPainted</code> property is <code>false</code> for
+ * JRadioButtons. For this screen shot, it has been set to
+ * <code>true</code> so the borders get drawn. Also, a
+ * concretization of the Basic look and would typically provide
+ * icons for the various states of radio buttons.
+ *
+ * <p>Note that the focus rectangle is invisible If the radio button
+ * is currently selected. While it might be debatable whether this
+ * makes a lot of sense, this behavior can be observed in the Sun
+ * reference implementation (in JDK 1.3.1 and 1.4.1). The Classpath
+ * implementation tries to exactly replicate the JDK appearance.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class RadioButtonBorder
+ extends ButtonBorder
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = 1596945751743747369L;
+
+
+ /**
+ * Constructs a new border for drawing a JRadioButton in
+ * the Basic look and feel.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public RadioButtonBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ /* The superclass ButtonBorder substitutes null arguments
+ * with fallback colors.
+ */
+ super(shadow, darkShadow, highlight, lightHighlight);
+ }
+
+
+ /**
+ * Paints the RadioButtonBorder around a given component.
+ *
+ * <p>The Sun implementation always seems to draw exactly
+ * the same border, irrespective of the state of the button.
+ * This is rather surprising, but GNU Classpath emulates the
+ * observable behavior.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ AbstractButton button = null;
+ ButtonModel bmodel = null;
+ boolean lowered = false;
+ boolean focused = false;
+
+ if (c instanceof AbstractButton)
+ {
+ button = (AbstractButton) c;
+ bmodel = button.getModel();
+ }
+
+ if (bmodel != null)
+ {
+ lowered = button.isSelected()
+ || (/* mouse inside */ bmodel.isArmed() && bmodel.isPressed());
+ focused = button.hasFocus() && button.isFocusPainted();
+ }
+
+ if (lowered)
+ BasicGraphicsUtils.drawLoweredBezel(g, x, y, width, height,
+ shadow, darkShadow,
+ highlight, lightHighlight);
+ else
+ BasicGraphicsUtils.drawBezel(g, x, y, width, height,
+ /* isPressed */ false,
+ /* isPefault */ focused,
+ shadow, darkShadow,
+ highlight, lightHighlight);
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ /* There is no obvious reason for overriding this method, but we
+ * try to have exactly the same API as the Sun reference
+ * implementation.
+ */
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets(Component)
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ /* The exact amount has been determined using a test program
+ * that was run on the Apple/Sun JDK 1.3.1 on MacOS X, and the
+ * Sun JDK 1.4.1_01 on GNU/Linux for x86. Both gave [2,2,2,2].
+ */
+ if (insets == null)
+ return new Insets(2, 2, 2, 2);
+
+ insets.left = insets.right = insets.top = insets.bottom = 2;
+ return insets;
+ }
+ }
+
+
+ /**
+ * A one-pixel thick border for rollover buttons, for example in
+ * tool bars.
+ *
+ * @since 1.4
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class RolloverButtonBorder
+ extends ButtonBorder
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Sun JDK 1.4.1_01 on GNU/Linux 2.4.20 for x86.
+ */
+ static final long serialVersionUID = 1976364864896996846L;
+
+
+ /**
+ * Constructs a new border for drawing a roll-over button
+ * in the Basic look and feel.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public RolloverButtonBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ super(shadow, darkShadow, highlight, lightHighlight);
+ }
+
+
+ /**
+ * Paints the border around a rollover button. If <code>c</code>
+ * is not an {@link javax.swing.AbstractButton} whose model
+ * returns <code>true</code> for {@link
+ * javax.swing.ButtonModel#isRollover}, nothing gets painted at
+ * all.
+ *
+ * @param c the button whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ ButtonModel bmodel = null;
+ boolean drawPressed;
+ Color oldColor = g.getColor();
+ int x2, y2;
+
+ if (c instanceof AbstractButton)
+ bmodel = ((AbstractButton) c).getModel();
+
+ /* Draw nothing if c is not a rollover button. */
+ if ((bmodel == null) || !bmodel.isRollover())
+ return;
+
+ /* Draw nothing if the mouse is pressed, but outside the button. */
+ if (bmodel.isPressed() && !bmodel.isArmed())
+ return;
+
+ drawPressed = bmodel.isSelected() || bmodel.isPressed();
+ x2 = x + width - 1;
+ y2 = y + height - 1;
+
+ try
+ {
+ g.setColor(drawPressed ? shadow : lightHighlight);
+ g.drawLine(x, y, x2 - 1, y); // top edge
+ g.drawLine(x, y + 1, x, y2 - 1); // left edge
+
+ g.setColor(drawPressed ? lightHighlight : shadow);
+ g.drawLine(x, y2, x2, y2); // bottom edge
+ g.drawLine(x2, y, x2, y2 - 1); // right edge
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+ }
+
+
+ /**
+ * A border for JSplitPanes in the Basic look and feel. The divider
+ * in the middle of the JSplitPane has its own border class, of which
+ * an instance can be obtained with {@link #getSplitPaneDividerBorder()}.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * <p>In contrast to the other borders of the Basic look and feel,
+ * this class is not serializable. While this might be unintended,
+ * GNU Classpath follows the specification in order to be fully
+ * compatible with the Sun reference implementation.
+ *
+ * <p>In the Sun JDK, the bottom edge of the divider also gets
+ * painted if the orientation of the enclosed JSplitPane is
+ * <code>JSplitPane.VERTICAL_SPLIT</code> (at least in versions
+ * 1.3.1 and 1.4.1). GNU Classpath does not replicate this bug. A
+ * report has been filed with Sun (bug ID 4885629).
+ *
+ * <p>Note that the bottom left pixel of the border has a different
+ * color depending on the orientation of the enclosed JSplitPane.
+ * Although this is visually inconsistent, Classpath replicates the
+ * appearance of the Sun reference implementation. A bug report has
+ * been filed with Sun (review ID 188774).
+ *
+ * @see #getSplitPaneBorder()
+ * @see #getSplitPaneDividerBorder()
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class SplitPaneBorder implements Border, UIResource
+ {
+ /**
+ * Indicates that the top edge shall be not be painted
+ * by {@link #paintRect}.
+ */
+ private static final int SUPPRESS_TOP = 1;
+
+
+ /**
+ * Indicates that the left edge shall be not be painted
+ * by {@link #paintRect}.
+ */
+ private static final int SUPPRESS_LEFT = 2;
+
+
+ /**
+ * Indicates that the bottom edge shall be not be painted
+ * by {@link #paintRect}.
+ */
+ private static final int SUPPRESS_BOTTOM = 4;
+
+
+ /**
+ * Indicates that the right edge shall be not be painted
+ * by {@link #paintRect}.
+ */
+ private static final int SUPPRESS_RIGHT = 8;
+
+
+ /**
+ * The color for drawing the bottom and right edges of the border.
+ */
+ protected Color highlight;
+
+
+ /**
+ * The color for drawing the top and left edges of the border.
+ */
+ protected Color shadow;
+
+
+ /**
+ * Constructs a new border for drawing a JSplitPane in the Basic
+ * look and feel. The divider in the middle of the JSplitPane has
+ * its own border class, <code>SplitPaneDividerBorder</code>.
+ *
+ * @param shadow the shadow color.
+ * @param highlight the highlight color.
+ */
+ public SplitPaneBorder(Color highlight, Color shadow)
+ {
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.black;
+ this.highlight = (highlight != null) ? highlight : Color.white;
+ }
+
+
+ /**
+ * Paints the border around a <code>JSplitPane</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * @param c the <code>JSplitPane</code> whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ JSplitPane splitPane;
+ Component content;
+
+ if (!(c instanceof JSplitPane))
+ return;
+
+ splitPane = (JSplitPane) c;
+ switch (splitPane.getOrientation())
+ {
+ case JSplitPane.HORIZONTAL_SPLIT:
+ if ((content = splitPane.getLeftComponent()) != null)
+ paintRect(g, SUPPRESS_RIGHT, true, x, y, content.getBounds());
+ if ((content = splitPane.getRightComponent()) != null)
+ paintRect(g, SUPPRESS_LEFT, true, x, y, content.getBounds());
+ break;
+
+ case JSplitPane.VERTICAL_SPLIT:
+ if ((content = splitPane.getTopComponent()) != null)
+ paintRect(g, SUPPRESS_BOTTOM, false, x, y, content.getBounds());
+ if ((content = splitPane.getBottomComponent()) != null)
+ paintRect(g, SUPPRESS_TOP, false, x, y, content.getBounds());
+ break;
+ }
+ }
+
+
+ /**
+ * Paints a border around a child of a <code>JSplitPane</code>,
+ * omitting some of the edges.
+ *
+ * @param g the graphics for painting.
+ *
+ * @param suppress a bit mask indicating the set of suppressed
+ * edges, for example <code>SUPPRESS_TOP | SUPPRESS_RIGHT</code>.
+ *
+ * @param x the x coordinate of the SplitPaneBorder.
+ *
+ * @param y the y coordinate of the SplitPaneBorder.
+ *
+ * @param shadeBottomLeftPixel <code>true</code> to paint the
+ * bottom left pixel in the shadow color,
+ * <code>false</code> for the highlight color. The Basic
+ * look and feel uses the highlight color for the bottom
+ * left pixel of the border of a JSplitPane whose
+ * orientation is VERTICAL_SPLIT, and the shadow color
+ * otherwise. While this might be a strange distinction,
+ * Classpath tries to look identical to the reference
+ * implementation. A bug report has been filed with Sun;
+ * its review ID is 188774. We currently replicate the
+ * Sun behavior.
+ *
+ * @param rect the bounds of the child of JSplitPane whose
+ * border is to be painted.
+ */
+ private void paintRect(Graphics g, int suppress,
+ boolean shadeBottomLeftPixel,
+ int x, int y,
+ Rectangle rect)
+ {
+ if (rect == null)
+ return;
+
+ /* On each edge, the border exceeds the enclosed child by one
+ * pixel. See the image "BasicBorders.SplitPaneBorder-1.png" in
+ * the directory "doc-files".
+ */
+ x += rect.x - 1;
+ y += rect.y - 1;
+ int right = x + rect.width + 1;
+ int bottom = y + rect.height + 1;
+
+ Color oldColor = g.getColor();
+ try
+ {
+ g.setColor(shadow);
+ if ((suppress & SUPPRESS_TOP) == 0)
+ g.drawLine(x, y, right, y);
+ if ((suppress & SUPPRESS_LEFT) == 0)
+ g.drawLine(x, y, x, bottom);
+ else
+ g.drawLine(x, bottom, x, bottom); // one pixel
+
+ g.setColor(highlight);
+ if ((suppress & SUPPRESS_BOTTOM) == 0)
+ g.drawLine(x + (shadeBottomLeftPixel ? 1 : 0), bottom, right, bottom);
+ else if (!shadeBottomLeftPixel)
+ g.drawLine(x, bottom, x, bottom); // one pixel
+
+ if ((suppress & SUPPRESS_RIGHT) == 0)
+ g.drawLine(right, y, right, bottom);
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured, usually
+ * an instance of {@link javax.swing.JSplitPane}.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(1, 1, 1, 1);
+ }
+
+
+ /**
+ * Determines whether this border fills every pixel in its area
+ * when painting.
+ *
+ * @return <code>false</code> because this border does not
+ * paint over the pixels where the divider joins
+ * the border.
+ */
+ public boolean isBorderOpaque()
+ {
+ /* Strangely, the Sun implementation (tested with JDK 1.3.1 and
+ * 1.4.1_01) seems to always return true. It could be a bug,
+ * but without knowing the details of their implementation, it is
+ * hard to decide.
+ */
+ return false;
+ }
+ }
+
+
+ /**
+ * A border for the divider inside a JSplitPane.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneDividerBorder-1.png"
+ * width="520" height="200" alt="[A screen shot of this border]" />
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ private static class SplitPaneDividerBorder
+ implements Border, UIResource, Serializable
+ {
+ /**
+ * Constructs a new border for drawing the divider of a JSplitPane
+ * in the Basic look and feel. The outer parts of the JSplitPane have
+ * their own border class, <code>SplitPaneBorder</code>.
+ */
+ public SplitPaneDividerBorder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border around the divider of a <code>JSplitPane</code>.
+ *
+ * <p><img src="doc-files/BasicBorders.SplitPaneDividerBorder-1.png"
+ * width="520" height="200" alt="[A picture that shows which pixels
+ * get painted in what color]" />
+ *
+ * @param c the <code>JSplitPane</code> whose divider’s border
+ * is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ Color highlight = UIManager.getColor("SplitPane.highlight");
+ Color shadow = UIManager.getColor("SplitPane.shadow");
+ Color oldColor, dcol;
+ int x2, y2;
+ JSplitPane sp;
+
+ sp = getSplitPane(c);
+ if (sp == null)
+ return;
+
+ x2 = x + width - 1;
+ y2 = y + height - 1;
+ oldColor = g.getColor();
+ dcol = c.getBackground();
+ try
+ {
+ switch (sp.getOrientation())
+ {
+ case JSplitPane.HORIZONTAL_SPLIT:
+ g.setColor(dcol);
+ g.drawLine(x + 1, y, x2 - 1, y);
+ g.drawLine(x + 1, y2, x2 - 1, y2);
+ g.setColor(sp.getLeftComponent() != null ? highlight : dcol);
+ g.drawLine(x, y, x, y2);
+ g.setColor(sp.getRightComponent() != null ? shadow : dcol);
+ g.drawLine(x2, y, x2, y2);
+ break;
+
+ case JSplitPane.VERTICAL_SPLIT:
+ g.setColor(dcol);
+ g.drawLine(x, y + 1, x, y2 - 1);
+ g.drawLine(x2, y + 1, x2, y2 - 1);
+ g.setColor(sp.getTopComponent() != null ? highlight : dcol);
+ g.drawLine(x, y, x2, y);
+ g.setColor(sp.getBottomComponent() != null ? shadow : dcol);
+ g.drawLine(x, y2, x2, y2);
+ break;
+ }
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured, usually
+ * an instance of {@link javax.swing.JSplitPane}.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(1, 1, 1, 1);
+ }
+
+ /**
+ * Determines whether this border fills every pixel in its area
+ * when painting.
+ *
+ * @return <code>true</code>
+ */
+ public boolean isBorderOpaque()
+ {
+ return true;
+ }
+
+
+ /**
+ * Determines the JSplitPane whose divider is being painted.
+ *
+ * @param c an instance of BasicSplitPaneDivider.
+ *
+ * @return a <code>JSplitPane</code>, or <code>null</code> if
+ * <code>c</code> is not an instance of {@link
+ * javax.swing.plaf.basic.BasicSplitPaneDivider}.
+ */
+ private JSplitPane getSplitPane(Component c)
+ {
+ if (c instanceof BasicSplitPaneDivider)
+ return (((BasicSplitPaneDivider) c).getBasicSplitPaneUI())
+ .getSplitPane();
+ else
+ return null;
+ }
+ }
+
+
+ /**
+ * A border for toggle buttons in the Basic look and feel.
+ *
+ * <p><img src="doc-files/BasicBorders.ToggleButtonBorder-1.png"
+ * width="270" height="135" alt="[A screen shot of this border]" />
+ *
+ * <p>The Sun implementation always seems to draw exactly
+ * the same border, irrespective of the state of the button.
+ * This is rather surprising, but GNU Classpath emulates the
+ * observable behavior.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+ public static class ToggleButtonBorder
+ extends ButtonBorder
+ {
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = -3528666548001058394L;
+
+
+ /**
+ * Constructs a new border for drawing a JToggleButton in
+ * the Basic look and feel.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public ToggleButtonBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ /* The superclass ButtonBorder substitutes null arguments
+ * with fallback colors.
+ */
+ super(shadow, darkShadow, highlight, lightHighlight);
+ }
+
+
+ /**
+ * Paints the ToggleButtonBorder around a given component.
+ *
+ * <p>The Sun implementation always seems to draw exactly
+ * the same border, irrespective of the state of the button.
+ * This is rather surprising, but GNU Classpath emulates the
+ * observable behavior.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ /* The author of this code tried various variants for setting
+ * the state of the enclosed JToggleButton, but it seems that
+ * the drawn border is always identical. Weird, because this
+ * means that the user does not see whether the JToggleButton
+ * is selected or not.
+ */
+ BasicGraphicsUtils.drawBezel(g, x, y, width, height,
+ /* pressed */ false,
+ /* default */ false,
+ shadow, darkShadow,
+ highlight, lightHighlight);
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ /* There is no obvious reason for overriding this method, but we
+ * try to have exactly the same API as the Sun reference
+ * implementation.
+ */
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets(Component)
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ /* The exact amount has been determined using a test program
+ * that was run on the Apple/Sun JDK 1.3.1 on MacOS X, and the
+ * Sun JDK 1.4.1_01 on GNU/Linux for x86. Both gave [2,2,2,2].
+ */
+ if (insets == null)
+ return new Insets(2, 2, 2, 2);
+
+ insets.left = insets.right = insets.top = insets.bottom = 2;
+ return insets;
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,258 @@
+/* BasicButtonListener.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import gnu.classpath.SystemProperties;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class BasicButtonListener implements MouseListener, MouseMotionListener,
+ FocusListener, ChangeListener, PropertyChangeListener
+{
+ public BasicButtonListener(AbstractButton b)
+ {
+ // Do nothing here.
+ }
+
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ // Store the TextLayout for this in a client property for speed-up
+ // painting of the label.
+ String property = e.getPropertyName();
+ if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+ || property.equals("font"))
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+ == null)
+ {
+ AbstractButton b = (AbstractButton) e.getSource();
+ String text = b.getText();
+ if (text == null)
+ text = "";
+ FontRenderContext frc = new FontRenderContext(new AffineTransform(),
+ false, false);
+ TextLayout layout = new TextLayout(text, b.getFont(), frc);
+ b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
+ }
+ }
+
+ protected void checkOpacity(AbstractButton b)
+ {
+ // TODO: What should be done here?
+ }
+
+ public void focusGained(FocusEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ if (button.isFocusPainted())
+ button.repaint();
+ }
+ }
+
+ public void focusLost(FocusEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ if (button.isFocusPainted())
+ button.repaint();
+ }
+ }
+
+ public void installKeyboardActions(JComponent c)
+ {
+ c.getActionMap().put("pressed",
+ new AbstractAction()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ // It is important that these transitions happen in this order.
+ model.setArmed(true);
+ model.setPressed(true);
+ }
+ });
+
+ c.getActionMap().put("released",
+ new AbstractAction()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ // It is important that these transitions happen in this order.
+ model.setPressed(false);
+ model.setArmed(false);
+ }
+ });
+ }
+
+ public void uninstallKeyboardActions(JComponent c)
+ {
+ c.getActionMap().put("pressed", null);
+ c.getActionMap().put("released", null);
+ }
+
+ public void stateChanged(ChangeEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ public void mouseClicked(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Accept a mouse press event and arm the button.
+ *
+ * @param e The mouse press event to accept
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ if (SwingUtilities.isLeftMouseButton(e))
+ {
+ // It is important that these transitions happen in this order.
+ model.setArmed(true);
+ model.setPressed(true);
+
+ if (! button.isFocusOwner() && button.isRequestFocusEnabled())
+ button.requestFocus();
+ }
+ }
+ }
+
+ /**
+ * Accept a mouse release event and set the button's
+ * "pressed" property to <code>true</code>, if the model
+ * is armed. If the model is not armed, ignore the event.
+ *
+ * @param e The mouse release event to accept
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ if (e.getButton() == MouseEvent.BUTTON1)
+ {
+ // It is important that these transitions happen in this order.
+ model.setPressed(false);
+ model.setArmed(false);
+ }
+ }
+ }
+
+ /**
+ * Accept a mouse enter event and set the button's "rollover" property to
+ * <code>true</code>, if the button's "rolloverEnabled" property is
+ * <code>true</code>. If the button is currently armed and the mouse
+ * button is not held down, this enter event will also disarm the model.
+ *
+ * @param e The mouse enter event to accept
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ if (button.isRolloverEnabled()
+ && ! SwingUtilities.isLeftMouseButton(e))
+ model.setRollover(true);
+
+ if (model.isPressed())
+ model.setArmed(true);
+ }
+ }
+
+ /**
+ * Accept a mouse exit event and set the button's model's "rollover"
+ * property to <code>false</code>, if it's "rolloverEnabled" property is
+ * <code>true</code>. Also disarm the button.
+ *
+ * @param e The mouse exit event to accept
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ if (e.getSource() instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) e.getSource();
+ ButtonModel model = button.getModel();
+ if (button.isRolloverEnabled())
+ model.setRollover(false);
+ model.setArmed(false);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,458 @@
+/* BasicButtonUI.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
+import javax.swing.InputMap;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+
+/**
+ * A UI delegate for the {@link JButton} component.
+ */
+public class BasicButtonUI extends ButtonUI
+{
+ /**
+ * A constant used to pad out elements in the button's layout and
+ * preferred size calculations.
+ */
+ protected int defaultTextIconGap = 4;
+
+ /**
+ * A constant added to the defaultTextIconGap to adjust the text
+ * within this particular button.
+ */
+ protected int defaultTextShiftOffset;
+
+ private int textShiftOffset;
+
+ /**
+ * Factory method to create an instance of BasicButtonUI for a given
+ * {@link JComponent}, which should be an {@link AbstractButton}.
+ *
+ * @param c The component.
+ *
+ * @return A new UI capable of drawing the component
+ */
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicButtonUI();
+ }
+
+ /**
+ * Returns the default gap between the button's text and icon (in pixels).
+ *
+ * @param b the button (ignored).
+ *
+ * @return The gap.
+ */
+ public int getDefaultTextIconGap(AbstractButton b)
+ {
+ return defaultTextIconGap;
+ }
+
+ /**
+ * Sets the text shift offset to zero.
+ *
+ * @see #setTextShiftOffset()
+ */
+ protected void clearTextShiftOffset()
+ {
+ textShiftOffset = 0;
+ }
+
+ /**
+ * Returns the text shift offset.
+ *
+ * @return The text shift offset.
+ *
+ * @see #clearTextShiftOffset()
+ * @see #setTextShiftOffset()
+ */
+ protected int getTextShiftOffset()
+ {
+ return textShiftOffset;
+ }
+
+ /**
+ * Sets the text shift offset to the value in {@link #defaultTextShiftOffset}.
+ *
+ * @see #clearTextShiftOffset()
+ */
+ protected void setTextShiftOffset()
+ {
+ textShiftOffset = defaultTextShiftOffset;
+ }
+
+ /**
+ * Returns the prefix for the UI defaults property for this UI class.
+ * This is 'Button' for this class.
+ *
+ * @return the prefix for the UI defaults property
+ */
+ protected String getPropertyPrefix()
+ {
+ return "Button.";
+ }
+
+ /**
+ * Installs the default settings.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
+ protected void installDefaults(AbstractButton b)
+ {
+ String prefix = getPropertyPrefix();
+ LookAndFeel.installColorsAndFont(b, prefix + "background",
+ prefix + "foreground", prefix + "font");
+ LookAndFeel.installBorder(b, prefix + "border");
+ if (b.getMargin() == null || b.getMargin() instanceof UIResource)
+ b.setMargin(UIManager.getInsets(prefix + "margin"));
+ b.setIconTextGap(UIManager.getInt(prefix + "textIconGap"));
+ b.setInputMap(JComponent.WHEN_FOCUSED,
+ (InputMap) UIManager.get(prefix + "focusInputMap"));
+ }
+
+ /**
+ * Removes the defaults added by {@link #installDefaults(AbstractButton)}.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
+ protected void uninstallDefaults(AbstractButton b)
+ {
+ if (b.getFont() instanceof UIResource)
+ b.setFont(null);
+ if (b.getForeground() instanceof UIResource)
+ b.setForeground(null);
+ if (b.getBackground() instanceof UIResource)
+ b.setBackground(null);
+ if (b.getBorder() instanceof UIResource)
+ b.setBorder(null);
+ b.setIconTextGap(defaultTextIconGap);
+ if (b.getMargin() instanceof UIResource)
+ b.setMargin(null);
+ }
+
+ protected BasicButtonListener listener;
+
+ /**
+ * Creates and returns a new instance of {@link BasicButtonListener}. This
+ * method provides a hook to make it easy for subclasses to install a
+ * different listener.
+ *
+ * @param b the button.
+ *
+ * @return A new listener.
+ */
+ protected BasicButtonListener createButtonListener(AbstractButton b)
+ {
+ return new BasicButtonListener(b);
+ }
+
+ /**
+ * Installs listeners for the button.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
+ protected void installListeners(AbstractButton b)
+ {
+ listener = createButtonListener(b);
+ b.addChangeListener(listener);
+ b.addPropertyChangeListener(listener);
+ b.addFocusListener(listener);
+ b.addMouseListener(listener);
+ b.addMouseMotionListener(listener);
+ }
+
+ /**
+ * Uninstalls listeners for the button.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
+ protected void uninstallListeners(AbstractButton b)
+ {
+ b.removeChangeListener(listener);
+ b.removePropertyChangeListener(listener);
+ b.removeFocusListener(listener);
+ b.removeMouseListener(listener);
+ b.removeMouseMotionListener(listener);
+ }
+
+ protected void installKeyboardActions(AbstractButton b)
+ {
+ listener.installKeyboardActions(b);
+ }
+
+ protected void uninstallKeyboardActions(AbstractButton b)
+ {
+ listener.uninstallKeyboardActions(b);
+ }
+
+ /**
+ * Install the BasicButtonUI as the UI for a particular component.
+ * This means registering all the UI's listeners with the component,
+ * and setting any properties of the button which are particular to
+ * this look and feel.
+ *
+ * @param c The component to install the UI into
+ */
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof AbstractButton)
+ {
+ AbstractButton b = (AbstractButton) c;
+ installDefaults(b);
+ installListeners(b);
+ installKeyboardActions(b);
+ }
+ }
+
+ /**
+ * Calculate the preferred size of this component, by delegating to
+ * {@link BasicGraphicsUtils#getPreferredButtonSize}.
+ *
+ * @param c The component to measure
+ *
+ * @return The preferred dimensions of the component
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+ Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b,
+ defaultTextIconGap + defaultTextShiftOffset);
+ return d;
+ }
+
+ static Icon currentIcon(AbstractButton b)
+ {
+ Icon i = b.getIcon();
+ ButtonModel model = b.getModel();
+
+ if (model.isPressed() && b.getPressedIcon() != null && b.isEnabled())
+ i = b.getPressedIcon();
+
+ else if (model.isRollover())
+ {
+ if (b.isSelected() && b.getRolloverSelectedIcon() != null)
+ i = b.getRolloverSelectedIcon();
+ else if (b.getRolloverIcon() != null)
+ i = b.getRolloverIcon();
+ }
+
+ else if (b.isSelected() && b.isEnabled())
+ {
+ if (b.isEnabled() && b.getSelectedIcon() != null)
+ i = b.getSelectedIcon();
+ else if (b.getDisabledSelectedIcon() != null)
+ i = b.getDisabledSelectedIcon();
+ }
+
+ else if (! b.isEnabled() && b.getDisabledIcon() != null)
+ i = b.getDisabledIcon();
+
+ return i;
+ }
+
+ /**
+ * Paint the component, which is an {@link AbstractButton}, according to
+ * its current state.
+ *
+ * @param g The graphics context to paint with
+ * @param c The component to paint the state of
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+
+ Font f = c.getFont();
+
+ g.setFont(f);
+
+ if (b.isBorderPainted())
+ SwingUtilities.calculateInnerArea(b, vr);
+ else
+ vr = SwingUtilities.getLocalBounds(b);
+ String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
+ b.getText(),
+ currentIcon(b),
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ vr, ir, tr,
+ b.getIconTextGap()
+ + defaultTextShiftOffset);
+
+ if ((b.getModel().isArmed() && b.getModel().isPressed())
+ || b.isSelected())
+ paintButtonPressed(g, b);
+
+ paintIcon(g, c, ir);
+ if (text != null)
+ paintText(g, b, tr, text);
+ if (b.isFocusOwner() && b.isFocusPainted())
+ paintFocus(g, b, vr, tr, ir);
+ }
+
+ /**
+ * Paint any focus decoration this {@link JComponent} might have. The
+ * component, which in this case will be an {@link AbstractButton},
+ * should only have focus decoration painted if it has the focus, and its
+ * "focusPainted" property is <code>true</code>.
+ *
+ * @param g Graphics context to paint with
+ * @param b Button to paint the focus of
+ * @param vr Visible rectangle, the area in which to paint
+ * @param tr Text rectangle, contained in visible rectangle
+ * @param ir Icon rectangle, contained in visible rectangle
+ *
+ * @see AbstractButton#isFocusPainted()
+ * @see JComponent#hasFocus()
+ */
+ protected void paintFocus(Graphics g, AbstractButton b, Rectangle vr,
+ Rectangle tr, Rectangle ir)
+ {
+ // In the BasicLookAndFeel no focus border is drawn. This can be
+ // overridden in subclasses to implement such behaviour.
+ }
+
+ /**
+ * Paint the icon for this component. Depending on the state of the
+ * component and the availability of the button's various icon
+ * properties, this might mean painting one of several different icons.
+ *
+ * @param g Graphics context to paint with
+ * @param c Component to paint the icon of
+ * @param iconRect Rectangle in which the icon should be painted
+ */
+ protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
+ {
+ AbstractButton b = (AbstractButton) c;
+ Icon i = currentIcon(b);
+
+ if (i != null)
+ i.paintIcon(c, g, iconRect.x, iconRect.y);
+ }
+
+ /**
+ * Paints the background area of an {@link AbstractButton} in the pressed
+ * state. This means filling the supplied area with a darker than normal
+ * background.
+ *
+ * @param g The graphics context to paint with
+ * @param b The button to paint the state of
+ */
+ protected void paintButtonPressed(Graphics g, AbstractButton b)
+ {
+ if (b.isContentAreaFilled() && b.isOpaque())
+ {
+ Rectangle area = new Rectangle();
+ SwingUtilities.calculateInnerArea(b, area);
+ g.setColor(UIManager.getColor(getPropertyPrefix() + "shadow"));
+ g.fillRect(area.x, area.y, area.width, area.height);
+ }
+ }
+
+ /**
+ * Paints the "text" property of an {@link AbstractButton}.
+ *
+ * @param g The graphics context to paint with
+ * @param c The component to paint the state of
+ * @param textRect The area in which to paint the text
+ * @param text The text to paint
+ */
+ protected void paintText(Graphics g, JComponent c, Rectangle textRect,
+ String text)
+ {
+ paintText(g, (AbstractButton) c, textRect, text);
+ }
+
+ /**
+ * Paints the "text" property of an {@link AbstractButton}.
+ *
+ * @param g The graphics context to paint with
+ * @param b The button to paint the state of
+ * @param textRect The area in which to paint the text
+ * @param text The text to paint
+ *
+ * @since 1.4
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect,
+ String text)
+ {
+ Font f = b.getFont();
+ g.setFont(f);
+ FontMetrics fm = g.getFontMetrics(f);
+
+ if (b.isEnabled())
+ {
+ g.setColor(b.getForeground());
+ // FIXME: Underline mnemonic.
+ BasicGraphicsUtils.drawString(b, g, text, -1, textRect.x,
+ textRect.y + fm.getAscent());
+ }
+ else
+ {
+ String prefix = getPropertyPrefix();
+ g.setColor(UIManager.getColor(prefix + "disabledText"));
+ // FIXME: Underline mnemonic.
+ BasicGraphicsUtils.drawString(b, g, text, -1, textRect.x,
+ textRect.y + fm.getAscent());
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* BasicCheckBoxMenuItemUI.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.event.MouseEvent;
+
+import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * DOCUMENT ME!
+ */
+public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
+{
+
+ /**
+ * Creates a new BasicCheckBoxMenuItemUI object.
+ */
+ public BasicCheckBoxMenuItemUI()
+ {
+ super();
+ }
+
+ /**
+ * Factory method to create a BasicCheckBoxMenuItemUI for the given {@link
+ * JComponent}, which should be a JCheckBoxMenuItem
+ *
+ * @param c The {@link JComponent} a UI is being created for.
+ *
+ * @return A BasicCheckBoxMenuItemUI for the {@link JComponent}.
+ */
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicCheckBoxMenuItemUI();
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "CheckBoxMenuItem"
+ */
+ protected String getPropertyPrefix()
+ {
+ return "CheckBoxMenuItem";
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param item DOCUMENT ME!
+ * @param e DOCUMENT ME!
+ * @param path DOCUMENT ME!
+ * @param manager DOCUMENT ME!
+ */
+ public void processMouseEvent(JMenuItem item, MouseEvent e,
+ MenuElement[] path,
+ MenuSelectionManager manager)
+ {
+ // TODO: May not be implemented properly.
+ item.processMouseEvent(e, path, manager);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* BasicCheckBoxUI.java
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate for the {@link JCheckBox} component.
+ */
+public class BasicCheckBoxUI extends BasicRadioButtonUI
+{
+
+ /**
+ * Returns a UI delegate (that is, an instance of this class) for the
+ * specified component.
+ *
+ * @param c the component (this should be a {@link JCheckBox}).
+ *
+ * @return A new instance of <code>BasicCheckBoxUI</code>.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicCheckBoxUI();
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIManager} defaults table
+ * (<code>"CheckBox."</code> in this case).
+ *
+ * @return "CheckBox."
+ */
+ public String getPropertyPrefix()
+ {
+ return "CheckBox.";
+ }
+}
+
+
+
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicColorChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicColorChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicColorChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicColorChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,344 @@
+/* BasicColorChooserUI.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JColorChooser;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.LookAndFeel;
+import javax.swing.colorchooser.AbstractColorChooserPanel;
+import javax.swing.colorchooser.ColorChooserComponentFactory;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.plaf.ColorChooserUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * This is the UI Class for the JColorChooser in the Basic Look and Feel.
+ */
+public class BasicColorChooserUI extends ColorChooserUI
+{
+ /**
+ * This helper class handles property changes from the JColorChooser.
+ */
+ public class PropertyHandler implements PropertyChangeListener
+ {
+ /**
+ * This method is called when any of the properties of the JColorChooser
+ * change.
+ *
+ * @param e The PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName() == JColorChooser.CHOOSER_PANELS_PROPERTY)
+ makeTabs(chooser.getChooserPanels());
+ else if (e.getPropertyName() == JColorChooser.PREVIEW_PANEL_PROPERTY)
+ updatePreviewPanel(chooser.getPreviewPanel());
+ else if (e.getPropertyName() == JColorChooser.SELECTION_MODEL_PROPERTY)
+ ((AbstractColorChooserPanel) pane.getSelectedComponent())
+ .updateChooser();
+
+ chooser.repaint();
+ }
+ }
+
+ /**
+ * This is a helper class that listens to the Model of the JColorChooser for
+ * color change events so it can update the preview panel.
+ */
+ private class PreviewListener implements ChangeListener
+ {
+ /**
+ * This method is called whenever the JColorChooser's color changes.
+ *
+ * @param e The ChangeEvent.
+ */
+ public void stateChanged(ChangeEvent e)
+ {
+ if (pane != null)
+ {
+ AbstractColorChooserPanel panel = (AbstractColorChooserPanel) pane
+ .getSelectedComponent();
+ if (panel != null)
+ panel.updateChooser();
+ }
+ chooser.repaint();
+ }
+ }
+
+ /**
+ * This helper class listens to the JTabbedPane that is used for tab
+ * changes.
+ */
+ private class TabPaneListener implements ChangeListener
+ {
+ /**
+ * This method is called whenever a different tab is selected in the
+ * JTabbedPane.
+ *
+ * @param e The ChangeEvent.
+ */
+ public void stateChanged(ChangeEvent e)
+ {
+ // Need to do this because we don't update all the tabs when they're not
+ // visible, so they are not informed of new colors when they're hidden.
+ AbstractColorChooserPanel comp = (AbstractColorChooserPanel) pane
+ .getSelectedComponent();
+ comp.updateChooser();
+ }
+ }
+
+ /** An array of default choosers to use in the JColorChooser. */
+ protected AbstractColorChooserPanel[] defaultChoosers;
+
+ /** The listener for the preview panel. */
+ protected ChangeListener previewListener;
+
+ /** The PropertyChangeListener for the JColorChooser. */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /**
+ * The JColorChooser this is installed on.
+ */
+ protected JColorChooser chooser;
+
+ /** The JTabbedPane that is used. */
+ JTabbedPane pane;
+
+ /** The Container that holds the preview panel. */
+ private Container prevContainer;
+
+ /**
+ * Creates a new BasicColorChooserUI object.
+ */
+ public BasicColorChooserUI()
+ {
+ super();
+ }
+
+ /**
+ * This method creates a new UI Component for the given JComponent.
+ *
+ * @param c The JComponent to create an UI for.
+ *
+ * @return A new BasicColorChooserUI.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicColorChooserUI();
+ }
+
+ /**
+ * This method creates the default chooser panels for the JColorChooser.
+ *
+ * @return The default chooser panels.
+ */
+ protected AbstractColorChooserPanel[] createDefaultChoosers()
+ {
+ return ColorChooserComponentFactory.getDefaultChooserPanels();
+ }
+
+ /**
+ * This method installs the UI Component for the given JComponent.
+ *
+ * @param c The JComponent to install this UI for.
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JColorChooser)
+ {
+ chooser = (JColorChooser) c;
+ chooser.setLayout(new BorderLayout());
+
+ // Do this first, so we avoid doing work for property change events.
+ defaultChoosers = createDefaultChoosers();
+ chooser.setChooserPanels(defaultChoosers);
+ pane = new JTabbedPane();
+
+ pane.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent e)
+ {
+ pane.repaint();
+ }
+ });
+
+ makeTabs(defaultChoosers);
+
+ chooser.add(pane, BorderLayout.NORTH);
+
+ installPreviewPanel();
+
+ installDefaults();
+ installListeners();
+ }
+ }
+
+ /**
+ * This method adds tabs to the JTabbedPane for the chooserPanels defined in
+ * the JColorChooser.
+ * This is package-private to avoid an accessor method.
+ *
+ * @param panels The Panels that need tabs to be made for them.
+ */
+ void makeTabs(AbstractColorChooserPanel[] panels)
+ {
+ pane.removeAll();
+ for (int i = 0; i < panels.length; i++)
+ pane.addTab(panels[i].getDisplayName(), panels[i].getSmallDisplayIcon(),
+ panels[i]);
+ }
+
+ /**
+ * This method uninstalls this UI for the given JComponent.
+ *
+ * @param c The JComponent that will have this UI removed.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallListeners();
+ uninstallDefaults();
+ uninstallDefaultChoosers();
+
+ pane = null;
+ chooser = null;
+ }
+
+ /**
+ * Uninstalls the default color choosers that have been installed by this UI.
+ */
+ protected void uninstallDefaultChoosers()
+ {
+ defaultChoosers = null;
+ }
+
+ /**
+ * This method installs the preview panel for the JColorChooser.
+ */
+ protected void installPreviewPanel()
+ {
+ updatePreviewPanel(ColorChooserComponentFactory.getPreviewPanel());
+ }
+
+ /**
+ * This is a helper method that swaps the existing preview panel with the
+ * given panel.
+ * This is package-private to avoid an accessor method.
+ *
+ * @param preview The new preview panel.
+ */
+ void updatePreviewPanel(JComponent preview)
+ {
+ if (prevContainer == null)
+ {
+ prevContainer = new JPanel();
+ prevContainer.setLayout(new BorderLayout());
+ chooser.add(prevContainer, BorderLayout.CENTER);
+ }
+ prevContainer.removeAll();
+ prevContainer.add(preview, BorderLayout.CENTER);
+ }
+
+ /**
+ * This method installs the default properties given by the Basic Look and
+ * Feel.
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installColorsAndFont(chooser, "ColorChooser.background",
+ "ColorChooser.foreground",
+ "ColorChooser.font");
+ }
+
+ /**
+ * This method uninstalls the default properties given by the Basic Look and
+ * Feel.
+ */
+ protected void uninstallDefaults()
+ {
+ chooser.setBackground(null);
+ chooser.setForeground(null);
+ chooser.setFont(null);
+ }
+
+ /**
+ * This method installs any listeners required for this UI to function.
+ */
+ protected void installListeners()
+ {
+ propertyChangeListener = createPropertyChangeListener();
+ previewListener = new PreviewListener();
+
+ chooser.addPropertyChangeListener(propertyChangeListener);
+ chooser.getSelectionModel().addChangeListener(previewListener);
+
+ pane.addChangeListener(new TabPaneListener());
+ }
+
+ /**
+ * This method creates the PropertyChangeListener used for listening to the
+ * JColorChooser.
+ *
+ * @return A PropertyChangeListener.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyHandler();
+ }
+
+ /**
+ * This method uninstalls any listeners that were previously installed by
+ * the UI.
+ */
+ protected void uninstallListeners()
+ {
+ chooser.removePropertyChangeListener(propertyChangeListener);
+ chooser.getSelectionModel().removeChangeListener(previewListener);
+
+ previewListener = null;
+ propertyChangeListener = null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxEditor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxEditor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxEditor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxEditor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,181 @@
+/* BasicComboBoxEditor.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Component;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+
+import javax.swing.ComboBoxEditor;
+import javax.swing.JTextField;
+
+/**
+ * An editor used by the {@link BasicComboBoxUI} class. This editor uses a
+ * {@link JTextField} as the editor component.
+ *
+ * @author Olga Rodimina
+ */
+public class BasicComboBoxEditor extends Object implements ComboBoxEditor,
+ FocusListener
+{
+ /** The editor component. */
+ protected JTextField editor;
+
+ /**
+ * Creates a new <code>BasicComboBoxEditor</code> instance.
+ */
+ public BasicComboBoxEditor()
+ {
+ editor = new JTextField();
+ editor.setBorder(null);
+ editor.setColumns(9);
+ }
+
+ /**
+ * Returns the component that will be used by the combo box to display and
+ * edit the currently selected item in the combo box.
+ *
+ * @return The editor component, which is a {@link JTextField} in this case.
+ */
+ public Component getEditorComponent()
+ {
+ return editor;
+ }
+
+ /**
+ * Sets item that should be edited when any editing operation is performed
+ * by the user. The value is always equal to the currently selected value
+ * in the combo box. Thus whenever a different value is selected from the
+ * combo box list then this method should be called to change editing
+ * item to the new selected item.
+ *
+ * @param item item that is currently selected in the combo box
+ */
+ public void setItem(Object item)
+ {
+ if (item == null)
+ editor.setText("");
+ else
+ editor.setText(item.toString());
+ }
+
+ /**
+ * Returns the text from the editor component.
+ *
+ * @return The text from the editor component.
+ */
+ public Object getItem()
+ {
+ return editor.getText();
+ }
+
+ /**
+ * Selects all the text in the editor component.
+ */
+ public void selectAll()
+ {
+ editor.selectAll();
+ }
+
+ /**
+ * This method is called when textfield gains focus. This will enable
+ * editing of the selected item.
+ *
+ * @param e the FocusEvent describing change in focus.
+ */
+ public void focusGained(FocusEvent e)
+ {
+ // FIXME: Need to implement
+ }
+
+ /**
+ * This method is called when textfield loses focus. If during this time any
+ * editting operation was performed by the user, then it will be cancelled
+ * and selected item will not be changed.
+ *
+ * @param e the FocusEvent describing change in focus
+ */
+ public void focusLost(FocusEvent e)
+ {
+ // FIXME: Need to implement
+ }
+
+ /**
+ * Adds an {@link ActionListener} to the editor component. If the user will
+ * edit currently selected item in the textfield and pressEnter, then action
+ * will be performed. The actionPerformed of this ActionListener should
+ * change the selected item of the comboBox to the newly editted selected
+ * item.
+ *
+ * @param l the ActionListener responsible for changing selected item of the
+ * combo box when it is editted by the user.
+ */
+ public void addActionListener(ActionListener l)
+ {
+ editor.addActionListener(l);
+ }
+
+ /**
+ * Removes the {@link ActionListener} from the editor component.
+ *
+ * @param l the listener to remove.
+ */
+ public void removeActionListener(ActionListener l)
+ {
+ editor.removeActionListener(l);
+ }
+
+ /**
+ * A subclass of {@link BasicComboBoxEditor} that implements the
+ * {@link UIResource} interface.
+ */
+ public static class UIResource extends BasicComboBoxEditor
+ implements javax.swing.plaf.UIResource
+ {
+ /**
+ * Creates a new <code>BasicComboBoxEditor.UIResource</code> instance.
+ */
+ public UIResource()
+ {
+ // Nothing to do here.
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* BasicComboBoxRenderer.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * A renderer for a {@link JComboBox}.
+ *
+ * @author Olga Rodimina
+ */
+public class BasicComboBoxRenderer
+ extends JLabel
+ implements ListCellRenderer, Serializable
+{
+ /**
+ * A shared border instance for all renderers.
+ */
+ protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
+
+ /**
+ * Creates a new <code>BasicComboBoxRenderer</code> object.
+ */
+ public BasicComboBoxRenderer()
+ {
+ setOpaque(true);
+ setBorder(noFocusBorder);
+ }
+
+ /**
+ * Returns preferredSize of the renderer
+ *
+ * @return preferredSize of the renderer
+ */
+ public Dimension getPreferredSize()
+ {
+ if (this.getText() != null && ! this.getText().equals(""))
+ return super.getPreferredSize();
+ else
+ {
+ // If the combo box option's text is empty or null, it won't size
+ // properly (ie, it'll be way too short)... so we throw in a dummy
+ // space to trick the superclass's sizing methods.
+ String oldText = this.getText();
+ this.setText(" ");
+ Dimension d = super.getPreferredSize();
+ this.setText(oldText);
+ return d;
+ }
+ }
+
+ /**
+ * Returns a component that has been configured to display the given
+ * <code>value</code>.
+ *
+ * @param list List of items for which to the background and foreground
+ * colors
+ * @param value object that should be rendered in the cell
+ * @param index index of the cell in the list of items.
+ * @param isSelected draw cell highlighted if isSelected is true
+ * @param cellHasFocus draw focus rectangle around cell if the cell has
+ * focus
+ *
+ * @return Component that will be used to draw the desired cell.
+ */
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected,
+ boolean cellHasFocus)
+ {
+ if (isSelected)
+ {
+ setBackground(list.getSelectionBackground());
+ setForeground(list.getSelectionForeground());
+ }
+ else
+ {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ }
+ setFont(list.getFont());
+
+ if (value instanceof Icon)
+ setIcon((Icon) value);
+ else
+ setText(value == null ? "" : value.toString());
+
+ return this;
+ }
+
+ /**
+ * A subclass of {@link BasicComboBoxRenderer} that implements the
+ * {@link javax.swing.plaf.UIResource} interface.
+ */
+ public static class UIResource extends BasicComboBoxRenderer
+ implements javax.swing.plaf.UIResource
+ {
+ /**
+ * Creates a new <code>UIResource</code> object.
+ */
+ public UIResource()
+ {
+ // Nothing to do here.
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1397 @@
+/* BasicComboBoxUI.java --
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Rectangle;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.swing.CellRendererPane;
+import javax.swing.ComboBoxEditor;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.InputMap;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+
+/**
+ * A UI delegate for the {@link JComboBox} component.
+ *
+ * @author Olga Rodimina
+ * @author Robert Schuster
+ */
+public class BasicComboBoxUI extends ComboBoxUI
+{
+ /**
+ * The arrow button that is displayed in the right side of JComboBox. This
+ * button is used to hide and show combo box's list of items.
+ */
+ protected JButton arrowButton;
+
+ /**
+ * The combo box represented by this UI delegate.
+ */
+ protected JComboBox comboBox;
+
+ /**
+ * The component that is responsible for displaying/editing the selected
+ * item of the combo box.
+ *
+ * @see BasicComboBoxEditor#getEditorComponent()
+ */
+ protected Component editor;
+
+ /**
+ * A listener listening to focus events occurring in the {@link JComboBox}.
+ */
+ protected FocusListener focusListener;
+
+ /**
+ * A flag indicating whether JComboBox currently has the focus.
+ */
+ protected boolean hasFocus;
+
+ /**
+ * A listener listening to item events fired by the {@link JComboBox}.
+ */
+ protected ItemListener itemListener;
+
+ /**
+ * A listener listening to key events that occur while {@link JComboBox} has
+ * the focus.
+ */
+ protected KeyListener keyListener;
+
+ /**
+ * List used when rendering selected item of the combo box. The selection
+ * and foreground colors for combo box renderer are configured from this
+ * list.
+ */
+ protected JList listBox;
+
+ /**
+ * ListDataListener listening to JComboBox model
+ */
+ protected ListDataListener listDataListener;
+
+ /**
+ * Popup list containing the combo box's menu items.
+ */
+ protected ComboPopup popup;
+
+ protected KeyListener popupKeyListener;
+
+ protected MouseListener popupMouseListener;
+
+ protected MouseMotionListener popupMouseMotionListener;
+
+ /**
+ * Listener listening to changes in the bound properties of JComboBox
+ */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /* Size of the largest item in the comboBox
+ * This is package-private to avoid an accessor method.
+ */
+ Dimension displaySize = new Dimension();
+
+ /**
+ * Used to render the combo box values.
+ */
+ protected CellRendererPane currentValuePane;
+
+ /**
+ * The current minimum size if isMinimumSizeDirty is false.
+ * Setup by getMinimumSize() and invalidated by the various listeners.
+ */
+ protected Dimension cachedMinimumSize;
+
+ /**
+ * Indicates whether or not the cachedMinimumSize field is valid or not.
+ */
+ protected boolean isMinimumSizeDirty = true;
+
+ /**
+ * Creates a new <code>BasicComboBoxUI</code> object.
+ */
+ public BasicComboBoxUI()
+ {
+ currentValuePane = new CellRendererPane();
+ cachedMinimumSize = new Dimension();
+ }
+
+ /**
+ * A factory method to create a UI delegate for the given
+ * {@link JComponent}, which should be a {@link JComboBox}.
+ *
+ * @param c The {@link JComponent} a UI is being created for.
+ *
+ * @return A UI delegate for the {@link JComponent}.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicComboBoxUI();
+ }
+
+ /**
+ * Installs the UI for the given {@link JComponent}.
+ *
+ * @param c the JComponent to install a UI for.
+ *
+ * @see #uninstallUI(JComponent)
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+
+ if (c instanceof JComboBox)
+ {
+ isMinimumSizeDirty = true;
+ comboBox = (JComboBox) c;
+ installDefaults();
+
+ // Set editor and renderer for the combo box. Editor is used
+ // only if combo box becomes editable, otherwise renderer is used
+ // to paint the selected item; combobox is not editable by default.
+ ListCellRenderer renderer = comboBox.getRenderer();
+ if (renderer == null || renderer instanceof UIResource)
+ comboBox.setRenderer(createRenderer());
+
+ ComboBoxEditor currentEditor = comboBox.getEditor();
+ if (currentEditor == null || currentEditor instanceof UIResource)
+ {
+ currentEditor = createEditor();
+ comboBox.setEditor(currentEditor);
+ }
+ editor = currentEditor.getEditorComponent();
+
+ installComponents();
+ installListeners();
+ if (arrowButton != null)
+ configureArrowButton();
+ if (editor != null)
+ configureEditor();
+ comboBox.setLayout(createLayoutManager());
+ comboBox.setFocusable(true);
+ installKeyboardActions();
+ comboBox.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP,
+ Boolean.TRUE);
+ }
+ }
+
+ /**
+ * Uninstalls the UI for the given {@link JComponent}.
+ *
+ * @param c The JComponent that is having this UI removed.
+ *
+ * @see #installUI(JComponent)
+ */
+ public void uninstallUI(JComponent c)
+ {
+ setPopupVisible(comboBox, false);
+ popup.uninstallingUI();
+ uninstallKeyboardActions();
+ comboBox.setLayout(null);
+ uninstallComponents();
+ uninstallListeners();
+ uninstallDefaults();
+ comboBox = null;
+ }
+
+ /**
+ * Installs the defaults that are defined in the {@link BasicLookAndFeel}
+ * for this {@link JComboBox}.
+ *
+ * @see #uninstallDefaults()
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installColorsAndFont(comboBox, "ComboBox.background",
+ "ComboBox.foreground", "ComboBox.font");
+ LookAndFeel.installBorder(comboBox, "ComboBox.border");
+ }
+
+ /**
+ * Creates and installs the listeners for this UI.
+ *
+ * @see #uninstallListeners()
+ */
+ protected void installListeners()
+ {
+ // install combo box's listeners
+ propertyChangeListener = createPropertyChangeListener();
+ comboBox.addPropertyChangeListener(propertyChangeListener);
+
+ focusListener = createFocusListener();
+ comboBox.addFocusListener(focusListener);
+
+ itemListener = createItemListener();
+ comboBox.addItemListener(itemListener);
+
+ keyListener = createKeyListener();
+ comboBox.addKeyListener(keyListener);
+
+ // install listeners that listen to combo box model
+ listDataListener = createListDataListener();
+ comboBox.getModel().addListDataListener(listDataListener);
+
+ // Install mouse and key listeners from the popup.
+ popupMouseListener = popup.getMouseListener();
+ comboBox.addMouseListener(popupMouseListener);
+
+ popupMouseMotionListener = popup.getMouseMotionListener();
+ comboBox.addMouseMotionListener(popupMouseMotionListener);
+
+ popupKeyListener = popup.getKeyListener();
+ comboBox.addKeyListener(popupKeyListener);
+ }
+
+ /**
+ * Uninstalls the defaults and sets any objects created during
+ * install to <code>null</code>.
+ *
+ * @see #installDefaults()
+ */
+ protected void uninstallDefaults()
+ {
+ if (comboBox.getFont() instanceof UIResource)
+ comboBox.setFont(null);
+
+ if (comboBox.getForeground() instanceof UIResource)
+ comboBox.setForeground(null);
+
+ if (comboBox.getBackground() instanceof UIResource)
+ comboBox.setBackground(null);
+
+ LookAndFeel.uninstallBorder(comboBox);
+ }
+
+ /**
+ * Detaches all the listeners we attached in {@link #installListeners}.
+ *
+ * @see #installListeners()
+ */
+ protected void uninstallListeners()
+ {
+ comboBox.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+
+ comboBox.removeFocusListener(focusListener);
+ listBox.removeFocusListener(focusListener);
+ focusListener = null;
+
+ comboBox.removeItemListener(itemListener);
+ itemListener = null;
+
+ comboBox.removeKeyListener(keyListener);
+ keyListener = null;
+
+ comboBox.getModel().removeListDataListener(listDataListener);
+ listDataListener = null;
+
+ if (popupMouseListener != null)
+ comboBox.removeMouseListener(popupMouseListener);
+ popupMouseListener = null;
+
+ if (popupMouseMotionListener != null)
+ comboBox.removeMouseMotionListener(popupMouseMotionListener);
+ popupMouseMotionListener = null;
+
+ if (popupKeyListener != null)
+ comboBox.removeKeyListener(popupKeyListener);
+ popupKeyListener = null;
+ }
+
+ /**
+ * Creates the popup that will contain list of combo box's items.
+ *
+ * @return popup containing list of combo box's items
+ */
+ protected ComboPopup createPopup()
+ {
+ return new BasicComboPopup(comboBox);
+ }
+
+ /**
+ * Creates a {@link KeyListener} to listen to key events.
+ *
+ * @return KeyListener that listens to key events.
+ */
+ protected KeyListener createKeyListener()
+ {
+ return new KeyHandler();
+ }
+
+ /**
+ * Creates the {@link FocusListener} that will listen to changes in this
+ * JComboBox's focus.
+ *
+ * @return the FocusListener.
+ */
+ protected FocusListener createFocusListener()
+ {
+ return new FocusHandler();
+ }
+
+ /**
+ * Creates a {@link ListDataListener} to listen to the combo box's data model.
+ *
+ * @return The new listener.
+ */
+ protected ListDataListener createListDataListener()
+ {
+ return new ListDataHandler();
+ }
+
+ /**
+ * Creates an {@link ItemListener} that will listen to the changes in
+ * the JComboBox's selection.
+ *
+ * @return The ItemListener
+ */
+ protected ItemListener createItemListener()
+ {
+ return new ItemHandler();
+ }
+
+ /**
+ * Creates a {@link PropertyChangeListener} to listen to the changes in
+ * the JComboBox's bound properties.
+ *
+ * @return The PropertyChangeListener
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Creates and returns a layout manager for the combo box. Subclasses can
+ * override this method to provide a different layout.
+ *
+ * @return a layout manager for the combo box.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return new ComboBoxLayoutManager();
+ }
+
+ /**
+ * Creates a component that will be responsible for rendering the
+ * selected component in the combo box.
+ *
+ * @return A renderer for the combo box.
+ */
+ protected ListCellRenderer createRenderer()
+ {
+ return new BasicComboBoxRenderer.UIResource();
+ }
+
+ /**
+ * Creates the component that will be responsible for displaying/editing
+ * the selected item in the combo box. This editor is used only when combo
+ * box is editable.
+ *
+ * @return A new component that will be responsible for displaying/editing
+ * the selected item in the combo box.
+ */
+ protected ComboBoxEditor createEditor()
+ {
+ return new BasicComboBoxEditor.UIResource();
+ }
+
+ /**
+ * Installs the components for this JComboBox. ArrowButton, main
+ * part of combo box (upper part) and popup list of items are created and
+ * configured here.
+ */
+ protected void installComponents()
+ {
+ // create drop down list of items
+ popup = createPopup();
+ listBox = popup.getList();
+
+ // create and install arrow button
+ arrowButton = createArrowButton();
+ comboBox.add(arrowButton);
+
+ if (comboBox.isEditable())
+ addEditor();
+
+ comboBox.add(currentValuePane);
+ }
+
+ /**
+ * Uninstalls components from this {@link JComboBox}.
+ *
+ * @see #installComponents()
+ */
+ protected void uninstallComponents()
+ {
+ // uninstall arrow button
+ unconfigureArrowButton();
+ comboBox.remove(arrowButton);
+ arrowButton = null;
+
+ popup = null;
+
+ if (comboBox.getRenderer() instanceof UIResource)
+ comboBox.setRenderer(null);
+
+ // if the editor is not an instanceof UIResource, it was not set by the
+ // UI delegate, so don't clear it...
+ ComboBoxEditor currentEditor = comboBox.getEditor();
+ if (currentEditor instanceof UIResource)
+ {
+ comboBox.setEditor(null);
+ editor = null;
+ }
+ }
+
+ /**
+ * Adds the current editor to the combo box.
+ */
+ public void addEditor()
+ {
+ removeEditor();
+ editor = comboBox.getEditor().getEditorComponent();
+ comboBox.add(editor);
+ }
+
+ /**
+ * Removes the current editor from the combo box.
+ */
+ public void removeEditor()
+ {
+ if (editor != null)
+ {
+ unconfigureEditor();
+ comboBox.remove(editor);
+ }
+ }
+
+ /**
+ * Configures the editor for this combo box.
+ */
+ protected void configureEditor()
+ {
+ editor.setFont(comboBox.getFont());
+ if (popupKeyListener != null)
+ editor.addKeyListener(popupKeyListener);
+ if (keyListener != null)
+ editor.addKeyListener(keyListener);
+ comboBox.configureEditor(comboBox.getEditor(),
+ comboBox.getSelectedItem());
+ }
+
+ /**
+ * Unconfigures the editor for this combo box.
+ */
+ protected void unconfigureEditor()
+ {
+ if (popupKeyListener != null)
+ editor.removeKeyListener(popupKeyListener);
+ if (keyListener != null)
+ editor.removeKeyListener(keyListener);
+ }
+
+ /**
+ * Configures the arrow button.
+ *
+ * @see #configureArrowButton()
+ */
+ public void configureArrowButton()
+ {
+ if (arrowButton != null)
+ {
+ arrowButton.setEnabled(comboBox.isEnabled());
+ arrowButton.setFocusable(false);
+ if (popupMouseListener != null)
+ arrowButton.addMouseListener(popupMouseListener);
+ if (popupMouseMotionListener != null)
+ arrowButton.addMouseMotionListener(popupMouseMotionListener);
+
+ // Mark the button as not closing the popup, we handle this ourselves.
+ arrowButton.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP,
+ Boolean.TRUE);
+ }
+ }
+
+ /**
+ * Unconfigures the arrow button.
+ *
+ * @see #configureArrowButton()
+ *
+ * @specnote The specification says this method is implementation specific
+ * and should not be used or overridden.
+ */
+ public void unconfigureArrowButton()
+ {
+ if (arrowButton != null)
+ {
+ if (popupMouseListener != null)
+ arrowButton.removeMouseListener(popupMouseListener);
+ if (popupMouseMotionListener != null)
+ arrowButton.removeMouseMotionListener(popupMouseMotionListener);
+ }
+ }
+
+ /**
+ * Creates an arrow button for this {@link JComboBox}. The arrow button is
+ * displayed at the right end of the combo box and is used to display/hide
+ * the drop down list of items.
+ *
+ * @return A new button.
+ */
+ protected JButton createArrowButton()
+ {
+ return new BasicArrowButton(BasicArrowButton.SOUTH);
+ }
+
+ /**
+ * Returns <code>true</code> if the popup is visible, and <code>false</code>
+ * otherwise.
+ *
+ * @param c The JComboBox to check
+ *
+ * @return <code>true</code> if popup part of the JComboBox is visible and
+ * <code>false</code> otherwise.
+ */
+ public boolean isPopupVisible(JComboBox c)
+ {
+ return popup.isVisible();
+ }
+
+ /**
+ * Displays/hides the {@link JComboBox}'s list of items on the screen.
+ *
+ * @param c The combo box, for which list of items should be
+ * displayed/hidden
+ * @param v true if show popup part of the jcomboBox and false to hide.
+ */
+ public void setPopupVisible(JComboBox c, boolean v)
+ {
+ if (v)
+ popup.show();
+ else
+ popup.hide();
+ }
+
+ /**
+ * JComboBox is focus traversable if it is editable and not otherwise.
+ *
+ * @param c combo box for which to check whether it is focus traversable
+ *
+ * @return true if focus tranversable and false otherwise
+ */
+ public boolean isFocusTraversable(JComboBox c)
+ {
+ if (!comboBox.isEditable())
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Paints given menu item using specified graphics context
+ *
+ * @param g The graphics context used to paint this combo box
+ * @param c comboBox which needs to be painted.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ hasFocus = comboBox.hasFocus();
+ if (! comboBox.isEditable())
+ {
+ Rectangle rect = rectangleForCurrentValue();
+ paintCurrentValueBackground(g, rect, hasFocus);
+ paintCurrentValue(g, rect, hasFocus);
+ }
+ }
+
+ /**
+ * Returns preferred size for the combo box.
+ *
+ * @param c comboBox for which to get preferred size
+ *
+ * @return The preferred size for the given combo box
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return getMinimumSize(c);
+ }
+
+ /**
+ * Returns the minimum size for this {@link JComboBox} for this
+ * look and feel. Also makes sure cachedMinimimSize is setup correctly.
+ *
+ * @param c The {@link JComponent} to find the minimum size for.
+ *
+ * @return The dimensions of the minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ if (isMinimumSizeDirty)
+ {
+ Insets i = getInsets();
+ Dimension d = getDisplaySize();
+ d.width += i.left + i.right + d.height;
+ cachedMinimumSize = new Dimension(d.width, d.height + i.top + i.bottom);
+ isMinimumSizeDirty = false;
+ }
+ return new Dimension(cachedMinimumSize);
+ }
+
+ /**
+ * Returns the maximum size for this {@link JComboBox} for this
+ * look and feel.
+ *
+ * @param c The {@link JComponent} to find the maximum size for
+ *
+ * @return The maximum size (<code>Dimension(32767, 32767)</code>).
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return new Dimension(32767, 32767);
+ }
+
+ /**
+ * Returns the number of accessible children of the combobox.
+ *
+ * @param c the component (combobox) to check, ignored
+ *
+ * @return the number of accessible children of the combobox
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int count = 1;
+ if (comboBox.isEditable())
+ count = 2;
+ return count;
+ }
+
+ /**
+ * Returns the accessible child with the specified index.
+ *
+ * @param c the component, this is ignored
+ * @param i the index of the accessible child to return
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible child = null;
+ switch (i)
+ {
+ case 0: // The popup.
+ if (popup instanceof Accessible)
+ {
+ AccessibleContext ctx = ((Accessible) popup).getAccessibleContext();
+ ctx.setAccessibleParent(comboBox);
+ child = (Accessible) popup;
+ }
+ break;
+ case 1: // The editor, if any.
+ if (comboBox.isEditable() && editor instanceof Accessible)
+ {
+ AccessibleContext ctx =
+ ((Accessible) editor).getAccessibleContext();
+ ctx.setAccessibleParent(comboBox);
+ child = (Accessible) editor;
+ }
+ break;
+ }
+ return child;
+ }
+
+ /**
+ * Returns true if the specified key is a navigation key and false otherwise
+ *
+ * @param keyCode a key for which to check whether it is navigation key or
+ * not.
+ *
+ * @return true if the specified key is a navigation key and false otherwis
+ */
+ protected boolean isNavigationKey(int keyCode)
+ {
+ return keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN
+ || keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT
+ || keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_ESCAPE
+ || keyCode == KeyEvent.VK_TAB;
+ }
+
+ /**
+ * Selects next possible item relative to the current selection
+ * to be next selected item in the combo box.
+ */
+ protected void selectNextPossibleValue()
+ {
+ int index = comboBox.getSelectedIndex();
+ if (index != comboBox.getItemCount() - 1)
+ comboBox.setSelectedIndex(index + 1);
+ }
+
+ /**
+ * Selects previous item relative to current selection to be
+ * next selected item.
+ */
+ protected void selectPreviousPossibleValue()
+ {
+ int index = comboBox.getSelectedIndex();
+ if (index > 0)
+ comboBox.setSelectedIndex(index - 1);
+ }
+
+ /**
+ * Displays combo box popup if the popup is not currently shown
+ * on the screen and hides it if it is currently shown
+ */
+ protected void toggleOpenClose()
+ {
+ setPopupVisible(comboBox, ! isPopupVisible(comboBox));
+ }
+
+ /**
+ * Returns the bounds in which comboBox's selected item will be
+ * displayed.
+ *
+ * @return rectangle bounds in which comboBox's selected Item will be
+ * displayed
+ */
+ protected Rectangle rectangleForCurrentValue()
+ {
+ int w = comboBox.getWidth();
+ int h = comboBox.getHeight();
+ Insets i = comboBox.getInsets();
+ int arrowSize = h - (i.top + i.bottom);
+ if (arrowButton != null)
+ arrowSize = arrowButton.getWidth();
+ return new Rectangle(i.left, i.top, w - (i.left + i.right + arrowSize),
+ h - (i.top + i.left));
+ }
+
+ /**
+ * Returns the insets of the current border.
+ *
+ * @return Insets representing space between combo box and its border
+ */
+ protected Insets getInsets()
+ {
+ return comboBox.getInsets();
+ }
+
+ /**
+ * Paints currently selected value in the main part of the combo
+ * box (part without popup).
+ *
+ * @param g graphics context
+ * @param bounds Rectangle representing the size of the area in which
+ * selected item should be drawn
+ * @param hasFocus true if combo box has focus and false otherwise
+ */
+ public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
+ {
+ Object currentValue = comboBox.getSelectedItem();
+ boolean isPressed = arrowButton.getModel().isPressed();
+
+ /* Gets the component to be drawn for the current value.
+ * If there is currently no selected item we will take an empty
+ * String as replacement.
+ */
+ ListCellRenderer renderer = comboBox.getRenderer();
+ if (comboBox.getSelectedIndex() != -1)
+ {
+ Component comp;
+ if (hasFocus && ! isPopupVisible(comboBox))
+ {
+ comp = renderer.getListCellRendererComponent(listBox,
+ comboBox.getSelectedItem(), -1, true, false);
+ }
+ else
+ {
+ comp = renderer.getListCellRendererComponent(listBox,
+ comboBox.getSelectedItem(), -1, false, false);
+ Color bg = UIManager.getColor("ComboBox.disabledForeground");
+ comp.setBackground(bg);
+ }
+ comp.setFont(comboBox.getFont());
+ if (hasFocus && ! isPopupVisible(comboBox))
+ {
+ comp.setForeground(listBox.getSelectionForeground());
+ comp.setBackground(listBox.getSelectionBackground());
+ }
+ else if (comboBox.isEnabled())
+ {
+ comp.setForeground(comboBox.getForeground());
+ comp.setBackground(comboBox.getBackground());
+ }
+ else
+ {
+ Color fg = UIManager.getColor("ComboBox.disabledForeground");
+ comp.setForeground(fg);
+ Color bg = UIManager.getColor("ComboBox.disabledBackground");
+ comp.setBackground(bg);
+ }
+ currentValuePane.paintComponent(g, comp, comboBox, bounds.x, bounds.y,
+ bounds.width, bounds.height);
+ }
+ }
+
+ /**
+ * Paints the background of part of the combo box, where currently
+ * selected value is displayed. If the combo box has focus this method
+ * should also paint focus rectangle around the combo box.
+ *
+ * @param g graphics context
+ * @param bounds Rectangle representing the size of the largest item in the
+ * comboBox
+ * @param hasFocus true if combo box has fox and false otherwise
+ */
+ public void paintCurrentValueBackground(Graphics g, Rectangle bounds,
+ boolean hasFocus)
+ {
+ Color saved = g.getColor();
+ if (comboBox.isEnabled())
+ g.setColor(UIManager.getColor("UIManager.background"));
+ else
+ g.setColor(UIManager.getColor("UIManager.disabledBackground"));
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ g.setColor(saved);
+ }
+
+ private static final ListCellRenderer DEFAULT_RENDERER
+ = new DefaultListCellRenderer();
+
+ /**
+ * Returns the default size for the display area of a combo box that does
+ * not contain any elements. This method returns the width and height of
+ * a single space in the current font, plus a margin of 1 pixel.
+ *
+ * @return The default display size.
+ *
+ * @see #getDisplaySize()
+ */
+ protected Dimension getDefaultSize()
+ {
+ Component comp = DEFAULT_RENDERER.getListCellRendererComponent(listBox,
+ " ", -1, false, false);
+ currentValuePane.add(comp);
+ comp.setFont(comboBox.getFont());
+ Dimension d = comp.getPreferredSize();
+ currentValuePane.remove(comp);
+ return d;
+ }
+
+ /**
+ * Returns the size of the display area for the combo box. This size will be
+ * the size of the combo box, not including the arrowButton.
+ *
+ * @return The size of the display area for the combo box.
+ */
+ protected Dimension getDisplaySize()
+ {
+ Dimension dim = new Dimension();
+ ListCellRenderer renderer = comboBox.getRenderer();
+ if (renderer == null)
+ {
+ renderer = DEFAULT_RENDERER;
+ }
+
+ Object prototype = comboBox.getPrototypeDisplayValue();
+ if (prototype != null)
+ {
+ Component comp = renderer.getListCellRendererComponent(listBox,
+ prototype, -1, false, false);
+ currentValuePane.add(comp);
+ comp.setFont(comboBox.getFont());
+ Dimension renderSize = comp.getPreferredSize();
+ currentValuePane.remove(comp);
+ dim.height = renderSize.height;
+ dim.width = renderSize.width;
+ }
+ else
+ {
+ ComboBoxModel model = comboBox.getModel();
+ int size = model.getSize();
+ if (size > 0)
+ {
+ for (int i = 0; i < size; ++i)
+ {
+ Component comp = renderer.getListCellRendererComponent(listBox,
+ model.getElementAt(i), -1, false, false);
+ currentValuePane.add(comp);
+ comp.setFont(comboBox.getFont());
+ Dimension renderSize = comp.getPreferredSize();
+ currentValuePane.remove(comp);
+ dim.width = Math.max(dim.width, renderSize.width);
+ dim.height = Math.max(dim.height, renderSize.height);
+ }
+ }
+ else
+ {
+ dim = getDefaultSize();
+ if (comboBox.isEditable())
+ dim.width = 100;
+ }
+ }
+ if (comboBox.isEditable())
+ {
+ Dimension editSize = editor.getPreferredSize();
+ dim.width = Math.max(dim.width, editSize.width);
+ dim.height = Math.max(dim.height, editSize.height);
+ }
+ displaySize.setSize(dim.width, dim.height);
+ return dim;
+ }
+
+ /**
+ * Installs the keyboard actions for the {@link JComboBox} as specified
+ * by the look and feel.
+ */
+ protected void installKeyboardActions()
+ {
+ SwingUtilities.replaceUIInputMap(comboBox,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ (InputMap) UIManager.get("ComboBox.ancestorInputMap"));
+ // Install any action maps here.
+ }
+
+ /**
+ * Uninstalls the keyboard actions for the {@link JComboBox} there were
+ * installed by in {@link #installListeners}.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ SwingUtilities.replaceUIInputMap(comboBox,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ // Uninstall any action maps here.
+ }
+
+ /**
+ * A {@link LayoutManager} used to position the sub-components of the
+ * {@link JComboBox}.
+ *
+ * @see BasicComboBoxUI#createLayoutManager()
+ */
+ public class ComboBoxLayoutManager implements LayoutManager
+ {
+ /**
+ * Creates a new ComboBoxLayoutManager object.
+ */
+ public ComboBoxLayoutManager()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Adds a component to the layout. This method does nothing, since the
+ * layout manager doesn't need to track the components.
+ *
+ * @param name the name to associate the component with (ignored).
+ * @param comp the component (ignored).
+ */
+ public void addLayoutComponent(String name, Component comp)
+ {
+ // Do nothing
+ }
+
+ /**
+ * Removes a component from the layout. This method does nothing, since
+ * the layout manager doesn't need to track the components.
+ *
+ * @param comp the component.
+ */
+ public void removeLayoutComponent(Component comp)
+ {
+ // Do nothing
+ }
+
+ /**
+ * Returns preferred layout size of the JComboBox.
+ *
+ * @param parent the Container for which the preferred size should be
+ * calculated.
+ *
+ * @return The preferred size for the given container
+ */
+ public Dimension preferredLayoutSize(Container parent)
+ {
+ return parent.getPreferredSize();
+ }
+
+ /**
+ * Returns the minimum layout size.
+ *
+ * @param parent the container.
+ *
+ * @return The minimum size.
+ */
+ public Dimension minimumLayoutSize(Container parent)
+ {
+ return parent.getMinimumSize();
+ }
+
+ /**
+ * Arranges the components in the container. It puts arrow
+ * button right end part of the comboBox. If the comboBox is editable
+ * then editor is placed to the left of arrow button, starting from the
+ * beginning.
+ *
+ * @param parent Container that should be layed out.
+ */
+ public void layoutContainer(Container parent)
+ {
+ // Position editor component to the left of arrow button if combo box is
+ // editable
+ Insets i = getInsets();
+ int arrowSize = comboBox.getHeight() - (i.top + i.bottom);
+ int editorWidth = comboBox.getBounds().width - arrowSize;
+
+ if (arrowButton != null)
+ arrowButton.setBounds(comboBox.getWidth() - (i.right + arrowSize),
+ i.top, arrowSize, arrowSize);
+ if (editor != null)
+ editor.setBounds(rectangleForCurrentValue());
+ }
+ }
+
+ /**
+ * Handles focus changes occuring in the combo box. This class is
+ * responsible for repainting combo box whenever focus is gained or lost
+ * and also for hiding popup list of items whenever combo box loses its
+ * focus.
+ */
+ public class FocusHandler extends Object implements FocusListener
+ {
+ /**
+ * Creates a new FocusHandler object.
+ */
+ public FocusHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Invoked when combo box gains focus. It repaints main
+ * part of combo box accordingly.
+ *
+ * @param e the FocusEvent
+ */
+ public void focusGained(FocusEvent e)
+ {
+ hasFocus = true;
+ comboBox.repaint();
+ }
+
+ /**
+ * Invoked when the combo box loses focus. It repaints the main part
+ * of the combo box accordingly and hides the popup list of items.
+ *
+ * @param e the FocusEvent
+ */
+ public void focusLost(FocusEvent e)
+ {
+ hasFocus = false;
+ if (! e.isTemporary() && comboBox.isLightWeightPopupEnabled())
+ setPopupVisible(comboBox, false);
+ comboBox.repaint();
+ }
+ }
+
+ /**
+ * Handles {@link ItemEvent}s fired by the {@link JComboBox} when its
+ * selected item changes.
+ */
+ public class ItemHandler extends Object implements ItemListener
+ {
+ /**
+ * Creates a new ItemHandler object.
+ */
+ public ItemHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Invoked when selected item becomes deselected or when
+ * new item becomes selected.
+ *
+ * @param e the ItemEvent representing item's state change.
+ */
+ public void itemStateChanged(ItemEvent e)
+ {
+ ComboBoxModel model = comboBox.getModel();
+ Object v = model.getSelectedItem();
+ if (editor != null)
+ comboBox.configureEditor(comboBox.getEditor(), v);
+ comboBox.repaint();
+ }
+ }
+
+ /**
+ * KeyHandler handles key events occuring while JComboBox has focus.
+ */
+ public class KeyHandler extends KeyAdapter
+ {
+ public KeyHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Invoked whenever key is pressed while JComboBox is in focus.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ if (comboBox.getModel().getSize() != 0 && comboBox.isEnabled())
+ {
+ if (! isNavigationKey(e.getKeyCode()))
+ {
+ if (! comboBox.isEditable())
+ if (comboBox.selectWithKeyChar(e.getKeyChar()))
+ e.consume();
+ }
+ else
+ {
+ if (e.getKeyCode() == KeyEvent.VK_UP && comboBox.isPopupVisible())
+ selectPreviousPossibleValue();
+ else if (e.getKeyCode() == KeyEvent.VK_DOWN)
+ {
+ if (comboBox.isPopupVisible())
+ selectNextPossibleValue();
+ else
+ comboBox.showPopup();
+ }
+ else if (e.getKeyCode() == KeyEvent.VK_ENTER
+ || e.getKeyCode() == KeyEvent.VK_ESCAPE)
+ popup.hide();
+ }
+ }
+ }
+ }
+
+ /**
+ * Handles the changes occurring in the JComboBox's data model.
+ */
+ public class ListDataHandler extends Object implements ListDataListener
+ {
+ /**
+ * Creates a new ListDataHandler object.
+ */
+ public ListDataHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Invoked if the content's of JComboBox's data model are changed.
+ *
+ * @param e ListDataEvent describing the change.
+ */
+ public void contentsChanged(ListDataEvent e)
+ {
+ if (e.getIndex0() != -1 || e.getIndex1() != -1)
+ {
+ isMinimumSizeDirty = true;
+ comboBox.revalidate();
+ }
+ if (editor != null)
+ comboBox.configureEditor(comboBox.getEditor(),
+ comboBox.getSelectedItem());
+ comboBox.repaint();
+ }
+
+ /**
+ * Invoked when items are added to the JComboBox's data model.
+ *
+ * @param e ListDataEvent describing the change.
+ */
+ public void intervalAdded(ListDataEvent e)
+ {
+ int start = e.getIndex0();
+ int end = e.getIndex1();
+ if (start == 0 && comboBox.getItemCount() - (end - start + 1) == 0)
+ contentsChanged(e);
+ else if (start != -1 || end != -1)
+ {
+ ListCellRenderer renderer = comboBox.getRenderer();
+ ComboBoxModel model = comboBox.getModel();
+ int w = displaySize.width;
+ int h = displaySize.height;
+ // TODO: Optimize using prototype here.
+ for (int i = start; i <= end; ++i)
+ {
+ Component comp = renderer.getListCellRendererComponent(listBox,
+ model.getElementAt(i), -1, false, false);
+ currentValuePane.add(comp);
+ comp.setFont(comboBox.getFont());
+ Dimension dim = comp.getPreferredSize();
+ w = Math.max(w, dim.width);
+ h = Math.max(h, dim.height);
+ currentValuePane.remove(comp);
+ }
+ if (displaySize.width < w || displaySize.height < h)
+ {
+ if (displaySize.width < w)
+ displaySize.width = w;
+ if (displaySize.height < h)
+ displaySize.height = h;
+ comboBox.revalidate();
+ if (editor != null)
+ {
+ comboBox.configureEditor(comboBox.getEditor(),
+ comboBox.getSelectedItem());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Invoked when items are removed from the JComboBox's
+ * data model.
+ *
+ * @param e ListDataEvent describing the change.
+ */
+ public void intervalRemoved(ListDataEvent e)
+ {
+ contentsChanged(e);
+ }
+ }
+
+ /**
+ * Handles {@link PropertyChangeEvent}s fired by the {@link JComboBox}.
+ */
+ public class PropertyChangeHandler extends Object
+ implements PropertyChangeListener
+ {
+ /**
+ * Creates a new instance.
+ */
+ public PropertyChangeHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Invoked whenever bound property of JComboBox changes.
+ *
+ * @param e the event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ // Lets assume every change invalidates the minimumsize.
+ isMinimumSizeDirty = true;
+
+ if (e.getPropertyName().equals("enabled"))
+ {
+ arrowButton.setEnabled(comboBox.isEnabled());
+
+ if (comboBox.isEditable())
+ comboBox.getEditor().getEditorComponent().setEnabled(
+ comboBox.isEnabled());
+ }
+ else if (e.getPropertyName().equals("editable"))
+ {
+ if (comboBox.isEditable())
+ {
+ configureEditor();
+ addEditor();
+ }
+ else
+ {
+ unconfigureEditor();
+ removeEditor();
+ }
+
+ comboBox.revalidate();
+ comboBox.repaint();
+ }
+ else if (e.getPropertyName().equals("dataModel"))
+ {
+ // remove ListDataListener from old model and add it to new model
+ ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue();
+ if (oldModel != null)
+ oldModel.removeListDataListener(listDataListener);
+
+ if ((ComboBoxModel) e.getNewValue() != null)
+ comboBox.getModel().addListDataListener(listDataListener);
+ }
+ else if (e.getPropertyName().equals("font"))
+ {
+ Font font = (Font) e.getNewValue();
+ editor.setFont(font);
+ listBox.setFont(font);
+ arrowButton.setFont(font);
+ comboBox.revalidate();
+ comboBox.repaint();
+ }
+
+ // FIXME: Need to handle changes in other bound properties.
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1119 @@
+/* BasicComboPopup.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionAdapter;
+import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.ComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.ListCellRenderer;
+import javax.swing.ListSelectionModel;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.UIManager;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+
+/**
+ * UI Delegate for ComboPopup
+ *
+ * @author Olga Rodimina
+ */
+public class BasicComboPopup extends JPopupMenu implements ComboPopup
+{
+ /* Timer for autoscrolling */
+ protected Timer autoscrollTimer;
+
+ /** ComboBox associated with this popup */
+ protected JComboBox comboBox;
+
+ /** FIXME: Need to document */
+ protected boolean hasEntered;
+
+ /**
+ * Indicates whether the scroll bar located in popup menu with comboBox's
+ * list of items is currently autoscrolling. This happens when mouse event
+ * originated in the combo box and is dragged outside of its bounds
+ */
+ protected boolean isAutoScrolling;
+
+ /** ItemListener listening to the selection changes in the combo box */
+ protected ItemListener itemListener;
+
+ /** This listener is not used */
+ protected KeyListener keyListener;
+
+ /** JList which is used to display item is the combo box */
+ protected JList list;
+
+ /** This listener is not used */
+ protected ListDataListener listDataListener;
+
+ /**
+ * MouseListener listening to mouse events occuring in the combo box's
+ * list.
+ */
+ protected MouseListener listMouseListener;
+
+ /**
+ * MouseMotionListener listening to mouse motion events occuring in the
+ * combo box's list
+ */
+ protected MouseMotionListener listMouseMotionListener;
+
+ /** This listener is not used */
+ protected ListSelectionListener listSelectionListener;
+
+ /** MouseListener listening to mouse events occuring in the combo box */
+ protected MouseListener mouseListener;
+
+ /**
+ * MouseMotionListener listening to mouse motion events occuring in the
+ * combo box
+ */
+ protected MouseMotionListener mouseMotionListener;
+
+ /**
+ * PropertyChangeListener listening to changes occuring in the bound
+ * properties of the combo box
+ */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /** direction for scrolling down list of combo box's items */
+ protected static final int SCROLL_DOWN = 1;
+
+ /** direction for scrolling up list of combo box's items */
+ protected static final int SCROLL_UP = 0;
+
+ /** Indicates auto scrolling direction */
+ protected int scrollDirection;
+
+ /** JScrollPane that contains list portion of the combo box */
+ protected JScrollPane scroller;
+
+ /** This field is not used */
+ protected boolean valueIsAdjusting;
+
+ /**
+ * Creates a new BasicComboPopup object.
+ *
+ * @param comboBox the combo box with which this popup should be associated
+ */
+ public BasicComboPopup(JComboBox comboBox)
+ {
+ this.comboBox = comboBox;
+ mouseListener = createMouseListener();
+ mouseMotionListener = createMouseMotionListener();
+ keyListener = createKeyListener();
+
+ list = createList();
+ configureList();
+ scroller = createScroller();
+ configureScroller();
+ configurePopup();
+ installComboBoxListeners();
+ installKeyboardActions();
+ }
+
+ /**
+ * This method displays drow down list of combo box items on the screen.
+ */
+ public void show()
+ {
+ Dimension size = comboBox.getSize();
+ size.height = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
+ Insets i = getInsets();
+ size.width -= i.left + i.right;
+ Rectangle bounds = computePopupBounds(0, comboBox.getBounds().height,
+ size.width, size.height);
+
+ scroller.setMaximumSize(bounds.getSize());
+ scroller.setPreferredSize(bounds.getSize());
+ scroller.setMinimumSize(bounds.getSize());
+ list.invalidate();
+
+ syncListSelection();
+
+ list.ensureIndexIsVisible(list.getSelectedIndex());
+ setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
+ show(comboBox, bounds.x, bounds.y);
+ }
+
+ /**
+ * This method hides drop down list of items
+ */
+ public void hide()
+ {
+ MenuSelectionManager menuSelectionManager =
+ MenuSelectionManager.defaultManager();
+ javax.swing.MenuElement[] menuElements =
+ menuSelectionManager.getSelectedPath();
+ for (int i = 0; i < menuElements.length; i++)
+ {
+ if (menuElements[i] == this)
+ {
+ menuSelectionManager.clearSelectedPath();
+ break;
+ }
+ }
+ comboBox.repaint();
+ }
+
+ /**
+ * Return list cointaining JComboBox's items
+ *
+ * @return list cointaining JComboBox's items
+ */
+ public JList getList()
+ {
+ return list;
+ }
+
+ /**
+ * Returns MouseListener that is listening to mouse events occuring in the
+ * combo box.
+ *
+ * @return MouseListener
+ */
+ public MouseListener getMouseListener()
+ {
+ return mouseListener;
+ }
+
+ /**
+ * Returns MouseMotionListener that is listening to mouse motion events
+ * occuring in the combo box.
+ *
+ * @return MouseMotionListener
+ */
+ public MouseMotionListener getMouseMotionListener()
+ {
+ return mouseMotionListener;
+ }
+
+ /**
+ * Returns KeyListener listening to key events occuring in the combo box.
+ * This method returns null because KeyHandler is not longer used.
+ *
+ * @return KeyListener
+ */
+ public KeyListener getKeyListener()
+ {
+ return keyListener;
+ }
+
+ /**
+ * This method uninstalls the UI for the given JComponent.
+ */
+ public void uninstallingUI()
+ {
+ uninstallComboBoxModelListeners(comboBox.getModel());
+ uninstallListeners();
+ uninstallKeyboardActions();
+ }
+
+ /**
+ * This method uninstalls listeners that were listening to changes occuring
+ * in the comb box's data model
+ *
+ * @param model data model for the combo box from which to uninstall
+ * listeners
+ */
+ protected void uninstallComboBoxModelListeners(ComboBoxModel model)
+ {
+ model.removeListDataListener(listDataListener);
+ }
+
+ /**
+ * This method uninstalls keyboard actions installed by the UI.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method fires PopupMenuEvent indicating that combo box's popup list
+ * of items will become visible
+ */
+ protected void firePopupMenuWillBecomeVisible()
+ {
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox));
+ }
+
+ /**
+ * This method fires PopupMenuEvent indicating that combo box's popup list
+ * of items will become invisible.
+ */
+ protected void firePopupMenuWillBecomeInvisible()
+ {
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox));
+ }
+
+ /**
+ * This method fires PopupMenuEvent indicating that combo box's popup list
+ * of items was closed without selection.
+ */
+ protected void firePopupMenuCanceled()
+ {
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuCanceled(new PopupMenuEvent(comboBox));
+ }
+
+ /**
+ * Creates MouseListener to listen to mouse events occuring in the combo
+ * box. Note that this listener doesn't listen to mouse events occuring in
+ * the popup portion of the combo box, it only listens to main combo box
+ * part.
+ *
+ * @return new MouseMotionListener that listens to mouse events occuring in
+ * the combo box
+ */
+ protected MouseListener createMouseListener()
+ {
+ return new InvocationMouseHandler();
+ }
+
+ /**
+ * Create Mouse listener that listens to mouse dragging events occuring in
+ * the combo box. This listener is responsible for changing the selection
+ * in the combo box list to the component over which mouse is being
+ * currently dragged
+ *
+ * @return new MouseMotionListener that listens to mouse dragging events
+ * occuring in the combo box
+ */
+ protected MouseMotionListener createMouseMotionListener()
+ {
+ return new InvocationMouseMotionHandler();
+ }
+
+ /**
+ * KeyListener created in this method is not used anymore.
+ *
+ * @return KeyListener that does nothing
+ */
+ protected KeyListener createKeyListener()
+ {
+ return new InvocationKeyHandler();
+ }
+
+ /**
+ * ListSelectionListener created in this method is not used anymore
+ *
+ * @return ListSelectionListener that does nothing
+ */
+ protected ListSelectionListener createListSelectionListener()
+ {
+ return new ListSelectionHandler();
+ }
+
+ /**
+ * Creates ListDataListener. This method returns null, because
+ * ListDataHandler class is obsolete and is no longer used.
+ *
+ * @return null
+ */
+ protected ListDataListener createListDataListener()
+ {
+ return null;
+ }
+
+ /**
+ * This method creates ListMouseListener to listen to mouse events occuring
+ * in the combo box's item list.
+ *
+ * @return MouseListener to listen to mouse events occuring in the combo
+ * box's items list.
+ */
+ protected MouseListener createListMouseListener()
+ {
+ return new ListMouseHandler();
+ }
+
+ /**
+ * Creates ListMouseMotionlistener to listen to mouse motion events occuring
+ * in the combo box's list. This listener is responsible for highlighting
+ * items in the list when mouse is moved over them.
+ *
+ * @return MouseMotionListener that handles mouse motion events occuring in
+ * the list of the combo box.
+ */
+ protected MouseMotionListener createListMouseMotionListener()
+ {
+ return new ListMouseMotionHandler();
+ }
+
+ /**
+ * Creates PropertyChangeListener to handle changes in the JComboBox's bound
+ * properties.
+ *
+ * @return PropertyChangeListener to handle changes in the JComboBox's bound
+ * properties.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Creates new ItemListener that will listen to ItemEvents occuring in the
+ * combo box.
+ *
+ * @return ItemListener to listen to ItemEvents occuring in the combo box.
+ */
+ protected ItemListener createItemListener()
+ {
+ return new ItemHandler();
+ }
+
+ /**
+ * Creates JList that will be used to display items in the combo box.
+ *
+ * @return JList that will be used to display items in the combo box.
+ */
+ protected JList createList()
+ {
+ JList l = new JList(comboBox.getModel());
+ return l;
+ }
+
+ /**
+ * This method configures the list of comboBox's items by setting default
+ * properties and installing listeners.
+ */
+ protected void configureList()
+ {
+ list.setFont(comboBox.getFont());
+ list.setForeground(comboBox.getForeground());
+ list.setBackground(comboBox.getBackground());
+ Color sfg = UIManager.getColor("ComboBox.selectionForeground");
+ list.setSelectionForeground(sfg);
+ Color sbg = UIManager.getColor("ComboBox.selectionBackground");
+ list.setSelectionBackground(sbg);
+ list.setBorder(null);
+ list.setCellRenderer(comboBox.getRenderer());
+ list.setFocusable(false);
+ syncListSelection();
+ list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ installListListeners();
+ }
+
+ /**
+ * This method installs list listeners.
+ */
+ protected void installListListeners()
+ {
+ // mouse listener listening to mouse events occuring in the
+ // combo box's list of items.
+ listMouseListener = createListMouseListener();
+ list.addMouseListener(listMouseListener);
+
+ // mouse listener listening to mouse motion events occuring in the
+ // combo box's list of items
+ listMouseMotionListener = createListMouseMotionListener();
+ list.addMouseMotionListener(listMouseMotionListener);
+
+ listSelectionListener = createListSelectionListener();
+ list.addListSelectionListener(listSelectionListener);
+ }
+
+ /**
+ * This method creates scroll pane that will contain the list of comboBox's
+ * items inside of it.
+ *
+ * @return JScrollPane
+ */
+ protected JScrollPane createScroller()
+ {
+ return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ }
+
+ /**
+ * This method configures scroll pane to contain list of comboBox's items
+ */
+ protected void configureScroller()
+ {
+ scroller.setBorder(null);
+ scroller.setFocusable(false);
+ scroller.getVerticalScrollBar().setFocusable(false);
+ }
+
+ /**
+ * This method configures popup menu that will be used to display Scrollpane
+ * with list of items inside of it.
+ */
+ protected void configurePopup()
+ {
+ setBorderPainted(true);
+ setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ setOpaque(false);
+ add(scroller);
+ setFocusable(false);
+ }
+
+ /*
+ * This method installs listeners that will listen to changes occuring
+ * in the combo box.
+ */
+ protected void installComboBoxListeners()
+ {
+ // item listener listenening to selection events in the combo box
+ itemListener = createItemListener();
+ comboBox.addItemListener(itemListener);
+
+ propertyChangeListener = createPropertyChangeListener();
+ comboBox.addPropertyChangeListener(propertyChangeListener);
+
+ installComboBoxModelListeners(comboBox.getModel());
+ }
+
+ /**
+ * This method installs listeners that will listen to changes occuring in
+ * the comb box's data model
+ *
+ * @param model data model for the combo box for which to install listeners
+ */
+ protected void installComboBoxModelListeners(ComboBoxModel model)
+ {
+ // list data listener to listen for ListDataEvents in combo box.
+ // This listener is now obsolete and nothing is done here
+ listDataListener = createListDataListener();
+ comboBox.getModel().addListDataListener(listDataListener);
+ }
+
+ /**
+ * Installs the keyboard actions.
+ */
+ protected void installKeyboardActions()
+ {
+ // Nothing to do here
+ }
+
+ /**
+ * This method always returns false to indicate that items in the combo box
+ * list are not focus traversable.
+ *
+ * @return false
+ */
+ public boolean isFocusTraversable()
+ {
+ return false;
+ }
+
+ /**
+ * This method start scrolling combo box's list of items either up or down
+ * depending on the specified 'direction'
+ *
+ * @param direction of the scrolling.
+ */
+ protected void startAutoScrolling(int direction)
+ {
+ // FIXME: add timer
+ isAutoScrolling = true;
+
+ if (direction == SCROLL_UP)
+ autoScrollUp();
+ else
+ autoScrollDown();
+ }
+
+ /**
+ * This method stops scrolling the combo box's list of items
+ */
+ protected void stopAutoScrolling()
+ {
+ // FIXME: add timer
+ isAutoScrolling = false;
+ }
+
+ /**
+ * This method scrolls up list of combo box's items up and highlights that
+ * just became visible.
+ */
+ protected void autoScrollUp()
+ {
+ // scroll up the scroll bar to make the item above visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_UP);
+
+ scrollbar.setValue(scrollbar.getValue() - scrollToNext);
+
+ // If we haven't reached the begging of the combo box's list of items,
+ // then highlight next element above currently highlighted element
+ if (list.getSelectedIndex() != 0)
+ list.setSelectedIndex(list.getSelectedIndex() - 1);
+ }
+
+ /**
+ * This method scrolls down list of combo box's and highlights item in the
+ * list that just became visible.
+ */
+ protected void autoScrollDown()
+ {
+ // scroll scrollbar down to make next item visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_DOWN);
+ scrollbar.setValue(scrollbar.getValue() + scrollToNext);
+
+ // If we haven't reached the end of the combo box's list of items
+ // then highlight next element below currently highlighted element
+ if (list.getSelectedIndex() + 1 != comboBox.getItemCount())
+ list.setSelectedIndex(list.getSelectedIndex() + 1);
+ }
+
+ /**
+ * This method helps to delegate focus to the right component in the
+ * JComboBox. If the comboBox is editable then focus is sent to
+ * ComboBoxEditor, otherwise it is delegated to JComboBox.
+ *
+ * @param e MouseEvent
+ */
+ protected void delegateFocus(MouseEvent e)
+ {
+ if (comboBox.isEditable())
+ comboBox.getEditor().getEditorComponent().requestFocus();
+ else
+ comboBox.requestFocus();
+ }
+
+ /**
+ * This method displays combo box popup if the popup is not currently shown
+ * on the screen and hides it if it is currently visible
+ */
+ protected void togglePopup()
+ {
+ if (isVisible())
+ hide();
+ else
+ show();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected MouseEvent convertMouseEvent(MouseEvent e)
+ {
+ Point point = SwingUtilities.convertPoint((Component) e.getSource(),
+ e.getPoint(), list);
+ MouseEvent newEvent = new MouseEvent((Component) e.getSource(),
+ e.getID(), e.getWhen(),
+ e.getModifiers(), point.x, point.y,
+ e.getModifiers(),
+ e.isPopupTrigger());
+ return newEvent;
+ }
+
+ /**
+ * Returns required height of the popup such that number of items visible in
+ * it are equal to the maximum row count. By default
+ * comboBox.maximumRowCount=8
+ *
+ * @param maxRowCount number of maximum visible rows in the combo box's
+ * popup list of items
+ *
+ * @return height of the popup required to fit number of items equal to
+ * JComboBox.maximumRowCount.
+ */
+ protected int getPopupHeightForRowCount(int maxRowCount)
+ {
+ int totalHeight = 0;
+ ListCellRenderer rend = list.getCellRenderer();
+
+ if (comboBox.getItemCount() < maxRowCount)
+ maxRowCount = comboBox.getItemCount();
+
+ for (int i = 0; i < maxRowCount; i++)
+ {
+ Component comp = rend.getListCellRendererComponent(list,
+ comboBox.getModel()
+ .getElementAt(i),
+ -1, false, false);
+ Dimension dim = comp.getPreferredSize();
+ totalHeight += dim.height;
+ }
+
+ return totalHeight == 0 ? 100 : totalHeight;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param px DOCUMENT ME!
+ * @param py DOCUMENT ME!
+ * @param pw DOCUMENT ME!
+ * @param ph DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected Rectangle computePopupBounds(int px, int py, int pw, int ph)
+ {
+ return new Rectangle(px, py, pw, ph);
+ }
+
+ /**
+ * This method changes the selection in the list to the item over which the
+ * mouse is currently located.
+ *
+ * @param anEvent MouseEvent
+ * @param shouldScroll DOCUMENT ME!
+ */
+ protected void updateListBoxSelectionForEvent(MouseEvent anEvent,
+ boolean shouldScroll)
+ {
+ Point point = anEvent.getPoint();
+ if (list != null)
+ {
+ int index = list.locationToIndex(point);
+ if (index == -1)
+ {
+ if (point.y < 0)
+ index = 0;
+ else
+ index = comboBox.getModel().getSize() - 1;
+ }
+ if (list.getSelectedIndex() != index)
+ {
+ list.setSelectedIndex(index);
+ if (shouldScroll)
+ list.ensureIndexIsVisible(index);
+ }
+ }
+ }
+
+ /**
+ * InvocationMouseHandler is a listener that listens to mouse events
+ * occuring in the combo box. Note that this listener doesn't listen to
+ * mouse events occuring in the popup portion of the combo box, it only
+ * listens to main combo box part(area that displays selected item). This
+ * listener is responsible for showing and hiding popup portion of the
+ * combo box.
+ */
+ protected class InvocationMouseHandler extends MouseAdapter
+ {
+ /**
+ * Creates a new InvocationMouseHandler object.
+ */
+ protected InvocationMouseHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is invoked whenever mouse is being pressed over the main
+ * part of the combo box. This method will show popup if the popup is
+ * not shown on the screen right now, and it will hide popup otherwise.
+ *
+ * @param e MouseEvent that should be handled
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ if (SwingUtilities.isLeftMouseButton(e) && comboBox.isEnabled())
+ {
+ delegateFocus(e);
+ togglePopup();
+ }
+ }
+
+ /**
+ * This method is invoked whenever mouse event was originated in the combo
+ * box and released either in the combBox list of items or in the combo
+ * box itself.
+ *
+ * @param e MouseEvent that should be handled
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ Component component = (Component) e.getSource();
+ Dimension size = component.getSize();
+ Rectangle bounds = new Rectangle(0, 0, size.width - 1, size.height - 1);
+ // If mouse was released inside the bounds of combo box then do nothing,
+ // Otherwise if mouse was released inside the list of combo box items
+ // then change selection and close popup
+ if (! bounds.contains(e.getPoint()))
+ {
+ MouseEvent convEvent = convertMouseEvent(e);
+ Point point = convEvent.getPoint();
+ Rectangle visRect = new Rectangle();
+ list.computeVisibleRect(visRect);
+ if (visRect.contains(point))
+ {
+ updateListBoxSelectionForEvent(convEvent, false);
+ comboBox.setSelectedIndex(list.getSelectedIndex());
+ }
+ hide();
+ }
+ hasEntered = false;
+ stopAutoScrolling();
+ }
+ }
+
+ /**
+ * InvocationMouseMotionListener is a mouse listener that listens to mouse
+ * dragging events occuring in the combo box.
+ */
+ protected class InvocationMouseMotionHandler extends MouseMotionAdapter
+ {
+ /**
+ * Creates a new InvocationMouseMotionHandler object.
+ */
+ protected InvocationMouseMotionHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is responsible for highlighting item in the drop down list
+ * over which the mouse is currently being dragged.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ if (isVisible())
+ {
+ MouseEvent convEvent = convertMouseEvent(e);
+ Rectangle visRect = new Rectangle();
+ list.computeVisibleRect(visRect);
+ if (convEvent.getPoint().y >= visRect.y
+ && (convEvent.getPoint().y <= visRect.y + visRect.height - 1))
+ {
+ hasEntered = true;
+ if (isAutoScrolling)
+ stopAutoScrolling();
+ Point point = convEvent.getPoint();
+ if (visRect.contains(point))
+ {
+ valueIsAdjusting = true;
+ updateListBoxSelectionForEvent(convEvent, false);
+ valueIsAdjusting = false;
+ }
+ }
+ else if (hasEntered)
+ {
+ int dir = convEvent.getPoint().y < visRect.y ? SCROLL_UP
+ : SCROLL_DOWN;
+ if (isAutoScrolling && scrollDirection != dir)
+ {
+ stopAutoScrolling();
+ startAutoScrolling(dir);
+ }
+ else if (!isAutoScrolling)
+ startAutoScrolling(dir);
+ }
+ else if (e.getPoint().y < 0)
+ {
+ hasEntered = true;
+ startAutoScrolling(SCROLL_UP);
+ }
+ }
+ }
+ }
+
+ /**
+ * ItemHandler is an item listener that listens to selection events occuring
+ * in the combo box. FIXME: should specify here what it does when item is
+ * selected or deselected in the combo box list.
+ */
+ protected class ItemHandler extends Object implements ItemListener
+ {
+ /**
+ * Creates a new ItemHandler object.
+ */
+ protected ItemHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method responds to the selection events occuring in the combo box.
+ *
+ * @param e ItemEvent specifying the combo box's selection
+ */
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (e.getStateChange() == ItemEvent.SELECTED && ! valueIsAdjusting)
+ {
+ valueIsAdjusting = true;
+ syncListSelection();
+ valueIsAdjusting = false;
+ list.ensureIndexIsVisible(comboBox.getSelectedIndex());
+ }
+ }
+ }
+
+ /**
+ * ListMouseHandler is a listener that listens to mouse events occuring in
+ * the combo box's list of items. This class is responsible for hiding
+ * popup portion of the combo box if the mouse is released inside the combo
+ * box's list.
+ */
+ protected class ListMouseHandler extends MouseAdapter
+ {
+ protected ListMouseHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ public void mouseReleased(MouseEvent anEvent)
+ {
+ comboBox.setSelectedIndex(list.getSelectedIndex());
+ hide();
+ }
+ }
+
+ /**
+ * ListMouseMotionHandler listens to mouse motion events occuring in the
+ * combo box's list. This class is responsible for highlighting items in
+ * the list when mouse is moved over them
+ */
+ protected class ListMouseMotionHandler extends MouseMotionAdapter
+ {
+ protected ListMouseMotionHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void mouseMoved(MouseEvent anEvent)
+ {
+ Point point = anEvent.getPoint();
+ Rectangle visRect = new Rectangle();
+ list.computeVisibleRect(visRect);
+ if (visRect.contains(point))
+ {
+ valueIsAdjusting = true;
+ updateListBoxSelectionForEvent(anEvent, false);
+ valueIsAdjusting = false;
+ }
+ }
+ }
+
+ /**
+ * This class listens to changes occuring in the bound properties of the
+ * combo box
+ */
+ protected class PropertyChangeHandler extends Object
+ implements PropertyChangeListener
+ {
+ protected PropertyChangeHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("renderer"))
+ {
+ list.setCellRenderer(comboBox.getRenderer());
+ if (isVisible())
+ hide();
+ }
+ if (e.getPropertyName().equals("model"))
+ {
+ ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue();
+ uninstallComboBoxModelListeners(oldModel);
+ ComboBoxModel newModel = (ComboBoxModel) e.getNewValue();
+ list.setModel(newModel);
+ installComboBoxModelListeners(newModel);
+ if (comboBox.getItemCount() > 0)
+ comboBox.setSelectedIndex(0);
+ if (isVisible())
+ hide();
+ }
+ }
+ }
+
+ // ------ private helper methods --------------------
+
+ /**
+ * This method uninstalls listeners installed by the UI
+ */
+ private void uninstallListeners()
+ {
+ uninstallComboBoxListeners();
+ uninstallComboBoxModelListeners(comboBox.getModel());
+ }
+
+ /**
+ * This method uninstalls Listeners registered with combo boxes list of
+ * items
+ */
+ private void uninstallListListeners()
+ {
+ list.removeMouseListener(listMouseListener);
+ listMouseListener = null;
+
+ list.removeMouseMotionListener(listMouseMotionListener);
+ listMouseMotionListener = null;
+ }
+
+ /**
+ * This method uninstalls listeners listening to combo box associated with
+ * this popup menu
+ */
+ private void uninstallComboBoxListeners()
+ {
+ comboBox.removeItemListener(itemListener);
+ itemListener = null;
+
+ comboBox.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+
+ void syncListSelection()
+ {
+ int index = comboBox.getSelectedIndex();
+ if (index == -1)
+ list.clearSelection();
+ else
+ list.setSelectedIndex(index);
+ }
+
+ // --------------------------------------------------------------------
+ // The following classes are here only for backwards API compatibility
+ // They aren't used.
+ // --------------------------------------------------------------------
+
+ /**
+ * This class is not used any more.
+ */
+ public class ListDataHandler extends Object implements ListDataListener
+ {
+ public ListDataHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void contentsChanged(ListDataEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ public void intervalAdded(ListDataEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ public void intervalRemoved(ListDataEvent e)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * This class is not used anymore
+ */
+ protected class ListSelectionHandler extends Object
+ implements ListSelectionListener
+ {
+ protected ListSelectionHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * This class is not used anymore
+ */
+ public class InvocationKeyHandler extends KeyAdapter
+ {
+ public InvocationKeyHandler()
+ {
+ // Nothing to do here.
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ // Nothing to do here.
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopIconUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopIconUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopIconUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopIconUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,592 @@
+/* BasicDesktopIconUI.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDesktopPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JInternalFrame.JDesktopIcon;
+import javax.swing.SwingConstants;
+import javax.swing.border.Border;
+import javax.swing.event.MouseInputAdapter;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopIconUI;
+
+/**
+ * This class acts as the UI delegate for JDesktopIcons for the Basic look and feel.
+ */
+public class BasicDesktopIconUI extends DesktopIconUI
+{
+ /**
+ * This helper class handles mouse events that occur on the JDesktopIcon.
+ */
+ public class MouseInputHandler extends MouseInputAdapter
+ {
+ /** The x offset from the MouseEvent coordinates to the top left corner. */
+ private transient int xOffset;
+
+ /** The y offset fromt he MouseEvent coordinates to the top left corner. */
+ private transient int yOffset;
+
+ /** A cached value of the JDesktopPane that parents this JDesktopIcon. */
+ private transient JDesktopPane pane;
+
+ /**
+ * This method is called when the mouse is dragged in the JDesktopIcon.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ Rectangle b = desktopIcon.getBounds();
+
+ moveAndRepaint(desktopIcon, b.x + e.getX() - xOffset,
+ b.y + e.getY() - yOffset, b.width, b.height);
+ }
+
+ /**
+ * This method is called when the mouse is moved in the JDesktopIcon.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ // Nothing to do.
+ }
+
+ /**
+ * This method is called when the mouse is pressed in the JDesktopIcon.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ xOffset = e.getX();
+ yOffset = e.getY();
+ pane = frame.getDesktopPane();
+ if (pane != null)
+ pane.getDesktopManager().beginDraggingFrame(desktopIcon);
+ }
+
+ /**
+ * This method is called when the mouse is released in the JDesktopIcon.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ if (pane != null)
+ pane.getDesktopManager().endDraggingFrame(desktopIcon);
+ xOffset = 0;
+ yOffset = 0;
+ }
+
+ /**
+ * This method moves and repaints the JDesktopIcon to the given bounds.
+ *
+ * @param f The JComponent to move and repaint.
+ * @param newX The new x coordinate.
+ * @param newY The new y coordinate.
+ * @param newWidth The new width.
+ * @param newHeight The new height.
+ */
+ public void moveAndRepaint(JComponent f, int newX, int newY, int newWidth,
+ int newHeight)
+ {
+ if (pane != null)
+ pane.getDesktopManager().dragFrame(f, newX, newY);
+ else
+ desktopIcon.setBounds(newX, newY, newWidth, newHeight);
+ }
+ }
+
+ /**
+ * This class acts as the border for the JDesktopIcon.
+ */
+ private class DesktopIconBorder implements Border
+ {
+ /** The left inset value. */
+ int left = 10;
+
+ /** The top inset value. */
+ int top = 4;
+
+ /** The right inset value. */
+ int right = top;
+
+ /** The bottom inset value. */
+ int bottom = top;
+
+ /**
+ * This method returns the insets of the border.
+ *
+ * @param c The Component to find border insets for.
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(top, left, bottom, right);
+ }
+
+ /**
+ * This method returns whether the border is opaque.
+ *
+ * @return Whether the border is opaque.
+ */
+ public boolean isBorderOpaque()
+ {
+ return true;
+ }
+
+ /**
+ * This method paints the border.
+ *
+ * @param c The Component the border is in.
+ * @param g The Graphics object to paint with.
+ * @param x The x coordinate of the Component.
+ * @param y The y coordinate of the Component.
+ * @param width The width of the Component.
+ * @param height The height of the Component.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int width,
+ int height)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+
+ g.setColor(Color.LIGHT_GRAY);
+
+ g.fillRect(0, 0, left, height);
+ g.fillRect(0, 0, width, top);
+ g.fillRect(0, height - bottom, width, bottom);
+ g.fillRect(width - right, 0, right, height);
+
+ g.setColor(Color.BLACK);
+ g.drawRect(0, 0, width - 1, height - 1);
+
+ int fHeight = height / 4;
+ int hLeft = left / 2;
+
+ g.setColor(Color.BLACK);
+ g.fillRect(hLeft, fHeight, 2, 2);
+ g.fillRect(hLeft, fHeight * 2, 2, 2);
+ g.fillRect(hLeft, fHeight * 3, 2, 2);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ }
+
+ /** The static width and height of the iconSize. */
+ private static final int iconSize = 16;
+
+ /**
+ * This class represents the default frame icon when none
+ * is supplied by the JInternalFrame.
+ */
+ static class InternalFrameDefaultMenuIcon implements Icon
+ {
+ /**
+ * This returns the icon height.
+ *
+ * @return The icon height.
+ */
+ public int getIconHeight()
+ {
+ return iconSize;
+ }
+
+ /**
+ * This returns the icon width.
+ *
+ * @return The icon width.
+ */
+ public int getIconWidth()
+ {
+ return iconSize;
+ }
+
+ /**
+ * This method paints the icon.
+ *
+ * @param c The Component this icon belongs to.
+ * @param g The Graphics object to paint with.
+ * @param x The x coordinate to paint at.
+ * @param y The y coordinate to paint at.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+
+ g.setColor(Color.BLUE);
+ g.fillRect(0, 0, iconSize, (int) ((double) iconSize / 3) + 1);
+
+ g.setColor(Color.WHITE);
+ g.fillRect(0, (int) ((double) iconSize / 3), iconSize, iconSize * 5 / 6);
+
+ g.setColor(Color.GRAY);
+ g.drawRect(0, 0, iconSize, iconSize);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ }
+
+ /** The default JDesktopIcon width. */
+ private static final int iconWidth = 160;
+
+ /** The default JDesktopIcon height */
+ private static final int iconHeight = 35;
+
+ /** The JDesktopIcon this UI delegate represents. */
+ protected JDesktopIcon desktopIcon;
+
+ /** The JInternalFrame associated with the JDesktopIcon. */
+ protected JInternalFrame frame;
+
+ /** The MouseListener responsible for reacting to MouseEvents on the JDesktopIcon. */
+ private transient MouseInputListener mouseHandler;
+
+ /** The Button in the JDesktopIcon responsible for deiconifying it.
+ * This is package-private to avoid an accessor method. */
+ transient BoundButton button;
+
+ /** The PropertyChangeListener listening to the JDesktopIcon. */
+ private transient PropertyChangeListener propertyHandler;
+
+ /** The default icon used when no frame icon is given by the JInternalFrame. */
+ static Icon defaultIcon = new InternalFrameDefaultMenuIcon();
+
+ /**
+ * This is a helper class that is used in JDesktopIcon and gives the Button a predetermined size.
+ */
+ private class BoundButton extends JButton
+ {
+ /**
+ * Creates a new BoundButton object.
+ *
+ * @param title The title of the button.
+ */
+ public BoundButton(String title)
+ {
+ super(title);
+ }
+
+ /**
+ * This method returns a standard size (based on the defaults of the JDesktopIcon) and the insets.
+ *
+ * @return The preferred size of the JDesktopIcon.
+ */
+ public Dimension getPreferredSize()
+ {
+ Insets insets = desktopIcon.getInsets();
+ return new Dimension(iconWidth - insets.left - insets.right,
+ iconHeight - insets.top - insets.bottom);
+ }
+
+ /**
+ * This method returns the minimum size of the button.
+ *
+ * @return The minimum size of the button.
+ */
+ public Dimension getMinimumSize()
+ {
+ return getPreferredSize();
+ }
+
+ /**
+ * This method returns the maximum size of the button.
+ *
+ * @return The maximum size of the button.
+ */
+ public Dimension getMaximumSize()
+ {
+ return getPreferredSize();
+ }
+ }
+
+ /**
+ * Creates a new BasicDesktopIconUI object.
+ */
+ public BasicDesktopIconUI()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method creates a new BasicDesktopIconUI for the given JComponent.
+ *
+ * @param c The JComponent to create a UI for.
+ *
+ * @return A new BasicDesktopIconUI.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicDesktopIconUI();
+ }
+
+ /**
+ * This method installs the UI for the given JComponent.
+ *
+ * @param c The JComponent to install this UI for.
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JDesktopIcon)
+ {
+ desktopIcon = (JDesktopIcon) c;
+ desktopIcon.setLayout(new BorderLayout());
+ frame = desktopIcon.getInternalFrame();
+
+ installDefaults();
+ installComponents();
+ installListeners();
+
+ desktopIcon.setOpaque(true);
+ }
+ }
+
+ /**
+ * This method uninstalls the UI for the given JComponent.
+ *
+ * @param c The JComponent to uninstall this UI for.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ desktopIcon.setOpaque(false);
+
+ uninstallListeners();
+ uninstallComponents();
+ uninstallDefaults();
+
+ frame = null;
+ desktopIcon.setLayout(null);
+ desktopIcon = null;
+ }
+
+ /**
+ * This method installs the necessary sub components for the JDesktopIcon.
+ */
+ protected void installComponents()
+ {
+ // Try to create a button based on what the frame's
+ // state is currently
+ button = new BoundButton(frame.getTitle());
+ button.setHorizontalAlignment(SwingConstants.LEFT);
+ button.setHorizontalTextPosition(SwingConstants.TRAILING);
+
+ Icon use = frame.getFrameIcon();
+ if (use == null)
+ use = defaultIcon;
+ button.setIcon(use);
+
+ desktopIcon.add(button, SwingConstants.CENTER);
+ }
+
+ /**
+ * This method uninstalls the sub components for the JDesktopIcon.
+ */
+ protected void uninstallComponents()
+ {
+ desktopIcon.remove(button);
+
+ button = null;
+ }
+
+ /**
+ * This method installs the listeners needed by this UI.
+ */
+ protected void installListeners()
+ {
+ mouseHandler = createMouseInputListener();
+
+ desktopIcon.addMouseMotionListener(mouseHandler);
+ desktopIcon.addMouseListener(mouseHandler);
+
+ propertyHandler = new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(JInternalFrame.TITLE_PROPERTY))
+ button.setText(desktopIcon.getInternalFrame().getTitle());
+ else if (e.getPropertyName().equals(JInternalFrame.FRAME_ICON_PROPERTY))
+ {
+ Icon use = desktopIcon.getInternalFrame().getFrameIcon();
+ if (use == null)
+ use = defaultIcon;
+ button.setIcon(use);
+ }
+ desktopIcon.revalidate();
+ desktopIcon.repaint();
+ }
+ };
+ frame.addPropertyChangeListener(propertyHandler);
+
+ button.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ deiconize();
+ }
+ });
+ }
+
+ /**
+ * This method uninstalls the listeners needed by the UI.
+ */
+ protected void uninstallListeners()
+ {
+ // button is nulled so no need to remove it.
+
+ frame.removePropertyChangeListener(propertyHandler);
+ propertyHandler = null;
+
+ desktopIcon.removeMouseMotionListener(mouseHandler);
+ desktopIcon.removeMouseListener(mouseHandler);
+ }
+
+ /**
+ * This method installs the defaults for the JDesktopIcon.
+ */
+ protected void installDefaults()
+ {
+ // FIXME: Move border to defaults.
+ desktopIcon.setBorder(new DesktopIconBorder());
+ }
+
+ /**
+ * This method uninstalls the defaults for the JDesktopIcon.
+ */
+ protected void uninstallDefaults()
+ {
+ desktopIcon.setBorder(null);
+ }
+
+ /**
+ * This method creates a new MouseInputListener for the JDesktopIcon.
+ *
+ * @return A new MouseInputListener.
+ */
+ protected MouseInputListener createMouseInputListener()
+ {
+ return new MouseInputHandler();
+ }
+
+ /**
+ * This method returns the preferred size for the given JComponent.
+ *
+ * @param c The JComponent to find a preferred size for.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return new Dimension(iconWidth, iconHeight);
+ }
+
+ /**
+ * This method returns the minimum size for the given JComponent.
+ *
+ * @param c The JComponent to find a minimum size for.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the maximum size for the given JComponent.
+ *
+ * @param c The JComponent to find a maximum size for.
+ *
+ * @return The maximum size.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the insets of the given JComponent.
+ *
+ * @param c The JComponent to find insets for.
+ *
+ * @return The insets of the given JComponent.
+ */
+ public Insets getInsets(JComponent c)
+ {
+ return c.getInsets();
+ }
+
+ /**
+ * This method deiconizes the JInternalFrame associated with the JDesktopIcon.
+ */
+ public void deiconize()
+ {
+ try
+ {
+ frame.setIcon(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDesktopPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,470 @@
+/* BasicDesktopPaneUI.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyVetoException;
+
+import javax.swing.AbstractAction;
+import javax.swing.DefaultDesktopManager;
+import javax.swing.DesktopManager;
+import javax.swing.JComponent;
+import javax.swing.JDesktopPane;
+import javax.swing.JInternalFrame;
+import javax.swing.KeyStroke;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopPaneUI;
+import javax.swing.plaf.UIResource;
+
+/**
+ * This class is the UI delegate for JDesktopPane for the Basic look and feel.
+ */
+public class BasicDesktopPaneUI extends DesktopPaneUI
+{
+ /**
+ * This helper class is used to handle key events that cause JInternalFrames
+ * to be closed.
+ */
+ protected class CloseAction extends AbstractAction
+ {
+ /**
+ * This method is called when the action is performed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (desktop.getSelectedFrame() != null)
+ {
+ try
+ {
+ desktop.getSelectedFrame().setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempts has been vetoed.
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the action is enabled.
+ *
+ * @return Whether the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ if (desktop.getSelectedFrame() != null)
+ return desktop.getSelectedFrame().isClosable();
+ return false;
+ }
+ }
+
+ /**
+ * This helper class is used to handle key events that cause JInternalFrames
+ * to be maximized.
+ */
+ protected class MaximizeAction extends AbstractAction
+ {
+ /**
+ * This method is called when the action is performed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (desktop.getSelectedFrame() != null)
+ {
+ try
+ {
+ desktop.getSelectedFrame().setMaximum(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempts has been vetoed.
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the action is enabled.
+ *
+ * @return Whether the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ if (desktop.getSelectedFrame() != null)
+ return desktop.getSelectedFrame().isMaximizable();
+ return false;
+ }
+ }
+
+ /**
+ * This helper class is used to handle key events that cause JInternalFrames
+ * to be minimized.
+ */
+ protected class MinimizeAction extends AbstractAction
+ {
+ /**
+ * This method is called when the action is performed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (desktop.getSelectedFrame() != null)
+ {
+ try
+ {
+ desktop.getSelectedFrame().setIcon(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the action is enabled.
+ *
+ * @return Whether the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ if (desktop.getSelectedFrame() != null)
+ return desktop.getSelectedFrame().isIconifiable();
+ return false;
+ }
+ }
+
+ /**
+ * This helper class is used to handle key events that pass the SELECTED
+ * property to the next JInternalFrame in the JDesktopPane's list of
+ * children.
+ */
+ protected class NavigateAction extends AbstractAction
+ {
+ /**
+ * This method is called when the action is performed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ // This is supposed to set the next selected frame.
+ JInternalFrame[] frames = desktop.getAllFrames();
+ if (frames.length == 0)
+ return;
+
+ JInternalFrame sFrame = frames[0];
+ if (desktop.getSelectedFrame() != null)
+ sFrame = desktop.getSelectedFrame();
+
+ int i = 0;
+ for (; i < frames.length; i++)
+ if (frames[i] == sFrame)
+ break;
+
+ // FIXME: Navigate actions go reverse too.
+ if (i == frames.length)
+ i = 0;
+
+ desktop.setSelectedFrame(frames[i]);
+ }
+
+ /**
+ * This method returns whether the action is enabled.
+ *
+ * @return Whether this action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ // Always true.
+ return true;
+ }
+ }
+
+ /**
+ * This helper class is used to restore the JInternalFrame to its original
+ * size before maximizing or iconifying.
+ */
+ protected class OpenAction extends AbstractAction
+ {
+ /**
+ * This method is called when the action is performed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ JInternalFrame frame = desktop.getSelectedFrame();
+ if (frame != null)
+ {
+ try
+ {
+ if (frame.isIcon())
+ frame.setIcon(false);
+ else if (frame.isMaximum())
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the action is enabled.
+ *
+ * @return Whether this action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ // JInternalFrames are always restorable.
+ return true;
+ }
+ }
+
+ /**
+ * The KeyStroke associated with closing JInternalFrames.
+ * @deprecated
+ */
+ protected KeyStroke closeKey;
+
+ /**
+ * The KeyStroke associated with maximizing JInternalFrames.
+ * @deprecated
+ */
+ protected KeyStroke maximizeKey;
+
+ /**
+ * The KeyStroke associated with minimizing JInternalFrames.
+ * @deprecated
+ */
+ protected KeyStroke minimizeKey;
+
+ /**
+ * The KeyStroke associated with navigating (forward?) through
+ * JInternalFrames.
+ * @deprecated
+ */
+ protected KeyStroke navigateKey;
+
+ /**
+ * The KeyStroke associated with navigating (backward?) through
+ * JInternalFrames.
+ * @deprecated
+ */
+ protected KeyStroke navigateKey2;
+
+ /** The default desktop manager used with JDesktopPane. */
+ protected DesktopManager desktopManager;
+
+ /** The JDesktopPane this UI is used with. */
+ protected JDesktopPane desktop;
+
+ /**
+ * Creates a new BasicDesktopPaneUI object.
+ */
+ public BasicDesktopPaneUI()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method creates a BasicDesktopPaneUI for the given JComponent.
+ *
+ * @param c The JComponent to create a UI for.
+ *
+ * @return A new BasicDesktopPaneUI.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicDesktopPaneUI();
+ }
+
+ /**
+ * This method returns the maximum size for the given JComponent.
+ *
+ * @param c The JComponent to find a maximum size for.
+ *
+ * @return The maximum size for the given JComponent.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the minimum size for the given JComponent.
+ *
+ * @param c The JComponent to find a minimum size for.
+ *
+ * @return The minimum size for the given JComponent.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the preferred size for the given JComponent.
+ *
+ * @param c The JComponent to find a preferred size for.
+ *
+ * @return The preferred size for the given JComponent.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ // return null because JDesktopPanes don't have preferred sizes.
+ return null;
+ }
+
+ /**
+ * This method installs the defaults for the JDesktopPane provided by the
+ * current look and feel.
+ */
+ protected void installDefaults()
+ {
+ Color bg = desktop.getBackground();
+ if (bg == null || bg instanceof UIResource)
+ desktop.setBackground(UIManager.getColor("desktop"));
+ }
+
+ /**
+ * This method installs the desktop manager for the JDesktopPane.
+ */
+ protected void installDesktopManager()
+ {
+ desktopManager = new DefaultDesktopManager();
+ desktop.setDesktopManager(desktopManager);
+ }
+
+ /**
+ * This method installs the keyboard actions for the JDesktopPane.
+ */
+ protected void installKeyboardActions()
+ {
+ // FIXME: create actions and keystrokes.
+ registerKeyboardActions();
+ }
+
+ /**
+ * This method installs the UI for the given JComponent.
+ *
+ * @param c The JComponent to install this UI for.
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JDesktopPane)
+ {
+ desktop = (JDesktopPane) c;
+
+ installDefaults();
+ installDesktopManager();
+ installKeyboardActions();
+ }
+ }
+
+ /**
+ * This method registers the actions to the appropriate Action and Input
+ * maps.
+ */
+ protected void registerKeyboardActions()
+ {
+ // FIXME: Do the binding.
+ // XXX: the gtk windows tend to intercept a lot of the
+ // key events for themselves. must figure a way past that
+ // before binding
+ }
+
+ /**
+ * This method reverses the work done by the installDefaults method.
+ */
+ protected void uninstallDefaults()
+ {
+ desktop.setBackground(null);
+ }
+
+ /**
+ * This method reverses the work done by the installDesktopManager method.
+ */
+ protected void uninstallDesktopManager()
+ {
+ desktopManager = null;
+ desktop.setDesktopManager(null);
+ }
+
+ /**
+ * This method reverses the work done by the installKeyboardActions method.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ unregisterKeyboardActions();
+ // FIXME: null the actions and keystrokes.
+ }
+
+ /**
+ * This method reverses the work done by the registerKeyboardActions method.
+ */
+ protected void unregisterKeyboardActions()
+ {
+ // FIXME: unmap the keystrokes
+ }
+
+ /**
+ * This method uninstalls the UI for the given JComponent. It should reverse
+ * all the work done by the installUI method.
+ *
+ * @param c The JComponent to uninstall this UI for.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallKeyboardActions();
+ uninstallDesktopManager();
+ uninstallDefaults();
+
+ desktop = null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,589 @@
+/* BasicDirectoryModel.java --
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.AbstractListModel;
+import javax.swing.JFileChooser;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListDataEvent;
+import javax.swing.filechooser.FileSystemView;
+
+
+/**
+ * Implements an AbstractListModel for directories where the source
+ * of the files is a JFileChooser object.
+ *
+ * This class is used for sorting and ordering the file list in
+ * a JFileChooser L&F object.
+ */
+public class BasicDirectoryModel extends AbstractListModel
+ implements PropertyChangeListener
+{
+ /** The list of files itself */
+ private Vector contents;
+
+ /**
+ * The directories in the list.
+ */
+ private Vector directories;
+
+ /**
+ * The files in the list.
+ */
+ private Vector files;
+
+ /** The listing mode of the associated JFileChooser,
+ either FILES_ONLY, DIRECTORIES_ONLY or FILES_AND_DIRECTORIES */
+ private int listingMode;
+
+ /** The JFileCooser associated with this model */
+ private JFileChooser filechooser;
+
+ /**
+ * The thread that loads the file view.
+ */
+ private DirectoryLoadThread loadThread;
+
+ /**
+ * This thread is responsible for loading file lists from the
+ * current directory and updating the model.
+ */
+ private class DirectoryLoadThread extends Thread
+ {
+
+ /**
+ * Updates the Swing list model.
+ */
+ private class UpdateSwingRequest
+ implements Runnable
+ {
+
+ private List added;
+ private int addIndex;
+ private List removed;
+ private int removeIndex;
+ private boolean cancel;
+
+ UpdateSwingRequest(List add, int ai, List rem, int ri)
+ {
+ added = add;
+ addIndex = ai;
+ removed = rem;
+ removeIndex = ri;
+ cancel = false;
+ }
+
+ public void run()
+ {
+ if (! cancel)
+ {
+ int numRemoved = removed == null ? 0 : removed.size();
+ int numAdded = added == null ? 0 : added.size();
+ synchronized (contents)
+ {
+ if (numRemoved > 0)
+ contents.removeAll(removed);
+ if (numAdded > 0)
+ contents.addAll(added);
+
+ files = null;
+ directories = null;
+ }
+ if (numRemoved > 0 && numAdded == 0)
+ fireIntervalRemoved(BasicDirectoryModel.this, removeIndex,
+ removeIndex + numRemoved - 1);
+ else if (numRemoved == 0 && numAdded > 0)
+ fireIntervalAdded(BasicDirectoryModel.this, addIndex,
+ addIndex + numAdded - 1);
+ else
+ fireContentsChanged();
+ }
+ }
+
+ void cancel()
+ {
+ cancel = true;
+ }
+ }
+
+ /**
+ * The directory beeing loaded.
+ */
+ File directory;
+
+ /**
+ * Stores all UpdateSwingRequests that are sent to the event queue.
+ */
+ private UpdateSwingRequest pending;
+
+ /**
+ * Creates a new DirectoryLoadThread that loads the specified
+ * directory.
+ *
+ * @param dir the directory to load
+ */
+ DirectoryLoadThread(File dir)
+ {
+ super("Basic L&F directory loader");
+ directory = dir;
+ }
+
+ public void run()
+ {
+ FileSystemView fsv = filechooser.getFileSystemView();
+ File[] files = fsv.getFiles(directory,
+ filechooser.isFileHidingEnabled());
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ // Check list for accepted files.
+ Vector accepted = new Vector();
+ for (int i = 0; i < files.length; i++)
+ {
+ if (filechooser.accept(files[i]))
+ accepted.add(files[i]);
+ }
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ // Sort list.
+ sort(accepted);
+
+ // Now split up directories from files so that we get the directories
+ // listed before the files.
+ Vector newFiles = new Vector();
+ Vector newDirectories = new Vector();
+ for (Iterator i = accepted.iterator(); i.hasNext();)
+ {
+ File f = (File) i.next();
+ boolean traversable = filechooser.isTraversable(f);
+ if (traversable)
+ newDirectories.add(f);
+ else if (! traversable && filechooser.isFileSelectionEnabled())
+ newFiles.add(f);
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ }
+
+ // Build up new file cache. Try to update only the changed elements.
+ // This will be important for actions like adding new files or
+ // directories inside a large file list.
+ Vector newCache = new Vector(newDirectories);
+ newCache.addAll(newFiles);
+
+ int newSize = newCache.size();
+ int oldSize = contents.size();
+ if (newSize < oldSize)
+ {
+ // Check for removed interval.
+ int start = -1;
+ int end = -1;
+ boolean found = false;
+ for (int i = 0; i < newSize && !found; i++)
+ {
+ if (! newCache.get(i).equals(contents.get(i)))
+ {
+ start = i;
+ end = i + oldSize - newSize;
+ found = true;
+ }
+ }
+ if (start >= 0 && end > start
+ && contents.subList(end, oldSize)
+ .equals(newCache.subList(start, newSize)))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ Vector removed = new Vector(contents.subList(start, end));
+ UpdateSwingRequest r = new UpdateSwingRequest(null, 0,
+ removed, start);
+ invokeLater(r);
+ newCache = null;
+ }
+ }
+ else if (newSize > oldSize)
+ {
+ // Check for inserted interval.
+ int start = oldSize;
+ int end = newSize;
+ boolean found = false;
+ for (int i = 0; i < oldSize && ! found; i++)
+ {
+ if (! newCache.get(i).equals(contents.get(i)))
+ {
+ start = i;
+ boolean foundEnd = false;
+ for (int j = i; j < newSize && ! foundEnd; j++)
+ {
+ if (newCache.get(j).equals(contents.get(i)))
+ {
+ end = j;
+ foundEnd = true;
+ }
+ }
+ end = i + oldSize - newSize;
+ }
+ }
+ if (start >= 0 && end > start
+ && newCache.subList(end, newSize)
+ .equals(contents.subList(start, oldSize)))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ List added = newCache.subList(start, end);
+ UpdateSwingRequest r = new UpdateSwingRequest(added, start,
+ null, 0);
+ invokeLater(r);
+ newCache = null;
+ }
+ }
+
+ // Handle complete list changes (newCache != null).
+ if (newCache != null && ! contents.equals(newCache))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+ UpdateSwingRequest r = new UpdateSwingRequest(newCache, 0,
+ contents, 0);
+ invokeLater(r);
+ }
+ }
+
+ /**
+ * Wraps SwingUtilities.invokeLater() and stores the request in
+ * a Vector so that we can still cancel it later.
+ *
+ * @param update the request to invoke
+ */
+ private void invokeLater(UpdateSwingRequest update)
+ {
+ pending = update;
+ SwingUtilities.invokeLater(update);
+ }
+
+ /**
+ * Cancels all pending update requests that might be in the AWT
+ * event queue.
+ */
+ void cancelPending()
+ {
+ if (pending != null)
+ pending.cancel();
+ }
+ }
+
+ /** A Comparator class/object for sorting the file list. */
+ private Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ if (lt((File) o1, (File) o2))
+ return -1;
+ else
+ return 1;
+ }
+ };
+
+ /**
+ * Creates a new BasicDirectoryModel object.
+ *
+ * @param filechooser DOCUMENT ME!
+ */
+ public BasicDirectoryModel(JFileChooser filechooser)
+ {
+ this.filechooser = filechooser;
+ filechooser.addPropertyChangeListener(this);
+ listingMode = filechooser.getFileSelectionMode();
+ contents = new Vector();
+ validateFileCache();
+ }
+
+ /**
+ * Returns whether a given (File) object is included in the list.
+ *
+ * @param o - The file object to test.
+ *
+ * @return <code>true</code> if the list contains the given object.
+ */
+ public boolean contains(Object o)
+ {
+ return contents.contains(o);
+ }
+
+ /**
+ * Fires a content change event.
+ */
+ public void fireContentsChanged()
+ {
+ fireContentsChanged(this, 0, getSize() - 1);
+ }
+
+ /**
+ * Returns a Vector of (java.io.File) objects containing
+ * the directories in this list.
+ *
+ * @return a Vector
+ */
+ public Vector getDirectories()
+ {
+ // Synchronize this with the UpdateSwingRequest for the case when
+ // contents is modified.
+ synchronized (contents)
+ {
+ Vector dirs = directories;
+ if (dirs == null)
+ {
+ // Initializes this in getFiles().
+ getFiles();
+ dirs = directories;
+ }
+ return dirs;
+ }
+ }
+
+ /**
+ * Returns the (java.io.File) object at
+ * an index in the list.
+ *
+ * @param index The list index
+ * @return a File object
+ */
+ public Object getElementAt(int index)
+ {
+ if (index > getSize() - 1)
+ return null;
+ return contents.elementAt(index);
+ }
+
+ /**
+ * Returns a Vector of (java.io.File) objects containing
+ * the files in this list.
+ *
+ * @return a Vector
+ */
+ public Vector getFiles()
+ {
+ synchronized (contents)
+ {
+ Vector f = files;
+ if (f == null)
+ {
+ f = new Vector();
+ Vector d = new Vector(); // Directories;
+ for (Iterator i = contents.iterator(); i.hasNext();)
+ {
+ File file = (File) i.next();
+ if (filechooser.isTraversable(file))
+ d.add(file);
+ else
+ f.add(file);
+ }
+ files = f;
+ directories = d;
+ }
+ return f;
+ }
+ }
+
+ /**
+ * Returns the size of the list, which only includes directories
+ * if the JFileChooser is set to DIRECTORIES_ONLY.
+ *
+ * Otherwise, both directories and files are included in the count.
+ *
+ * @return The size of the list.
+ */
+ public int getSize()
+ {
+ return contents.size();
+ }
+
+ /**
+ * Returns the index of an (java.io.File) object in the list.
+ *
+ * @param o The object - normally a File.
+ *
+ * @return the index of that object, or -1 if it is not in the list.
+ */
+ public int indexOf(Object o)
+ {
+ return contents.indexOf(o);
+ }
+
+ /**
+ * Obsoleted method which does nothing.
+ */
+ public void intervalAdded(ListDataEvent e)
+ {
+ // obsoleted
+ }
+
+ /**
+ * Obsoleted method which does nothing.
+ */
+ public void intervalRemoved(ListDataEvent e)
+ {
+ // obsoleted
+ }
+
+ /**
+ * Obsoleted method which does nothing.
+ */
+ public void invalidateFileCache()
+ {
+ // obsoleted
+ }
+
+ /**
+ * Less than, determine the relative order in the list of two files
+ * for sorting purposes.
+ *
+ * The order is: directories < files, and thereafter alphabetically,
+ * using the default locale collation.
+ *
+ * @param a the first file
+ * @param b the second file
+ *
+ * @return <code>true</code> if a > b, <code>false</code> if a < b.
+ */
+ protected boolean lt(File a, File b)
+ {
+ boolean aTrav = filechooser.isTraversable(a);
+ boolean bTrav = filechooser.isTraversable(b);
+
+ if (aTrav == bTrav)
+ {
+ String aname = a.getName().toLowerCase();
+ String bname = b.getName().toLowerCase();
+ return (aname.compareTo(bname) < 0) ? true : false;
+ }
+ else
+ {
+ if (aTrav)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ /**
+ * Listens for a property change; the change in file selection mode of the
+ * associated JFileChooser. Reloads the file cache on that event.
+ *
+ * @param e - A PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ String property = e.getPropertyName();
+ if (property.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_HIDING_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_VIEW_CHANGED_PROPERTY)
+ )
+ {
+ validateFileCache();
+ }
+ }
+
+ /**
+ * Renames a file - However, does <I>not</I> re-sort the list
+ * or replace the old file with the new one in the list.
+ *
+ * @param oldFile The old file
+ * @param newFile The new file name
+ *
+ * @return <code>true</code> if the rename succeeded
+ */
+ public boolean renameFile(File oldFile, File newFile)
+ {
+ return oldFile.renameTo( newFile );
+ }
+
+ /**
+ * Sorts a Vector of File objects.
+ *
+ * @param v The Vector to sort.
+ */
+ protected void sort(Vector v)
+ {
+ Collections.sort(v, comparator);
+ }
+
+ /**
+ * Re-loads the list of files
+ */
+ public void validateFileCache()
+ {
+ File dir = filechooser.getCurrentDirectory();
+ if (dir != null)
+ {
+ // Cancel all pending requests.
+ if (loadThread != null)
+ {
+ loadThread.interrupt();
+ loadThread.cancelPending();
+ }
+ loadThread = new DirectoryLoadThread(dir);
+ loadThread.start();
+ }
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,96 @@
+/* BasicEditorPaneUI.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+
+/**
+ * The UI class for {@link JEditorPane}s.
+ *
+ * @author original author unknown
+ * @author Roman Kennke (roman at kennke.org)
+ */
+public class BasicEditorPaneUI extends BasicTextUI
+{
+ /**
+ * Creates an instance of <code>BasicEditorPaneUI</code> for the text
+ * component <code>comp</code>.
+ *
+ * @param comp the component for which to create an UI
+ *
+ * @return the UI for <code>comp</code>
+ */
+ public static ComponentUI createUI(JComponent comp)
+ {
+ return new BasicEditorPaneUI();
+ }
+
+ /**
+ * Creates a new <code>BasicEditorPaneUI</code>
+ */
+ public BasicEditorPaneUI()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * Returns the property prefix to be used by this UI class. This is
+ * <code>EditorPane</code> in this case.
+ *
+ * @return <code>EditorPane</code>
+ */
+ protected String getPropertyPrefix()
+ {
+ return "EditorPane";
+ }
+
+ /**
+ * Gets the EditorKit for the text component.
+ *
+ * @param textComponent the text component for which to fetch the editor kit
+ */
+ public EditorKit getEditorKit(JTextComponent textComponent)
+ {
+ return ((JEditorPane) textComponent).getEditorKit();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1438 @@
+/* BasicFileChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileSystemView;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.FileChooserUI;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+
+/**
+ * A UI delegate for the {@link JFileChooser} component under the
+ * {@link BasicLookAndFeel}.
+ */
+public class BasicFileChooserUI extends FileChooserUI
+{
+ /**
+ * A file filter that accepts all files.
+ */
+ protected class AcceptAllFileFilter extends FileFilter
+ {
+ /**
+ * Creates a new instance.
+ */
+ public AcceptAllFileFilter()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns <code>true</code> always, as all files are accepted by this
+ * filter.
+ *
+ * @param f the file.
+ *
+ * @return Always <code>true</code>.
+ */
+ public boolean accept(File f)
+ {
+ return true;
+ }
+
+ /**
+ * Returns a description for this filter.
+ *
+ * @return A description for the file filter.
+ */
+ public String getDescription()
+ {
+ return acceptAllFileFilterText;
+ }
+ }
+
+ /**
+ * Handles a user action to approve the dialog selection.
+ *
+ * @see BasicFileChooserUI#getApproveSelectionAction()
+ */
+ protected class ApproveSelectionAction extends AbstractAction
+ {
+ /**
+ * Creates a new ApproveSelectionAction object.
+ */
+ protected ApproveSelectionAction()
+ {
+ super("approveSelection");
+ }
+
+ /**
+ * Sets the current selection and closes the dialog.
+ *
+ * @param e the action event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Object obj = null;
+ if (parentPath != null)
+ obj = new String(parentPath + getFileName());
+ else
+ obj = filechooser.getSelectedFile();
+ if (obj != null)
+ {
+ File f = filechooser.getFileSystemView().createFileObject(obj.toString());
+ File currSelected = filechooser.getSelectedFile();
+ if (filechooser.isTraversable(f))
+ {
+ filechooser.setCurrentDirectory(currSelected);
+ filechooser.rescanCurrentDirectory();
+ }
+ else
+ {
+ filechooser.approveSelection();
+ closeDialog();
+ }
+ }
+ else
+ {
+ File f = new File(filechooser.getCurrentDirectory(), getFileName());
+ if ( selectedDir != null )
+ f = selectedDir;
+ if (filechooser.isTraversable(f))
+ {
+ filechooser.setCurrentDirectory(f);
+ filechooser.rescanCurrentDirectory();
+ }
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
+ }
+ }
+ }
+
+ /**
+ * Provides presentation information about files and directories.
+ */
+ protected class BasicFileView extends FileView
+ {
+ /** Storage for cached icons. */
+ protected Hashtable iconCache = new Hashtable();
+
+ /**
+ * Creates a new instance.
+ */
+ public BasicFileView()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Adds an icon to the cache, associating it with the given file/directory.
+ *
+ * @param f the file/directory.
+ * @param i the icon.
+ */
+ public void cacheIcon(File f, Icon i)
+ {
+ iconCache.put(f, i);
+ }
+
+ /**
+ * Clears the icon cache.
+ */
+ public void clearIconCache()
+ {
+ iconCache.clear();
+ }
+
+ /**
+ * Retrieves the icon associated with the specified file/directory, if
+ * there is one.
+ *
+ * @param f the file/directory.
+ *
+ * @return The cached icon (or <code>null</code>).
+ */
+ public Icon getCachedIcon(File f)
+ {
+ return (Icon) iconCache.get(f);
+ }
+
+ /**
+ * Returns a description of the given file/directory. In this
+ * implementation, the description is the same as the name returned by
+ * {@link #getName(File)}.
+ *
+ * @param f the file/directory.
+ *
+ * @return A description of the given file/directory.
+ */
+ public String getDescription(File f)
+ {
+ return getName(f);
+ }
+
+ /**
+ * Returns an icon appropriate for the given file or directory.
+ *
+ * @param f the file/directory.
+ *
+ * @return An icon.
+ */
+ public Icon getIcon(File f)
+ {
+ Icon val = getCachedIcon(f);
+ if (val != null)
+ return val;
+ if (filechooser.isTraversable(f))
+ val = directoryIcon;
+ else
+ val = fileIcon;
+ cacheIcon(f, val);
+ return val;
+ }
+
+ /**
+ * Returns the name for the given file/directory.
+ *
+ * @param f the file/directory.
+ *
+ * @return The name of the file/directory.
+ */
+ public String getName(File f)
+ {
+ String name = null;
+ if (f != null)
+ {
+ JFileChooser c = getFileChooser();
+ FileSystemView v = c.getFileSystemView();
+ name = v.getSystemDisplayName(f);
+ }
+ return name;
+ }
+
+ /**
+ * Returns a localised description for the type of file/directory.
+ *
+ * @param f the file/directory.
+ *
+ * @return A type description for the given file/directory.
+ */
+ public String getTypeDescription(File f)
+ {
+ if (filechooser.isTraversable(f))
+ return dirDescText;
+ else
+ return fileDescText;
+ }
+
+ /**
+ * Returns {@link Boolean#TRUE} if the given file/directory is hidden,
+ * and {@link Boolean#FALSE} otherwise.
+ *
+ * @param f the file/directory.
+ *
+ * @return {@link Boolean#TRUE} or {@link Boolean#FALSE}.
+ */
+ public Boolean isHidden(File f)
+ {
+ return Boolean.valueOf(filechooser.getFileSystemView().isHiddenFile(f));
+ }
+ }
+
+ /**
+ * Handles an action to cancel the file chooser.
+ *
+ * @see BasicFileChooserUI#getCancelSelectionAction()
+ */
+ protected class CancelSelectionAction extends AbstractAction
+ {
+ /**
+ * Creates a new <code>CancelSelectionAction</code> object.
+ */
+ protected CancelSelectionAction()
+ {
+ super(null);
+ }
+
+ /**
+ * Cancels the selection and closes the dialog.
+ *
+ * @param e the action event (ignored).
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.setSelectedFile(null);
+ filechooser.setSelectedFiles(null);
+ filechooser.cancelSelection();
+ closeDialog();
+ }
+ }
+
+ /**
+ * An action to handle changes to the parent directory (for example, via
+ * a click on the "up folder" button).
+ *
+ * @see BasicFileChooserUI#getChangeToParentDirectoryAction()
+ */
+ protected class ChangeToParentDirectoryAction extends AbstractAction
+ {
+ /**
+ * Creates a new <code>ChangeToParentDirectoryAction</code> object.
+ */
+ protected ChangeToParentDirectoryAction()
+ {
+ super("Go Up");
+ }
+
+ /**
+ * Handles the action event.
+ *
+ * @param e the action event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.changeToParentDirectory();
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * A mouse listener that handles double-click events.
+ *
+ * @see BasicFileChooserUI#createDoubleClickListener(JFileChooser, JList)
+ */
+ protected class DoubleClickListener extends MouseAdapter
+ {
+
+ /** DOCUMENT ME! */
+ private Object lastSelected;
+
+ /** DOCUMENT ME! */
+ private JList list;
+
+ /**
+ * Creates a new DoubleClickListener object.
+ *
+ * @param list DOCUMENT ME!
+ */
+ public DoubleClickListener(JList list)
+ {
+ this.list = list;
+ lastSelected = list.getSelectedValue();
+ setDirectorySelected(false);
+ }
+
+ /**
+ * Handles a mouse click event.
+ *
+ * @param e the event.
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ Object p = list.getSelectedValue();
+ if (p == null)
+ return;
+ FileSystemView fsv = filechooser.getFileSystemView();
+ if (e.getClickCount() >= 2 && lastSelected != null &&
+ p.toString().equals(lastSelected.toString()))
+ {
+ File f = fsv.createFileObject(lastSelected.toString());
+ if (filechooser.isTraversable(f))
+ {
+ filechooser.setCurrentDirectory(f);
+ filechooser.rescanCurrentDirectory();
+ }
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
+ }
+ else // single click
+ {
+ String path = p.toString();
+ File f = fsv.createFileObject(path);
+ filechooser.setSelectedFile(f);
+
+ if (filechooser.isMultiSelectionEnabled())
+ {
+ int[] inds = list.getSelectedIndices();
+ File[] allFiles = new File[inds.length];
+ for (int i = 0; i < inds.length; i++)
+ allFiles[i] = (File) list.getModel().getElementAt(inds[i]);
+ filechooser.setSelectedFiles(allFiles);
+ }
+
+ if (filechooser.isTraversable(f))
+ {
+ setDirectorySelected(true);
+ setDirectory(f);
+ }
+ else
+ {
+ setDirectorySelected(false);
+ setDirectory(null);
+ }
+ lastSelected = path;
+ parentPath = path.substring(0, path.lastIndexOf("/") + 1);
+
+ if (f.isFile())
+ setFileName(path.substring(path.lastIndexOf("/") + 1));
+ else if (filechooser.getFileSelectionMode() !=
+ JFileChooser.FILES_ONLY)
+ setFileName(path);
+ }
+ }
+
+ /**
+ * Handles a mouse entered event (NOT IMPLEMENTED).
+ *
+ * @param e the mouse event.
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ // FIXME: Implement
+ }
+ }
+
+ /**
+ * An action that changes the file chooser to display the user's home
+ * directory.
+ *
+ * @see BasicFileChooserUI#getGoHomeAction()
+ */
+ protected class GoHomeAction extends AbstractAction
+ {
+ /**
+ * Creates a new <code>GoHomeAction</code> object.
+ */
+ protected GoHomeAction()
+ {
+ super("Go Home");
+ }
+
+ /**
+ * Sets the directory to the user's home directory, and repaints the
+ * file chooser component.
+ *
+ * @param e the action event (ignored).
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.setCurrentDirectory(filechooser.getFileSystemView()
+ .getHomeDirectory());
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * An action that handles the creation of a new folder/directory.
+ *
+ * @see BasicFileChooserUI#getNewFolderAction()
+ */
+ protected class NewFolderAction extends AbstractAction
+ {
+ /**
+ * Creates a new <code>NewFolderAction</code> object.
+ */
+ protected NewFolderAction()
+ {
+ super("New Folder");
+ }
+
+ /**
+ * Handles the event by creating a new folder.
+ *
+ * @param e the action event (ignored).
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ filechooser.getFileSystemView().createNewFolder(filechooser
+ .getCurrentDirectory());
+ }
+ catch (IOException ioe)
+ {
+ return;
+ }
+ filechooser.rescanCurrentDirectory();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * A listener for selection events in the file list.
+ *
+ * @see BasicFileChooserUI#createListSelectionListener(JFileChooser)
+ */
+ protected class SelectionListener implements ListSelectionListener
+ {
+ /**
+ * Creates a new <code>SelectionListener</code> object.
+ */
+ protected SelectionListener()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Sets the JFileChooser to the selected file on an update
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void valueChanged(ListSelectionEvent e)
+ {
+ JList list = (JList) e.getSource();
+ Object f = list.getSelectedValue();
+ if (f == null)
+ return;
+ File file = filechooser.getFileSystemView().createFileObject(f.toString());
+ if (! filechooser.isTraversable(file))
+ {
+ selectedDir = null;
+ filechooser.setSelectedFile(file);
+ }
+ else
+ {
+ selectedDir = file;
+ filechooser.setSelectedFile(null);
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @see BasicFileChooserUI#getUpdateAction()
+ */
+ protected class UpdateAction extends AbstractAction
+ {
+ /**
+ * Creates a new UpdateAction object.
+ */
+ protected UpdateAction()
+ {
+ super(null);
+ }
+
+ /**
+ * NOT YET IMPLEMENTED.
+ *
+ * @param e the action event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ // FIXME: implement this
+ }
+ }
+
+ /** The localised mnemonic for the cancel button. */
+ protected int cancelButtonMnemonic;
+
+ /** The localised text for the cancel button. */
+ protected String cancelButtonText;
+
+ /** The localised tool tip text for the cancel button. */
+ protected String cancelButtonToolTipText;
+
+ /** An icon representing a computer. */
+ protected Icon computerIcon;
+
+ /** An icon for the "details view" button. */
+ protected Icon detailsViewIcon;
+
+ /** An icon representing a directory. */
+ protected Icon directoryIcon;
+
+ /** The localised Mnemonic for the open button. */
+ protected int directoryOpenButtonMnemonic;
+
+ /** The localised text for the open button. */
+ protected String directoryOpenButtonText;
+
+ /** The localised tool tip text for the open button. */
+ protected String directoryOpenButtonToolTipText;
+
+ /** An icon representing a file. */
+ protected Icon fileIcon;
+
+ /** An icon representing a floppy drive. */
+ protected Icon floppyDriveIcon;
+
+ /** An icon representing a hard drive. */
+ protected Icon hardDriveIcon;
+
+ /** The localised mnemonic for the "help" button. */
+ protected int helpButtonMnemonic;
+
+ /** The localised text for the "help" button. */
+ protected String helpButtonText;
+
+ /** The localised tool tip text for the help button. */
+ protected String helpButtonToolTipText;
+
+ /** An icon representing the user's home folder. */
+ protected Icon homeFolderIcon;
+
+ /** An icon for the "list view" button. */
+ protected Icon listViewIcon;
+
+ /** An icon for the "new folder" button. */
+ protected Icon newFolderIcon = directoryIcon;
+
+ /** The localised mnemonic for the "open" button. */
+ protected int openButtonMnemonic;
+
+ /** The localised text for the "open" button. */
+ protected String openButtonText;
+
+ /** The localised tool tip text for the "open" button. */
+ protected String openButtonToolTipText;
+
+ /** The localised mnemonic for the "save" button. */
+ protected int saveButtonMnemonic;
+
+ /** The localised text for the "save" button. */
+ protected String saveButtonText;
+
+ /** The localised tool tip text for the save button. */
+ protected String saveButtonToolTipText;
+
+ /** The localised mnemonic for the "update" button. */
+ protected int updateButtonMnemonic;
+
+ /** The localised text for the "update" button. */
+ protected String updateButtonText;
+
+ /** The localised tool tip text for the "update" button. */
+ protected String updateButtonToolTipText;
+
+ /** An icon for the "up folder" button. */
+ protected Icon upFolderIcon;
+
+ // -- begin private, but package local since used in inner classes --
+
+ /** The file chooser component represented by this UI delegate. */
+ JFileChooser filechooser;
+
+ /** The model for the directory list. */
+ BasicDirectoryModel model;
+
+ /** The file filter for all files. */
+ FileFilter acceptAll = new AcceptAllFileFilter();
+
+ /** The default file view. */
+ FileView fv = new BasicFileView();
+
+ /** The accept (open/save) button. */
+ JButton accept;
+
+ /** An optional accessory panel. */
+ JPanel accessoryPanel = new JPanel();
+
+ /** A property change listener. */
+ PropertyChangeListener propertyChangeListener;
+
+ /** The text describing the filter for "all files". */
+ String acceptAllFileFilterText;
+
+ /** The text describing a directory type. */
+ String dirDescText;
+
+ /** The text describing a file type. */
+ String fileDescText;
+
+ /** Is a directory selected? */
+ boolean dirSelected;
+
+ /** The current directory. */
+ File currDir;
+
+ // FIXME: describe what is contained in the bottom panel
+ /** The bottom panel. */
+ JPanel bottomPanel;
+
+ /** The close panel. */
+ JPanel closePanel;
+
+ /** Text box that displays file name */
+ JTextField entry;
+
+ /** Current parent path */
+ String parentPath;
+
+ /**
+ * The action for the 'approve' button.
+ * @see #getApproveSelectionAction()
+ */
+ private ApproveSelectionAction approveSelectionAction;
+
+ /**
+ * The action for the 'cancel' button.
+ * @see #getCancelSelectionAction()
+ */
+ private CancelSelectionAction cancelSelectionAction;
+
+ /**
+ * The action for the 'go home' control button.
+ * @see #getGoHomeAction()
+ */
+ private GoHomeAction goHomeAction;
+
+ /**
+ * The action for the 'up folder' control button.
+ * @see #getChangeToParentDirectoryAction()
+ */
+ private ChangeToParentDirectoryAction changeToParentDirectoryAction;
+
+ /**
+ * The action for the 'new folder' control button.
+ * @see #getNewFolderAction()
+ */
+ private NewFolderAction newFolderAction;
+
+ /**
+ * The action for ???. // FIXME: what is this?
+ * @see #getUpdateAction()
+ */
+ private UpdateAction updateAction;
+
+ /**
+ * When in FILES_ONLY, mode a directory cannot be selected, so
+ * we save a reference to any it here. This is used to enter
+ * the directory on "Open" when in that mode.
+ */
+ private File selectedDir;
+
+ // -- end private --
+
+ /**
+ * Closes the dialog.
+ */
+ void closeDialog()
+ {
+ Window owner = SwingUtilities.windowForComponent(filechooser);
+ if (owner instanceof JDialog)
+ ((JDialog) owner).dispose();
+ }
+
+ /**
+ * Creates a new <code>BasicFileChooserUI</code> object.
+ *
+ * @param b the file chooser component.
+ */
+ public BasicFileChooserUI(JFileChooser b)
+ {
+ }
+
+ /**
+ * Returns a UI delegate for the given component.
+ *
+ * @param c the component (should be a {@link JFileChooser}).
+ *
+ * @return A new UI delegate.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicFileChooserUI((JFileChooser) c);
+ }
+
+ /**
+ * Installs the UI for the specified component.
+ *
+ * @param c the component (should be a {@link JFileChooser}).
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JFileChooser)
+ {
+ JFileChooser fc = (JFileChooser) c;
+ this.filechooser = fc;
+ fc.resetChoosableFileFilters();
+ createModel();
+ clearIconCache();
+ installDefaults(fc);
+ installComponents(fc);
+ installListeners(fc);
+
+ Object path = filechooser.getCurrentDirectory();
+ if (path != null)
+ parentPath = path.toString().substring(path.toString().lastIndexOf("/"));
+ }
+ }
+
+ /**
+ * Uninstalls this UI from the given component.
+ *
+ * @param c the component (should be a {@link JFileChooser}).
+ */
+ public void uninstallUI(JComponent c)
+ {
+ model = null;
+ uninstallListeners(filechooser);
+ uninstallComponents(filechooser);
+ uninstallDefaults(filechooser);
+ filechooser = null;
+ }
+
+ // FIXME: Indent the entries in the combobox
+ // Made this method package private to access it from within inner classes
+ // with better performance
+ void boxEntries()
+ {
+ ArrayList parentFiles = new ArrayList();
+ File parent = filechooser.getCurrentDirectory();
+ if (parent == null)
+ parent = filechooser.getFileSystemView().getDefaultDirectory();
+ while (parent != null)
+ {
+ String name = parent.getName();
+ if (name.equals(""))
+ name = parent.getAbsolutePath();
+
+ parentFiles.add(parentFiles.size(), name);
+ parent = parent.getParentFile();
+ }
+
+ if (parentFiles.size() == 0)
+ return;
+
+ }
+
+ /**
+ * Creates and install the subcomponents for the file chooser.
+ *
+ * @param fc the file chooser.
+ */
+ public void installComponents(JFileChooser fc)
+ {
+ }
+
+ /**
+ * Uninstalls the components from the file chooser.
+ *
+ * @param fc the file chooser.
+ */
+ public void uninstallComponents(JFileChooser fc)
+ {
+ }
+
+ /**
+ * Installs the listeners required by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void installListeners(JFileChooser fc)
+ {
+ propertyChangeListener = createPropertyChangeListener(filechooser);
+ if (propertyChangeListener != null)
+ filechooser.addPropertyChangeListener(propertyChangeListener);
+ fc.addPropertyChangeListener(getModel());
+ }
+
+ /**
+ * Uninstalls the listeners previously installed by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void uninstallListeners(JFileChooser fc)
+ {
+ if (propertyChangeListener != null)
+ {
+ filechooser.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+ fc.removePropertyChangeListener(getModel());
+ }
+
+ /**
+ * Installs the defaults for this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void installDefaults(JFileChooser fc)
+ {
+ installIcons(fc);
+ installStrings(fc);
+ }
+
+ /**
+ * Uninstalls the defaults previously added by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void uninstallDefaults(JFileChooser fc)
+ {
+ uninstallStrings(fc);
+ uninstallIcons(fc);
+ }
+
+ /**
+ * Installs the icons for this UI delegate.
+ *
+ * @param fc the file chooser (ignored).
+ */
+ protected void installIcons(JFileChooser fc)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ computerIcon = MetalIconFactory.getTreeComputerIcon();
+ detailsViewIcon = defaults.getIcon("FileChooser.detailsViewIcon");
+ directoryIcon = new MetalIconFactory.TreeFolderIcon();
+ fileIcon = new MetalIconFactory.TreeLeafIcon();
+ floppyDriveIcon = MetalIconFactory.getTreeFloppyDriveIcon();
+ hardDriveIcon = MetalIconFactory.getTreeHardDriveIcon();
+ homeFolderIcon = defaults.getIcon("FileChooser.homeFolderIcon");
+ listViewIcon = defaults.getIcon("FileChooser.listViewIcon");
+ newFolderIcon = defaults.getIcon("FileChooser.newFolderIcon");
+ upFolderIcon = defaults.getIcon("FileChooser.upFolderIcon");
+ }
+
+ /**
+ * Uninstalls the icons previously added by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void uninstallIcons(JFileChooser fc)
+ {
+ computerIcon = null;
+ detailsViewIcon = null;
+ directoryIcon = null;
+ fileIcon = null;
+ floppyDriveIcon = null;
+ hardDriveIcon = null;
+ homeFolderIcon = null;
+ listViewIcon = null;
+ newFolderIcon = null;
+ upFolderIcon = null;
+ }
+
+ /**
+ * Installs the strings used by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void installStrings(JFileChooser fc)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ dirDescText = defaults.getString("FileChooser.directoryDescriptionText");
+ fileDescText = defaults.getString("FileChooser.fileDescriptionText");
+
+ acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText");
+ cancelButtonText = "Cancel";
+ cancelButtonToolTipText = "Abort file chooser dialog";
+ cancelButtonMnemonic = new Integer((String) UIManager.get("FileChooser.cancelButtonMnemonic")).intValue();
+
+ directoryOpenButtonText = "Open";
+ directoryOpenButtonToolTipText = "Open selected directory";
+ directoryOpenButtonMnemonic
+ = new Integer((String) UIManager.get("FileChooser.directoryOpenButtonMnemonic")).intValue();
+
+ helpButtonText = "Help";
+ helpButtonToolTipText = "FileChooser help";
+ helpButtonMnemonic = new Integer((String) UIManager.get("FileChooser.helpButtonMnemonic")).intValue();
+
+ openButtonText = "Open";
+ openButtonToolTipText = "Open selected file";
+ openButtonMnemonic = new Integer((String) UIManager.get("FileChooser.openButtonMnemonic")).intValue();
+
+ saveButtonText = "Save";
+ saveButtonToolTipText = "Save selected file";
+ saveButtonMnemonic = new Integer((String) UIManager.get("FileChooser.saveButtonMnemonic")).intValue();
+
+ updateButtonText = "Update";
+ updateButtonToolTipText = "Update directory listing";
+ updateButtonMnemonic = new Integer((String) UIManager.get("FileChooser.updateButtonMnemonic")).intValue();
+ }
+
+ /**
+ * Uninstalls the strings previously added by this UI delegate.
+ *
+ * @param fc the file chooser.
+ */
+ protected void uninstallStrings(JFileChooser fc)
+ {
+ acceptAllFileFilterText = null;
+ dirDescText = null;
+ fileDescText = null;
+
+ cancelButtonText = null;
+ cancelButtonToolTipText = null;
+
+ directoryOpenButtonText = null;
+ directoryOpenButtonToolTipText = null;
+
+ helpButtonText = null;
+ helpButtonToolTipText = null;
+
+ openButtonText = null;
+ openButtonToolTipText = null;
+
+ saveButtonText = null;
+ saveButtonToolTipText = null;
+
+ updateButtonText = null;
+ updateButtonToolTipText = null;
+ }
+
+ /**
+ * Creates a new directory model.
+ */
+ protected void createModel()
+ {
+ model = new BasicDirectoryModel(filechooser);
+ }
+
+ /**
+ * Returns the directory model.
+ *
+ * @return The directory model.
+ */
+ public BasicDirectoryModel getModel()
+ {
+ return model;
+ }
+
+ /**
+ * Creates a listener to handle changes to the properties of the given
+ * file chooser component.
+ *
+ * @param fc the file chooser component.
+ *
+ * @return A new listener.
+ */
+ public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
+ {
+ // The RI returns null here, so do we.
+ return null;
+ }
+
+ /**
+ * Returns the current file name.
+ *
+ * @return The current file name.
+ */
+ public String getFileName()
+ {
+ return entry.getText();
+ }
+
+ /**
+ * Returns the current directory name.
+ *
+ * @return The directory name.
+ *
+ * @see #setDirectoryName(String)
+ */
+ public String getDirectoryName()
+ {
+ // XXX: I don't see a case where the thing returns something non-null..
+ return null;
+ }
+
+ /**
+ * Sets the file name.
+ *
+ * @param filename the file name.
+ *
+ * @see #getFileName()
+ */
+ public void setFileName(String filename)
+ {
+ // FIXME: it might be the case that this method provides an access
+ // point for the JTextField (or whatever) a subclass is using...
+ //this.filename = filename;
+ }
+
+ /**
+ * Sets the directory name (NOT IMPLEMENTED).
+ *
+ * @param dirname the directory name.
+ *
+ * @see #getDirectoryName()
+ */
+ public void setDirectoryName(String dirname)
+ {
+ // FIXME: Implement
+ }
+
+ /**
+ * Rescans the current directory.
+ *
+ * @param fc the file chooser.
+ */
+ public void rescanCurrentDirectory(JFileChooser fc)
+ {
+ getModel().validateFileCache();
+ }
+
+ /**
+ * NOT YET IMPLEMENTED.
+ *
+ * @param fc the file chooser.
+ * @param f the file.
+ */
+ public void ensureFileIsVisible(JFileChooser fc, File f)
+ {
+ // XXX: Not sure what this does.
+ }
+
+ /**
+ * Returns the {@link JFileChooser} component that this UI delegate
+ * represents.
+ *
+ * @return The component represented by this UI delegate.
+ */
+ public JFileChooser getFileChooser()
+ {
+ return filechooser;
+ }
+
+ /**
+ * Returns the optional accessory panel.
+ *
+ * @return The optional accessory panel.
+ */
+ public JPanel getAccessoryPanel()
+ {
+ return accessoryPanel;
+ }
+
+ /**
+ * Returns the approve (open or save) button for the dialog.
+ *
+ * @param fc the file chooser.
+ *
+ * @return The button.
+ */
+ protected JButton getApproveButton(JFileChooser fc)
+ {
+ return accept;
+ }
+
+ /**
+ * Returns the tool tip text for the approve (open/save) button. This first
+ * checks the file chooser to see if a value has been explicitly set - if
+ * not, a default value appropriate for the type of file chooser is
+ * returned.
+ *
+ * @param fc the file chooser.
+ *
+ * @return The tool tip text.
+ */
+ public String getApproveButtonToolTipText(JFileChooser fc)
+ {
+ if (fc.getApproveButtonToolTipText() != null)
+ return fc.getApproveButtonToolTipText();
+ else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ return saveButtonToolTipText;
+ else
+ return openButtonToolTipText;
+ }
+
+ /**
+ * Clears the icon cache.
+ */
+ public void clearIconCache()
+ {
+ if (fv instanceof BasicFileView)
+ ((BasicFileView) fv).clearIconCache();
+ }
+
+ /**
+ * Creates a new listener to handle selections in the file list.
+ *
+ * @param fc the file chooser component.
+ *
+ * @return A new instance of {@link SelectionListener}.
+ */
+ public ListSelectionListener createListSelectionListener(JFileChooser fc)
+ {
+ return new SelectionListener();
+ }
+
+ /**
+ * Creates a new listener to handle double-click events.
+ *
+ * @param fc the file chooser component.
+ * @param list the list.
+ *
+ * @return A new instance of {@link DoubleClickListener}.
+ */
+ protected MouseListener createDoubleClickListener(JFileChooser fc, JList list)
+ {
+ return new DoubleClickListener(list);
+ }
+
+ /**
+ * Returns <code>true</code> if a directory is selected, and
+ * <code>false</code> otherwise.
+ *
+ * @return A boolean.
+ */
+ protected boolean isDirectorySelected()
+ {
+ return dirSelected;
+ }
+
+ /**
+ * Sets the flag that indicates whether the current directory is selected.
+ *
+ * @param selected the new flag value.
+ */
+ protected void setDirectorySelected(boolean selected)
+ {
+ dirSelected = selected;
+ }
+
+ /**
+ * Returns the current directory.
+ *
+ * @return The current directory.
+ */
+ protected File getDirectory()
+ {
+ return currDir;
+ }
+
+ /**
+ * Sets the current directory.
+ *
+ * @param f the directory.
+ */
+ protected void setDirectory(File f)
+ {
+ currDir = f;
+ }
+
+ /**
+ * Returns the "accept all" file filter.
+ *
+ * @param fc the file chooser component.
+ *
+ * @return The "accept all" file filter.
+ */
+ public FileFilter getAcceptAllFileFilter(JFileChooser fc)
+ {
+ return acceptAll;
+ }
+
+ /**
+ * Returns the default file view (NOT the file view from the file chooser,
+ * if there is one).
+ *
+ * @param fc the file chooser component.
+ *
+ * @return The file view.
+ *
+ * @see JFileChooser#getFileView()
+ */
+ public FileView getFileView(JFileChooser fc)
+ {
+ return fv;
+ }
+
+ /**
+ * Returns the dialog title.
+ *
+ * @param fc the file chooser (<code>null</code> not permitted).
+ *
+ * @return The dialog title.
+ *
+ * @see JFileChooser#getDialogTitle()
+ */
+ public String getDialogTitle(JFileChooser fc)
+ {
+ String result = fc.getDialogTitle();
+ if (result == null)
+ result = getApproveButtonText(fc);
+ return result;
+ }
+
+ /**
+ * Returns the approve button mnemonic.
+ *
+ * @param fc the file chooser (<code>null</code> not permitted).
+ *
+ * @return The approve button mnemonic.
+ *
+ * @see JFileChooser#getApproveButtonMnemonic()
+ */
+ public int getApproveButtonMnemonic(JFileChooser fc)
+ {
+ if (fc.getApproveButtonMnemonic() != 0)
+ return fc.getApproveButtonMnemonic();
+ else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ return saveButtonMnemonic;
+ else
+ return openButtonMnemonic;
+ }
+
+ /**
+ * Returns the approve button text.
+ *
+ * @param fc the file chooser (<code>null</code> not permitted).
+ *
+ * @return The approve button text.
+ *
+ * @see JFileChooser#getApproveButtonText()
+ */
+ public String getApproveButtonText(JFileChooser fc)
+ {
+ String result = fc.getApproveButtonText();
+ if (result == null)
+ {
+ if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ result = saveButtonText;
+ else
+ result = openButtonText;
+ }
+ return result;
+ }
+
+ /**
+ * Creates and returns a new action that will be used with the "new folder"
+ * button.
+ *
+ * @return A new instance of {@link NewFolderAction}.
+ */
+ public Action getNewFolderAction()
+ {
+ if (newFolderAction == null)
+ newFolderAction = new NewFolderAction();
+ return newFolderAction;
+ }
+
+ /**
+ * Creates and returns a new action that will be used with the "home folder"
+ * button.
+ *
+ * @return A new instance of {@link GoHomeAction}.
+ */
+ public Action getGoHomeAction()
+ {
+ if (goHomeAction == null)
+ goHomeAction = new GoHomeAction();
+ return goHomeAction;
+ }
+
+ /**
+ * Returns the action that handles events for the "up folder" control button.
+ *
+ * @return An instance of {@link ChangeToParentDirectoryAction}.
+ */
+ public Action getChangeToParentDirectoryAction()
+ {
+ if (changeToParentDirectoryAction == null)
+ changeToParentDirectoryAction = new ChangeToParentDirectoryAction();
+ return changeToParentDirectoryAction;
+ }
+
+ /**
+ * Returns the action that handles events for the "approve" button.
+ *
+ * @return An instance of {@link ApproveSelectionAction}.
+ */
+ public Action getApproveSelectionAction()
+ {
+ if (approveSelectionAction == null)
+ approveSelectionAction = new ApproveSelectionAction();
+ return approveSelectionAction;
+ }
+
+ /**
+ * Returns the action that handles events for the "cancel" button.
+ *
+ * @return An instance of {@link CancelSelectionAction}.
+ */
+ public Action getCancelSelectionAction()
+ {
+ if (cancelSelectionAction == null)
+ cancelSelectionAction = new CancelSelectionAction();
+ return cancelSelectionAction;
+ }
+
+ /**
+ * Returns the update action (an instance of {@link UpdateAction}).
+ *
+ * @return An action.
+ */
+ public Action getUpdateAction()
+ {
+ if (updateAction == null)
+ updateAction = new UpdateAction();
+ return updateAction;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* BasicFormattedTextFieldUI.java
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * @since 1.4
+ */
+public class BasicFormattedTextFieldUI extends BasicTextFieldUI
+{
+ public BasicFormattedTextFieldUI()
+ {
+ // Nothing to do here.
+ }
+
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicFormattedTextFieldUI();
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "FormattedTextField"
+ */
+ protected String getPropertyPrefix()
+ {
+ return "FormattedTextField";
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,816 @@
+/* BasicGraphicsUtils.java
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import gnu.classpath.SystemProperties;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.font.TextLayout;
+import java.awt.geom.Rectangle2D;
+
+import javax.swing.AbstractButton;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
+
+/**
+ * A utility class providing commonly used drawing and measurement
+ * routines.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class BasicGraphicsUtils
+{
+ /**
+ * Used as a key for a client property to store cached TextLayouts in. This
+ * is used for speed-up drawing of text in
+ * {@link #drawString(Graphics, String, int, int, int)}.
+ */
+ static final String CACHED_TEXT_LAYOUT =
+ "BasicGraphicsUtils.cachedTextLayout";
+
+ /**
+ * Constructor. It is utterly unclear why this class should
+ * be constructable, but this is what the API specification
+ * says.
+ */
+ public BasicGraphicsUtils()
+ {
+ // Nothing to do here.
+ }
+
+
+ /**
+ * Draws a rectangle that appears etched into the surface, given
+ * four colors that are used for drawing.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-1.png" width="360"
+ * height="200" alt="[An illustration that shows which pixels
+ * get painted in what color]" />
+ *
+ * @param g the graphics into which the rectangle is drawn.
+ * @param x the x coordinate of the rectangle.
+ * @param y the y coordinate of the rectangle.
+ * @param width the width of the rectangle in pixels.
+ * @param height the height of the rectangle in pixels.
+ *
+ * @param shadow the color that will be used for painting
+ * the outer side of the top and left edges.
+ *
+ * @param darkShadow the color that will be used for painting
+ * the inner side of the top and left edges.
+ *
+ * @param highlight the color that will be used for painting
+ * the inner side of the bottom and right edges.
+ *
+ * @param lightHighlight the color that will be used for painting
+ * the outer side of the bottom and right edges.
+ *
+ * @see #getEtchedInsets()
+ * @see javax.swing.border.EtchedBorder
+ */
+ public static void drawEtchedRect(Graphics g,
+ int x, int y, int width, int height,
+ Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ Color oldColor;
+ int x2, y2;
+
+ oldColor = g.getColor();
+ x2 = x + width - 1;
+ y2 = y + height - 1;
+
+ try
+ {
+ /* To understand this code, it might be helpful to look at the
+ * image "BasicGraphicsUtils-1.png" that is included with the
+ * JavaDoc. The file is located in the "doc-files" subdirectory.
+ *
+ * (x2, y2) is the coordinate of the most right and bottom pixel
+ * to be painted.
+ */
+ g.setColor(shadow);
+ g.drawLine(x, y, x2 - 1, y); // top, outer
+ g.drawLine(x, y + 1, x, y2 - 1); // left, outer
+
+ g.setColor(darkShadow);
+ g.drawLine(x + 1, y + 1, x2 - 2, y + 1); // top, inner
+ g.drawLine(x + 1, y + 2, x + 1, y2 - 2); // left, inner
+
+ g.setColor(highlight);
+ g.drawLine(x + 1, y2 - 1, x2 - 1, y2 - 1); // bottom, inner
+ g.drawLine(x2 - 1, y + 1, x2 - 1, y2 - 2); // right, inner
+
+ g.setColor(lightHighlight);
+ g.drawLine(x, y2, x2, y2); // bottom, outer
+ g.drawLine(x2, y, x2, y2 - 1); // right, outer
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Determines the width of the border that gets painted by
+ * {@link #drawEtchedRect}.
+ *
+ * @return an <code>Insets</code> object whose <code>top</code>,
+ * <code>left</code>, <code>bottom</code> and
+ * <code>right</code> field contain the border width at the
+ * respective edge in pixels.
+ */
+ public static Insets getEtchedInsets()
+ {
+ return new Insets(2, 2, 2, 2);
+ }
+
+
+ /**
+ * Draws a rectangle that appears etched into the surface, given
+ * two colors that are used for drawing.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-2.png" width="360"
+ * height="200" alt="[An illustration that shows which pixels
+ * get painted in what color]" />
+ *
+ * @param g the graphics into which the rectangle is drawn.
+ * @param x the x coordinate of the rectangle.
+ * @param y the y coordinate of the rectangle.
+ * @param width the width of the rectangle in pixels.
+ * @param height the height of the rectangle in pixels.
+ *
+ * @param shadow the color that will be used for painting the outer
+ * side of the top and left edges, and for the inner side of
+ * the bottom and right ones.
+ *
+ * @param highlight the color that will be used for painting the
+ * inner side of the top and left edges, and for the outer
+ * side of the bottom and right ones.
+ *
+ * @see #getGrooveInsets()
+ * @see javax.swing.border.EtchedBorder
+ */
+ public static void drawGroove(Graphics g,
+ int x, int y, int width, int height,
+ Color shadow, Color highlight)
+ {
+ /* To understand this, it might be helpful to look at the image
+ * "BasicGraphicsUtils-2.png" that is included with the JavaDoc,
+ * and to compare it with "BasicGraphicsUtils-1.png" which shows
+ * the pixels painted by drawEtchedRect. These image files are
+ * located in the "doc-files" subdirectory.
+ */
+ drawEtchedRect(g, x, y, width, height,
+ /* outer topLeft */ shadow,
+ /* inner topLeft */ highlight,
+ /* inner bottomRight */ shadow,
+ /* outer bottomRight */ highlight);
+ }
+
+
+ /**
+ * Determines the width of the border that gets painted by
+ * {@link #drawGroove}.
+ *
+ * @return an <code>Insets</code> object whose <code>top</code>,
+ * <code>left</code>, <code>bottom</code> and
+ * <code>right</code> field contain the border width at the
+ * respective edge in pixels.
+ */
+ public static Insets getGrooveInsets()
+ {
+ return new Insets(2, 2, 2, 2);
+ }
+
+
+ /**
+ * Draws a border that is suitable for buttons of the Basic look and
+ * feel.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-3.png" width="500"
+ * height="300" alt="[An illustration that shows which pixels
+ * get painted in what color]" />
+ *
+ * @param g the graphics into which the rectangle is drawn.
+ * @param x the x coordinate of the rectangle.
+ * @param y the y coordinate of the rectangle.
+ * @param width the width of the rectangle in pixels.
+ * @param height the height of the rectangle in pixels.
+ *
+ * @param isPressed <code>true</code> to draw the button border
+ * with a pressed-in appearance; <code>false</code> for
+ * normal (unpressed) appearance.
+ *
+ * @param isDefault <code>true</code> to draw the border with
+ * the appearance it has when hitting the enter key in a
+ * dialog will simulate a click to this button;
+ * <code>false</code> for normal appearance.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public static void drawBezel(Graphics g,
+ int x, int y, int width, int height,
+ boolean isPressed, boolean isDefault,
+ Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ Color oldColor = g.getColor();
+
+ /* To understand this, it might be helpful to look at the image
+ * "BasicGraphicsUtils-3.png" that is included with the JavaDoc,
+ * and to compare it with "BasicGraphicsUtils-1.png" which shows
+ * the pixels painted by drawEtchedRect. These image files are
+ * located in the "doc-files" subdirectory.
+ */
+ try
+ {
+ if ((isPressed == false) && (isDefault == false))
+ {
+ drawEtchedRect(g, x, y, width, height,
+ lightHighlight, highlight,
+ shadow, darkShadow);
+ }
+
+ if ((isPressed == true) && (isDefault == false))
+ {
+ g.setColor(shadow);
+ g.drawRect(x + 1, y + 1, width - 2, height - 2);
+ }
+
+ if ((isPressed == false) && (isDefault == true))
+ {
+ g.setColor(darkShadow);
+ g.drawRect(x, y, width - 1, height - 1);
+ drawEtchedRect(g, x + 1, y + 1, width - 2, height - 2,
+ lightHighlight, highlight,
+ shadow, darkShadow);
+ }
+
+ if ((isPressed == true) && (isDefault == true))
+ {
+ g.setColor(darkShadow);
+ g.drawRect(x, y, width - 1, height - 1);
+ g.setColor(shadow);
+ g.drawRect(x + 1, y + 1, width - 3, height - 3);
+ }
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Draws a rectangle that appears lowered into the surface, given
+ * four colors that are used for drawing.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-4.png" width="360"
+ * height="200" alt="[An illustration that shows which pixels
+ * get painted in what color]" />
+ *
+ * <p><strong>Compatibility with the Sun reference
+ * implementation:</strong> The Sun reference implementation seems
+ * to ignore the <code>x</code> and <code>y</code> arguments, at
+ * least in JDK 1.3.1 and 1.4.1_01. The method always draws the
+ * rectangular area at location (0, 0). A bug report has been filed
+ * with Sun; its “bug ID” is 4880003. The GNU Classpath
+ * implementation behaves correctly, thus not replicating this bug.
+ *
+ * @param g the graphics into which the rectangle is drawn.
+ * @param x the x coordinate of the rectangle.
+ * @param y the y coordinate of the rectangle.
+ * @param width the width of the rectangle in pixels.
+ * @param height the height of the rectangle in pixels.
+ *
+ * @param shadow the color that will be used for painting
+ * the inner side of the top and left edges.
+ *
+ * @param darkShadow the color that will be used for painting
+ * the outer side of the top and left edges.
+ *
+ * @param highlight the color that will be used for painting
+ * the inner side of the bottom and right edges.
+ *
+ * @param lightHighlight the color that will be used for painting
+ * the outer side of the bottom and right edges.
+ */
+ public static void drawLoweredBezel(Graphics g,
+ int x, int y, int width, int height,
+ Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ /* Like drawEtchedRect, but swapping darkShadow and shadow.
+ *
+ * To understand this, it might be helpful to look at the image
+ * "BasicGraphicsUtils-4.png" that is included with the JavaDoc,
+ * and to compare it with "BasicGraphicsUtils-1.png" which shows
+ * the pixels painted by drawEtchedRect. These image files are
+ * located in the "doc-files" subdirectory.
+ */
+ drawEtchedRect(g, x, y, width, height,
+ darkShadow, shadow,
+ highlight, lightHighlight);
+ }
+
+
+ /**
+ * Draws a String at the given location, underlining the first
+ * occurence of a specified character. The algorithm for determining
+ * the underlined position is not sensitive to case. If the
+ * character is not part of <code>text</code>, the text will be
+ * drawn without underlining. Drawing is performed in the current
+ * color and font of <code>g</code>.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-5.png" width="500"
+ * height="100" alt="[An illustration showing how to use the
+ * method]" />
+ *
+ * @param g the graphics into which the String is drawn.
+ *
+ * @param text the String to draw.
+ *
+ * @param underlinedChar the character whose first occurence in
+ * <code>text</code> will be underlined. It is not clear
+ * why the API specification declares this argument to be
+ * of type <code>int</code> instead of <code>char</code>.
+ * While this would allow to pass Unicode characters outside
+ * Basic Multilingual Plane 0 (U+0000 .. U+FFFE), at least
+ * the GNU Classpath implementation does not underline
+ * anything if <code>underlinedChar</code> is outside
+ * the range of <code>char</code>.
+ *
+ * @param x the x coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ *
+ * @param y the y coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ */
+ public static void drawString(Graphics g, String text,
+ int underlinedChar, int x, int y)
+ {
+ int index = -1;
+
+ /* It is intentional that lower case is used. In some languages,
+ * the set of lowercase characters is larger than the set of
+ * uppercase ones. Therefore, it is good practice to use lowercase
+ * for such comparisons (which really means that the author of this
+ * code can vaguely remember having read some Unicode techreport
+ * with this recommendation, but is too lazy to look for the URL).
+ */
+ if ((underlinedChar >= 0) || (underlinedChar <= 0xffff))
+ index = text.toLowerCase().indexOf(
+ Character.toLowerCase((char) underlinedChar));
+
+ drawStringUnderlineCharAt(g, text, index, x, y);
+ }
+
+
+ /**
+ * Draws a String at the given location, underlining the character
+ * at the specified index. Drawing is performed in the current color
+ * and font of <code>g</code>.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-5.png" width="500"
+ * height="100" alt="[An illustration showing how to use the
+ * method]" />
+ *
+ * @param g the graphics into which the String is drawn.
+ *
+ * @param text the String to draw.
+ *
+ * @param underlinedIndex the index of the underlined character in
+ * <code>text</code>. If <code>underlinedIndex</code> falls
+ * outside the range <code>[0, text.length() - 1]</code>, the
+ * text will be drawn without underlining anything.
+ *
+ * @param x the x coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ *
+ * @param y the y coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ *
+ * @since 1.4
+ */
+ public static void drawStringUnderlineCharAt(Graphics g, String text,
+ int underlinedIndex,
+ int x, int y)
+ {
+ Graphics2D g2;
+ Rectangle2D.Double underline;
+ FontRenderContext frc;
+ FontMetrics fmet;
+ LineMetrics lineMetrics;
+ Font font;
+ TextLayout layout;
+ double underlineX1, underlineX2;
+ boolean drawUnderline;
+ int textLength;
+
+ textLength = text.length();
+ if (textLength == 0)
+ return;
+
+ drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength);
+
+ // FIXME: unfortunately pango and cairo can't agree on metrics
+ // so for the time being we continue to *not* use TextLayouts.
+ if (true || !(g instanceof Graphics2D))
+ {
+ /* Fall-back. This is likely to produce garbage for any text
+ * containing right-to-left (Hebrew or Arabic) characters, even
+ * if the underlined character is left-to-right.
+ */
+ g.drawString(text, x, y);
+ if (drawUnderline)
+ {
+ fmet = g.getFontMetrics();
+ g.fillRect(
+ /* x */ x + fmet.stringWidth(text.substring(0, underlinedIndex)),
+ /* y */ y + fmet.getDescent() - 1,
+ /* width */ fmet.charWidth(text.charAt(underlinedIndex)),
+ /* height */ 1);
+ }
+
+ return;
+ }
+
+ g2 = (Graphics2D) g;
+ font = g2.getFont();
+ frc = g2.getFontRenderContext();
+ lineMetrics = font.getLineMetrics(text, frc);
+ layout = new TextLayout(text, font, frc);
+
+ /* Draw the text. */
+ layout.draw(g2, x, y);
+ if (!drawUnderline)
+ return;
+
+ underlineX1 = x + layout.getLogicalHighlightShape(
+ underlinedIndex, underlinedIndex).getBounds2D().getX();
+ underlineX2 = x + layout.getLogicalHighlightShape(
+ underlinedIndex + 1, underlinedIndex + 1).getBounds2D().getX();
+
+ underline = new Rectangle2D.Double();
+ if (underlineX1 < underlineX2)
+ {
+ underline.x = underlineX1;
+ underline.width = underlineX2 - underlineX1;
+ }
+ else
+ {
+ underline.x = underlineX2;
+ underline.width = underlineX1 - underlineX2;
+ }
+
+
+ underline.height = lineMetrics.getUnderlineThickness();
+ underline.y = lineMetrics.getUnderlineOffset();
+ if (underline.y == 0)
+ {
+ /* Some fonts do not specify an underline offset, although they
+ * actually should do so. In that case, the result of calling
+ * lineMetrics.getUnderlineOffset() will be zero. Since it would
+ * look very ugly if the underline was be positioned immediately
+ * below the baseline, we check for this and move the underline
+ * below the descent, as shown in the following ASCII picture:
+ *
+ * ##### ##### #
+ * # # # #
+ * # # # #
+ * # # # #
+ * ##### ###### ---- baseline (0)
+ * #
+ * #
+ * ------------------###----------- lineMetrics.getDescent()
+ */
+ underline.y = lineMetrics.getDescent();
+ }
+
+ underline.y += y;
+ g2.fill(underline);
+ }
+
+ /**
+ * Draws a string on the specified component.
+ *
+ * @param c the component
+ * @param g the Graphics context
+ * @param text the string
+ * @param underlinedChar the character to be underlined
+ * @param x the X location
+ * @param y the Y location
+ */
+ static void drawString(JComponent c, Graphics g, String text,
+ int underlinedChar, int x, int y)
+ {
+ int index = -1;
+
+ /* It is intentional that lower case is used. In some languages,
+ * the set of lowercase characters is larger than the set of
+ * uppercase ones. Therefore, it is good practice to use lowercase
+ * for such comparisons (which really means that the author of this
+ * code can vaguely remember having read some Unicode techreport
+ * with this recommendation, but is too lazy to look for the URL).
+ */
+ if ((underlinedChar >= 0) || (underlinedChar <= 0xffff))
+ index = text.toLowerCase().indexOf(
+ Character.toLowerCase((char) underlinedChar));
+
+ drawStringUnderlineCharAt(c, g, text, index, x, y);
+ }
+
+
+ /**
+ * Draws a String at the given location, underlining the character
+ * at the specified index. Drawing is performed in the current color
+ * and font of <code>g</code>.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-5.png" width="500"
+ * height="100" alt="[An illustration showing how to use the
+ * method]" />
+ *
+ * This is an accelerated version of the method with the same name. It
+ * uses a pre-laid out TextLayout stored in a client property.
+ *
+ * @param c the component that is drawn
+ * @param g the graphics into which the String is drawn.
+ *
+ * @param text the String to draw.
+ *
+ * @param underlinedIndex the index of the underlined character in
+ * <code>text</code>. If <code>underlinedIndex</code> falls
+ * outside the range <code>[0, text.length() - 1]</code>, the
+ * text will be drawn without underlining anything.
+ *
+ * @param x the x coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ *
+ * @param y the y coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ */
+ static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text,
+ int underlinedIndex,
+ int x, int y)
+ {
+ Graphics2D g2;
+ Rectangle2D.Double underline;
+ FontRenderContext frc;
+ FontMetrics fmet;
+ LineMetrics lineMetrics;
+ Font font;
+ TextLayout layout;
+ double underlineX1, underlineX2;
+ boolean drawUnderline;
+ int textLength;
+
+ textLength = text.length();
+ if (textLength == 0)
+ return;
+
+ drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength);
+
+ // FIXME: unfortunately pango and cairo can't agree on metrics
+ // so for the time being we continue to *not* use TextLayouts.
+ if (!(g instanceof Graphics2D)
+ || SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") != null)
+ {
+ /* Fall-back. This is likely to produce garbage for any text
+ * containing right-to-left (Hebrew or Arabic) characters, even
+ * if the underlined character is left-to-right.
+ */
+ g.drawString(text, x, y);
+ if (drawUnderline)
+ {
+ fmet = g.getFontMetrics();
+ g.fillRect(
+ /* x */ x + fmet.stringWidth(text.substring(0, underlinedIndex)),
+ /* y */ y + fmet.getDescent() - 1,
+ /* width */ fmet.charWidth(text.charAt(underlinedIndex)),
+ /* height */ 1);
+ }
+
+ return;
+ }
+
+ g2 = (Graphics2D) g;
+ font = g2.getFont();
+ frc = g2.getFontRenderContext();
+ lineMetrics = font.getLineMetrics(text, frc);
+ layout = (TextLayout) c.getClientProperty(CACHED_TEXT_LAYOUT);
+ if (layout == null)
+ {
+ layout = new TextLayout(text, font, frc);
+ System.err.println("Unable to use cached TextLayout for: " + text);
+ }
+
+ /* Draw the text. */
+ layout.draw(g2, x, y);
+ if (!drawUnderline)
+ return;
+
+ underlineX1 = x + layout.getLogicalHighlightShape(
+ underlinedIndex, underlinedIndex).getBounds2D().getX();
+ underlineX2 = x + layout.getLogicalHighlightShape(
+ underlinedIndex + 1, underlinedIndex + 1).getBounds2D().getX();
+
+ underline = new Rectangle2D.Double();
+ if (underlineX1 < underlineX2)
+ {
+ underline.x = underlineX1;
+ underline.width = underlineX2 - underlineX1;
+ }
+ else
+ {
+ underline.x = underlineX2;
+ underline.width = underlineX1 - underlineX2;
+ }
+
+
+ underline.height = lineMetrics.getUnderlineThickness();
+ underline.y = lineMetrics.getUnderlineOffset();
+ if (underline.y == 0)
+ {
+ /* Some fonts do not specify an underline offset, although they
+ * actually should do so. In that case, the result of calling
+ * lineMetrics.getUnderlineOffset() will be zero. Since it would
+ * look very ugly if the underline was be positioned immediately
+ * below the baseline, we check for this and move the underline
+ * below the descent, as shown in the following ASCII picture:
+ *
+ * ##### ##### #
+ * # # # #
+ * # # # #
+ * # # # #
+ * ##### ###### ---- baseline (0)
+ * #
+ * #
+ * ------------------###----------- lineMetrics.getDescent()
+ */
+ underline.y = lineMetrics.getDescent();
+ }
+
+ underline.y += y;
+ g2.fill(underline);
+ }
+
+ /**
+ * Draws a rectangle, simulating a dotted stroke by painting only
+ * every second pixel along the one-pixel thick edge. The color of
+ * those pixels is the current color of the Graphics <code>g</code>.
+ * Any other pixels are left unchanged.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-7.png" width="360"
+ * height="200" alt="[An illustration that shows which pixels
+ * get painted]" />
+ *
+ * @param g the graphics into which the rectangle is drawn.
+ * @param x the x coordinate of the rectangle.
+ * @param y the y coordinate of the rectangle.
+ * @param width the width of the rectangle in pixels.
+ * @param height the height of the rectangle in pixels.
+ */
+ public static void drawDashedRect(Graphics g,
+ int x, int y, int width, int height)
+ {
+ int right = x + width - 1;
+ int bottom = y + height - 1;
+
+ /* Draw the top and bottom edge of the dotted rectangle. */
+ for (int i = x; i <= right; i += 2)
+ {
+ g.drawLine(i, y, i, y);
+ g.drawLine(i, bottom, i, bottom);
+ }
+
+ /* Draw the left and right edge of the dotted rectangle. */
+ for (int i = y; i <= bottom; i += 2)
+ {
+ g.drawLine(x, i, x, i);
+ g.drawLine(right, i, right, i);
+ }
+ }
+
+
+ /**
+ * Determines the preferred width and height of an AbstractButton,
+ * given the gap between the button’s text and icon.
+ *
+ * @param b the button whose preferred size is determined.
+ *
+ * @param textIconGap the gap between the button’s text and
+ * icon.
+ *
+ * @return a <code>Dimension</code> object whose <code>width</code>
+ * and <code>height</code> fields indicate the preferred
+ * extent in pixels.
+ *
+ * @see javax.swing.SwingUtilities#layoutCompoundLabel(JComponent,
+ * FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle,
+ * Rectangle, int)
+ */
+ public static Dimension getPreferredButtonSize(AbstractButton b,
+ int textIconGap)
+ {
+ Rectangle contentRect;
+ Rectangle viewRect;
+ Rectangle iconRect = new Rectangle();
+ Rectangle textRect = new Rectangle();
+ Insets insets = b.getInsets();
+
+ viewRect = new Rectangle();
+
+ /* java.awt.Toolkit.getFontMetrics is deprecated. However, it
+ * seems not obvious how to get to the correct FontMetrics object
+ * otherwise. The real problem probably is that the method
+ * javax.swing.SwingUtilities.layoutCompundLabel should take a
+ * LineMetrics, not a FontMetrics argument. But fixing this that
+ * would change the public API.
+ */
+ SwingUtilities.layoutCompoundLabel(
+ b, // for the component orientation
+ b.getToolkit().getFontMetrics(b.getFont()), // see comment above
+ b.getText(),
+ b.getIcon(),
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ viewRect, iconRect, textRect,
+ textIconGap);
+
+ /* +------------------------+ +------------------------+
+ * | | | |
+ * | ICON | | CONTENTCONTENTCONTENT |
+ * | TEXTTEXTTEXT | --> | CONTENTCONTENTCONTENT |
+ * | TEXTTEXTTEXT | | CONTENTCONTENTCONTENT |
+ * +------------------------+ +------------------------+
+ */
+
+ contentRect = textRect.union(iconRect);
+
+ return new Dimension(insets.left
+ + contentRect.width
+ + insets.right + b.getHorizontalAlignment(),
+ insets.top
+ + contentRect.height
+ + insets.bottom);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicHTML.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicHTML.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicHTML.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicHTML.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,445 @@
+/* BasicHTML.java -- Provides HTML support to ComponentUI implementations
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.swing.JComponent;
+import javax.swing.SwingConstants;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.EditorKit;
+import javax.swing.text.Element;
+import javax.swing.text.Position;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
+
+/**
+ * Provides support for HTML rendering to {@link javax.swing.plaf.ComponentUI}
+ * implementations.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+public class BasicHTML
+{
+
+ /**
+ * This class serves as the root view for HTML rendering components.
+ * Its purpose and implementation is similar to the BasicTextUI.RootView
+ * class, only that is implements some stuff differently due to the nature
+ * of not beeing inside a JTextComponent.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private static class HTMLRootView extends View
+ {
+ /**
+ * The real root view.
+ */
+ private View view;
+
+ /**
+ * The component on which to render the view.
+ */
+ private JComponent component;
+
+ /**
+ * The EditorKit.
+ */
+ private EditorKit editorKit;
+
+ /**
+ * The document to use.
+ */
+ private Document document;
+
+ /**
+ * Creates a new RootView.
+ */
+ public HTMLRootView(JComponent c, View view, EditorKit kit, Document doc)
+ {
+ super(null);
+ component = c;
+ editorKit = kit;
+ document = doc;
+ setView(view);
+ }
+
+ /**
+ * Returns the ViewFactory for this RootView. If the current EditorKit
+ * provides a ViewFactory, this is used. Otherwise the TextUI itself
+ * is returned as a ViewFactory.
+ *
+ * @return the ViewFactory for this RootView
+ */
+ public ViewFactory getViewFactory()
+ {
+ return editorKit.getViewFactory();
+ }
+
+ /**
+ * Indicates that the preferences of one of the child view has changed.
+ * This calls revalidate on the text component.
+ *
+ * @param v the child view which's preference has changed
+ * @param width <code>true</code> if the width preference has changed
+ * @param height <code>true</code> if the height preference has changed
+ */
+ public void preferenceChanged(View v, boolean width, boolean height)
+ {
+ component.revalidate();
+ }
+
+ /**
+ * Sets the real root view.
+ *
+ * @param v the root view to set
+ */
+ public void setView(View v)
+ {
+ if (view != null)
+ view.setParent(null);
+
+ if (v != null)
+ v.setParent(this);
+
+ view = v;
+ }
+
+ /**
+ * Returns the real root view, regardless of the index.
+ *
+ * @param index not used here
+ *
+ * @return the real root view, regardless of the index.
+ */
+ public View getView(int index)
+ {
+ return view;
+ }
+
+ /**
+ * Returns <code>1</code> since the RootView always contains one
+ * child, that is the real root of the View hierarchy.
+ *
+ * @return <code>1</code> since the RootView always contains one
+ * child, that is the real root of the View hierarchy
+ */
+ public int getViewCount()
+ {
+ int count = 0;
+ if (view != null)
+ count = 1;
+ return count;
+ }
+
+ /**
+ * Returns the <code>Container</code> that contains this view. This
+ * normally will be the text component that is managed by this TextUI.
+ *
+ * @return the <code>Container</code> that contains this view
+ */
+ public Container getContainer()
+ {
+ return component;
+ }
+
+ /**
+ * Returns the preferred span along the specified <code>axis</code>.
+ * This is delegated to the real root view.
+ *
+ * @param axis the axis for which the preferred span is queried
+ *
+ * @return the preferred span along the axis
+ */
+ public float getPreferredSpan(int axis)
+ {
+ if (view != null)
+ return view.getPreferredSpan(axis);
+
+ return Integer.MAX_VALUE;
+ }
+
+ /**
+ * Paints the view. This is delegated to the real root view.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ * @param s the allocation for the View
+ */
+ public void paint(Graphics g, Shape s)
+ {
+ if (view != null)
+ {
+ Rectangle b = s.getBounds();
+ view.setSize(b.width, b.height);
+ view.paint(g, s);
+ }
+ }
+
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * This is delegated to the real root view.
+ *
+ * @param position the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int position, Shape a, Position.Bias bias)
+ throws BadLocationException
+ {
+ return view.modelToView(position, a, bias);
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
+ {
+ return view.viewToModel(x, y, a, b);
+ }
+
+ /**
+ * Notification about text insertions. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.insertUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Notification about text removals. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.removeUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Notification about text changes. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.changedUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Returns the document position that is (visually) nearest to the given
+ * document position <code>pos</code> in the given direction <code>d</code>.
+ *
+ * @param pos the document position
+ * @param b the bias for <code>pos</code>
+ * @param a the allocation for the view
+ * @param d the direction, must be either {@link SwingConstants#NORTH},
+ * {@link SwingConstants#SOUTH}, {@link SwingConstants#WEST} or
+ * {@link SwingConstants#EAST}
+ * @param biasRet an array of {@link Position.Bias} that can hold at least
+ * one element, which is filled with the bias of the return position
+ * on method exit
+ *
+ * @return the document position that is (visually) nearest to the given
+ * document position <code>pos</code> in the given direction
+ * <code>d</code>
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid offset in
+ * the document model
+ */
+ public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
+ int d, Position.Bias[] biasRet)
+ throws BadLocationException
+ {
+ return view.getNextVisualPositionFrom(pos, b, a, d, biasRet);
+ }
+
+ public int getStartOffset()
+ {
+ return 0;
+ }
+
+ public int getEndOffset()
+ {
+ return getDocument().getLength();
+ }
+
+ public Document getDocument()
+ {
+ return document;
+ }
+ }
+
+ /**
+ * The key that is used to store a HTML view in a JComponent's client
+ * properties.
+ */
+ public static final String propertyKey = "html";
+
+ /**
+ * The key that is used to store the document base in a JComponent's client
+ * properties. The document base is used to resolve relative references
+ * in HTML.
+ */
+ public static final String documentBaseKey = "html.base";
+
+ /**
+ * Creates a new instance of BasicHTML. This should not be necessary since
+ * all methods in this class are static.
+ */
+ public BasicHTML()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Creates a {@link View} instance that can be used by the component
+ * <code>c</code> to render the HTML string <code>html</code>.
+ *
+ * @param c the component that needs to render the HTML string
+ * @param html the HTML string to be rendered
+ *
+ * @return a view that can render the HTML string
+ */
+ public static View createHTMLView(JComponent c, String html)
+ {
+ // TODO: This might be wrong. Lets see if it turns out good when
+ // the javax.swing.text.html package is in a good shape.
+ HTMLDocument doc = new HTMLDocument();
+ HTMLEditorKit kit = new HTMLEditorKit();
+ StringReader reader = new StringReader(html);
+ try
+ {
+ kit.read(reader, doc, 0);
+ }
+ catch (IOException ex)
+ {
+ AssertionError err = new AssertionError("unexpected IOException");
+ err.initCause(ex);
+ throw err;
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError err =
+ new AssertionError("unexpected BadLocationException");
+ err.initCause(ex);
+ throw err;
+ }
+ ViewFactory vf = kit.getViewFactory();
+ Element root = doc.getDefaultRootElement();
+ View view = vf.create(root);
+ HTMLRootView rootView = new HTMLRootView(c, view, kit, doc);
+ return rootView;
+ }
+
+ /**
+ * Returns <code>true</code> if <code>s</code> is HTML, <code>false</code>
+ * otherwise.
+ *
+ * @param s the string to test
+ *
+ * @return <code>true</code> if <code>s</code> is HTML, <code>false</code>
+ * otherwise
+ */
+ public static boolean isHTMLString(String s)
+ {
+ // We consider a string to be HTML if it contains both the '<' and '>'
+ // character at least once.
+ return (s != null) && s.contains("<") && s.contains(">");
+ }
+
+ /**
+ * Stores a HTML renderer in <code>c</code>'s client property if
+ * <code>text</code> is HTML, otherwise it clears the corresponding client
+ * property. This is useful for {@link javax.swing.plaf.ComponentUI}
+ * implementations that are shared between it's components.
+ *
+ * @param c the component to update the renderer for
+ * @param text the string to be rendered
+ */
+ public static void updateRenderer(JComponent c, String text)
+ {
+ if (isHTMLString(text))
+ c.putClientProperty(propertyKey, createHTMLView(c, text));
+ else
+ c.putClientProperty(propertyKey, null);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,328 @@
+/* BasicIconFactory.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBoxMenuItem;
+
+/**
+ * Creates icons for the {@link BasicLookAndFeel}.
+ */
+public class BasicIconFactory implements Serializable
+{
+ static final long serialVersionUID = 5605588811185324383L;
+
+ private static class DummyIcon
+ implements Icon
+ {
+ public int getIconHeight()
+ {
+ return 10;
+ }
+ public int getIconWidth()
+ {
+ return 10;
+ }
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color save = g.getColor();
+ g.setColor(c.getForeground());
+ g.drawRect(x, y, 10, 10);
+ g.setColor(save);
+ }
+ }
+
+ /**
+ * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class CheckBoxIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel CheckBox icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel CheckBox icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // The icon is empty and needs no painting.
+ }
+ }
+
+ /**
+ * The icon used for {@link JCheckBoxMenuItem}s in the
+ * {@link BasicLookAndFeel}. This icon has a size of 9x9 pixels.
+ */
+ static class CheckBoxMenuItemIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon in pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 9;
+ }
+
+ /**
+ * Returns the width of the icon in pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 9;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
+ if (item.isSelected())
+ {
+ // paint the check...
+ g.setColor(Color.black);
+ g.drawLine(x + 1, y + 3, x + 1, y + 4);
+ g.drawLine(x + 2, y + 4, x + 2, y + 5);
+ for (int i = 0; i < 5; i++)
+ g.drawLine(x + 3 + i, y + 5 - i, x + 3 + i, y + 6 - i);
+ }
+ }
+ }
+
+ /**
+ * The icon used for RadioButtons in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class RadioButtonIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel RadioButton icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel RadioButton icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel RadioButton icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // The icon is empty and needs no painting.
+ }
+ }
+ /** The cached CheckBoxIcon instance. */
+ private static CheckBoxIcon checkBoxIcon;
+
+ /** The cached RadioButtonIcon instance. */
+ private static RadioButtonIcon radioButtonIcon;
+
+ public static Icon getMenuItemCheckIcon()
+ {
+ return new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+ g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+ g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+ g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+ g.setColor(saved);
+ }
+ };
+ }
+ public static Icon getMenuItemArrowIcon()
+ {
+ return new DummyIcon();
+ }
+
+ /**
+ * Returns a new instance of a 4 x 8 icon showing a small black triangle that
+ * points to the right. This is displayed in menu items that have a
+ * sub menu.
+ *
+ * @return The icon.
+ */
+ public static Icon getMenuArrowIcon()
+ {
+ return new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 8;
+ }
+ public int getIconWidth()
+ {
+ return 4;
+ }
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
+ g.setColor(saved);
+ }
+ };
+ }
+
+ /**
+ * Returns an icon for CheckBoxes in the BasicLookAndFeel. CheckBox icons
+ * in the Basic L&F are empty and have a size of 13x13 pixels.
+ * This method returns a shared single instance of this icon.
+ *
+ * @return an icon for CheckBoxes in the BasicLookAndFeel
+ */
+ public static Icon getCheckBoxIcon()
+ {
+ if (checkBoxIcon == null)
+ checkBoxIcon = new CheckBoxIcon();
+ return checkBoxIcon;
+ }
+
+ /**
+ * Returns an icon for RadioButtons in the BasicLookAndFeel. RadioButton
+ * icons in the Basic L&F are empty and have a size of 13x13 pixels.
+ * This method returns a shared single instance of this icon.
+ *
+ * @return an icon for RadioButtons in the BasicLookAndFeel
+ */
+ public static Icon getRadioButtonIcon()
+ {
+ if (radioButtonIcon == null)
+ radioButtonIcon = new RadioButtonIcon();
+ return radioButtonIcon;
+ }
+
+ /**
+ * Creates and returns an icon used when rendering {@link JCheckBoxMenuItem}
+ * components.
+ *
+ * @return An icon.
+ */
+ public static Icon getCheckBoxMenuItemIcon()
+ {
+ return new CheckBoxMenuItemIcon();
+ }
+
+ public static Icon getRadioButtonMenuItemIcon()
+ {
+ return getRadioButtonIcon();
+ }
+
+ public static Icon createEmptyFrameIcon()
+ {
+ return new DummyIcon();
+ }
+} // class BasicIconFactory
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1009 @@
+/* BasicInternalFrameTitlePane.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+/**
+ * This class acts as a titlebar for JInternalFrames.
+ */
+public class BasicInternalFrameTitlePane extends JComponent
+{
+ /**
+ * The Action responsible for closing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class CloseAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public CloseAction()
+ {
+ super("Close");
+ }
+
+ /**
+ * This method is called when something closes the JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (frame.isClosable())
+ {
+ try
+ {
+ frame.setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+ }
+
+ /**
+ * This Action is responsible for iconifying the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class IconifyAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public IconifyAction()
+ {
+ super("Minimize");
+ }
+
+ /**
+ * This method is called when the user wants to iconify the
+ * JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (frame.isIconifiable() && ! frame.isIcon())
+ {
+ try
+ {
+ frame.setIcon(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+ }
+
+ /**
+ * This Action is responsible for maximizing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class MaximizeAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public MaximizeAction()
+ {
+ super("Maximize");
+ }
+ /**
+ * This method is called when the user wants to maximize the
+ * JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ if (frame.isMaximizable() && ! frame.isMaximum())
+ frame.setMaximum(true);
+ else if (frame.isMaximum())
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+
+ /**
+ * This Action is responsible for dragging the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class MoveAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public MoveAction()
+ {
+ super("Move");
+ }
+ /**
+ * This method is called when the user wants to drag the JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ // FIXME: Implement keyboard driven? move actions.
+ }
+ }
+
+ /**
+ * This Action is responsible for restoring the JInternalFrame. Restoring
+ * the JInternalFrame is the same as setting the maximum property to false.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class RestoreAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public RestoreAction()
+ {
+ super("Restore");
+ }
+ /**
+ * This method is called when the user wants to restore the
+ * JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (frame.isMaximum())
+ {
+ try
+ {
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+ }
+ }
+ }
+
+ /**
+ * This action is responsible for sizing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class SizeAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public SizeAction()
+ {
+ super("Size");
+ }
+ /**
+ * This method is called when the user wants to resize the JInternalFrame.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ // FIXME: Not sure how size actions should be handled.
+ }
+ }
+
+ /**
+ * This class is responsible for handling property change events from the
+ * JInternalFrame and adjusting the Title Pane as necessary.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * This method is called when a PropertyChangeEvent is received by the
+ * Title Pane.
+ *
+ * @param evt The PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ String propName = evt.getPropertyName();
+ if (propName.equals("closable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ closeButton.setVisible(true);
+ else
+ closeButton.setVisible(false);
+ }
+ else if (propName.equals("iconable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ iconButton.setVisible(true);
+ else
+ iconButton.setVisible(false);
+ }
+ else if (propName.equals("maximizable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ maxButton.setVisible(true);
+ else
+ maxButton.setVisible(false);
+ }
+ enableActions();
+ }
+ }
+
+ /**
+ * This class acts as the MenuBar for the TitlePane. Clicking on the Frame
+ * Icon in the top left corner will activate it.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class SystemMenuBar extends JMenuBar
+ {
+ /**
+ * This method returns true if it can receive focus.
+ *
+ * @return True if this Component can receive focus.
+ */
+ public boolean isFocusTraversable()
+ {
+ return true;
+ }
+
+ /**
+ * This method returns true if this Component is expected to paint all of
+ * itself.
+ *
+ * @return True if this Component is expect to paint all of itself.
+ */
+ public boolean isOpaque()
+ {
+ return true;
+ }
+
+ /**
+ * This method paints this Component.
+ *
+ * @param g The Graphics object to paint with.
+ */
+ public void paint(Graphics g)
+ {
+ Icon frameIcon = frame.getFrameIcon();
+ if (frameIcon == null)
+ frameIcon = BasicDesktopIconUI.defaultIcon;
+ frameIcon.paintIcon(this, g, 0, 0);
+ }
+
+ /**
+ * This method requests that focus be given to this Component.
+ */
+ public void requestFocus()
+ {
+ super.requestFocus();
+ }
+ }
+
+ /**
+ * This class acts as the Layout Manager for the TitlePane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class TitlePaneLayout implements LayoutManager
+ {
+ /**
+ * Creates a new <code>TitlePaneLayout</code> object.
+ */
+ public TitlePaneLayout()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called when adding a Component to the Container.
+ *
+ * @param name The name to reference the added Component by.
+ * @param c The Component to add.
+ */
+ public void addLayoutComponent(String name, Component c)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called to lay out the children of the Title Pane.
+ *
+ * @param c The Container to lay out.
+ */
+ public void layoutContainer(Container c)
+ {
+ Dimension size = c.getSize();
+ Insets insets = c.getInsets();
+ int width = size.width - insets.left - insets.right;
+ int height = size.height - insets.top - insets.bottom;
+
+ // MenuBar is always present and located at the top left corner.
+ Dimension menupref = menuBar.getPreferredSize();
+ menuBar.setBounds(insets.left, insets.top, menupref.width, height);
+
+ int loc = width + insets.left - 1;
+ int top = insets.top + 1;
+ int buttonHeight = height - 4;
+ if (closeButton.isVisible())
+ {
+ int buttonWidth = closeIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ }
+
+ if (maxButton.isVisible())
+ {
+ int buttonWidth = maxIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ }
+
+ if (iconButton.isVisible())
+ {
+ int buttonWidth = iconIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ }
+
+ if (title != null)
+ title.setBounds(insets.left + menupref.width, insets.top,
+ loc - menupref.width - insets.left, height);
+ }
+
+ /**
+ * This method returns the minimum size of the given Container given the
+ * children that it has.
+ *
+ * @param c The Container to get a minimum size for.
+ *
+ * @return The minimum size of the Container.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return preferredLayoutSize(c);
+ }
+
+ /**
+ * This method returns the preferred size of the given Container taking
+ * into account the children that it has.
+ *
+ * @param c The Container to lay out.
+ *
+ * @return The preferred size of the Container.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ return new Dimension(22, 18);
+ }
+
+ /**
+ * This method is called when removing a Component from the Container.
+ *
+ * @param c The Component to remove.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * This helper class is used to create the minimize, maximize and close
+ * buttons in the top right corner of the Title Pane. These buttons are
+ * special since they cannot be given focus and have no border.
+ */
+ private class PaneButton extends JButton
+ {
+ /**
+ * Creates a new PaneButton object with the given Action.
+ *
+ * @param a The Action that the button uses.
+ */
+ public PaneButton(Action a)
+ {
+ super(a);
+ setMargin(new Insets(0, 0, 0, 0));
+ }
+
+ /**
+ * This method returns true if the Component can be focused.
+ *
+ * @return false.
+ */
+ public boolean isFocusable()
+ {
+ // These buttons cannot be given focus.
+ return false;
+ }
+
+ }
+
+ /** The action command for the Close action. */
+ protected static final String CLOSE_CMD;
+
+ /** The action command for the Minimize action. */
+ protected static final String ICONIFY_CMD;
+
+ /** The action command for the Maximize action. */
+ protected static final String MAXIMIZE_CMD;
+
+ /** The action command for the Move action. */
+ protected static final String MOVE_CMD;
+
+ /** The action command for the Restore action. */
+ protected static final String RESTORE_CMD;
+
+ /** The action command for the Size action. */
+ protected static final String SIZE_CMD;
+
+ /** The action associated with closing the JInternalFrame. */
+ protected Action closeAction;
+
+ /** The action associated with iconifying the JInternalFrame. */
+ protected Action iconifyAction;
+
+ /** The action associated with maximizing the JInternalFrame. */
+ protected Action maximizeAction;
+
+ /** The action associated with moving the JInternalFrame. */
+ protected Action moveAction;
+
+ /** The action associated with restoring the JInternalFrame. */
+ protected Action restoreAction;
+
+ /** The action associated with resizing the JInternalFrame. */
+ protected Action sizeAction;
+
+ /** The button that closes the JInternalFrame. */
+ protected JButton closeButton;
+
+ /** The button that iconifies the JInternalFrame. */
+ protected JButton iconButton;
+
+ /** The button that maximizes the JInternalFrame. */
+ protected JButton maxButton;
+
+ /** The icon displayed in the restore button. */
+ protected Icon minIcon = BasicIconFactory.createEmptyFrameIcon();
+
+ /** The icon displayed in the maximize button. */
+ protected Icon maxIcon = BasicIconFactory.createEmptyFrameIcon();
+
+ /** The icon displayed in the iconify button. */
+ protected Icon iconIcon = BasicIconFactory.createEmptyFrameIcon();
+
+ /** The icon displayed in the close button. */
+ protected Icon closeIcon;
+
+ /** The JInternalFrame that this TitlePane is used in. */
+ protected JInternalFrame frame;
+
+ /** The JMenuBar that is located at the top left of the Title Pane. */
+ protected JMenuBar menuBar;
+
+ /** The JMenu inside the menuBar. */
+ protected JMenu windowMenu;
+
+ /**
+ * The text color of the TitlePane when the JInternalFrame is not selected.
+ */
+ protected Color notSelectedTextColor;
+
+ /**
+ * The background color of the TitlePane when the JInternalFrame is not
+ * selected.
+ */
+ protected Color notSelectedTitleColor;
+
+ /** The text color of the titlePane when the JInternalFrame is selected. */
+ protected Color selectedTextColor;
+
+ /**
+ * The background color of the TitlePane when the JInternalFrame is
+ * selected.
+ */
+ protected Color selectedTitleColor;
+
+ /** The Property Change listener that listens to the JInternalFrame. */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /**
+ * The label used to display the title. This label is not added to the
+ * TitlePane.
+ * This is package-private to avoid an accessor method.
+ */
+ transient JLabel title;
+
+ static
+ {
+ // not constants in JDK
+ CLOSE_CMD = "Close";
+ ICONIFY_CMD = "Minimize";
+ MAXIMIZE_CMD = "Maximize";
+ MOVE_CMD = "Move";
+ RESTORE_CMD = "Restore";
+ SIZE_CMD = "Size";
+ }
+
+ /**
+ * Creates a new BasicInternalFrameTitlePane object that is used in the
+ * given JInternalFrame.
+ *
+ * @param f The JInternalFrame this BasicInternalFrameTitlePane will be used
+ * in.
+ */
+ public BasicInternalFrameTitlePane(JInternalFrame f)
+ {
+ frame = f;
+ setLayout(createLayout());
+ title = new JLabel();
+ title.setHorizontalAlignment(SwingConstants.LEFT);
+ title.setHorizontalTextPosition(SwingConstants.LEFT);
+ title.setOpaque(false);
+ setOpaque(true);
+
+ setBackground(Color.LIGHT_GRAY);
+ setOpaque(true);
+
+ installTitlePane();
+ }
+
+ /**
+ * This method installs the TitlePane onto the JInternalFrameTitlePane. It
+ * also creates any children components that need to be created and adds
+ * listeners to the appropriate components.
+ */
+ protected void installTitlePane()
+ {
+ installDefaults();
+ installListeners();
+ createActions();
+
+ assembleSystemMenu();
+
+ createButtons();
+ setButtonIcons();
+ addSubComponents();
+ enableActions();
+ }
+
+ /**
+ * This method adds the sub components to the TitlePane.
+ */
+ protected void addSubComponents()
+ {
+ add(menuBar);
+
+ add(closeButton);
+ add(iconButton);
+ add(maxButton);
+ }
+
+ /**
+ * This method creates the actions that are used to manipulate the
+ * JInternalFrame.
+ */
+ protected void createActions()
+ {
+ closeAction = new CloseAction();
+ closeAction.putValue(AbstractAction.ACTION_COMMAND_KEY, CLOSE_CMD);
+
+ iconifyAction = new IconifyAction();
+ iconifyAction.putValue(AbstractAction.ACTION_COMMAND_KEY, ICONIFY_CMD);
+
+ maximizeAction = new MaximizeAction();
+ maximizeAction.putValue(AbstractAction.ACTION_COMMAND_KEY, MAXIMIZE_CMD);
+
+ sizeAction = new SizeAction();
+ sizeAction.putValue(AbstractAction.ACTION_COMMAND_KEY, SIZE_CMD);
+
+ restoreAction = new RestoreAction();
+ restoreAction.putValue(AbstractAction.ACTION_COMMAND_KEY, RESTORE_CMD);
+
+ moveAction = new MoveAction();
+ moveAction.putValue(AbstractAction.ACTION_COMMAND_KEY, MOVE_CMD);
+ }
+
+ /**
+ * This method is used to install the listeners.
+ */
+ protected void installListeners()
+ {
+ propertyChangeListener = createPropertyChangeListener();
+ frame.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * This method is used to uninstall the listeners.
+ */
+ protected void uninstallListeners()
+ {
+ frame.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+
+ /**
+ * This method installs the defaults determined by the look and feel.
+ */
+ protected void installDefaults()
+ {
+ title.setFont(UIManager.getFont("InternalFrame.titleFont"));
+ selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
+ selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
+ notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
+ notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
+
+ closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
+ iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
+ maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
+ }
+
+ /**
+ * This method uninstalls the defaults.
+ */
+ protected void uninstallDefaults()
+ {
+ setFont(null);
+ selectedTextColor = null;
+ selectedTitleColor = null;
+ notSelectedTextColor = null;
+ notSelectedTitleColor = null;
+
+ closeIcon = null;
+ iconIcon = null;
+ maxIcon = null;
+ }
+
+ /**
+ * This method creates the buttons used in the TitlePane.
+ */
+ protected void createButtons()
+ {
+ closeButton = new PaneButton(closeAction);
+ closeButton.setText(null);
+ if (!frame.isClosable())
+ closeButton.setVisible(false);
+ iconButton = new PaneButton(iconifyAction);
+ iconButton.setText(null);
+ if (!frame.isIconifiable())
+ iconButton.setVisible(false);
+ maxButton = new PaneButton(maximizeAction);
+ maxButton.setText(null);
+ if (!frame.isMaximizable())
+ maxButton.setVisible(false);
+ }
+
+ /**
+ * Set icons for the minimize-, maximize- and close-buttons.
+ */
+ protected void setButtonIcons()
+ {
+ if (closeIcon != null && closeButton != null)
+ closeButton.setIcon(closeIcon);
+ if (iconIcon != null && iconButton != null)
+ iconButton.setIcon(iconIcon);
+ if (maxIcon != null && maxButton != null)
+ maxButton.setIcon(maxIcon);
+ }
+
+ /**
+ * This method creates the MenuBar used in the TitlePane.
+ */
+ protected void assembleSystemMenu()
+ {
+ menuBar = createSystemMenuBar();
+ windowMenu = createSystemMenu();
+
+ menuBar.add(windowMenu);
+
+ addSystemMenuItems(windowMenu);
+ enableActions();
+ }
+
+ /**
+ * This method adds the MenuItems to the given JMenu.
+ *
+ * @param systemMenu The JMenu to add MenuItems to.
+ */
+ protected void addSystemMenuItems(JMenu systemMenu)
+ {
+ JMenuItem tmp;
+
+ tmp = new JMenuItem(RESTORE_CMD);
+ tmp.addActionListener(restoreAction);
+ tmp.setMnemonic(KeyEvent.VK_R);
+ systemMenu.add(tmp);
+
+ tmp = new JMenuItem(MOVE_CMD);
+ tmp.addActionListener(moveAction);
+ tmp.setMnemonic(KeyEvent.VK_M);
+ systemMenu.add(tmp);
+
+ tmp = new JMenuItem(SIZE_CMD);
+ tmp.addActionListener(sizeAction);
+ tmp.setMnemonic(KeyEvent.VK_S);
+ systemMenu.add(tmp);
+
+ tmp = new JMenuItem(ICONIFY_CMD);
+ tmp.addActionListener(iconifyAction);
+ tmp.setMnemonic(KeyEvent.VK_N);
+ systemMenu.add(tmp);
+
+ tmp = new JMenuItem(MAXIMIZE_CMD);
+ tmp.addActionListener(maximizeAction);
+ tmp.setMnemonic(KeyEvent.VK_X);
+ systemMenu.add(tmp);
+
+ systemMenu.addSeparator();
+
+ tmp = new JMenuItem(CLOSE_CMD);
+ tmp.addActionListener(closeAction);
+ tmp.setMnemonic(KeyEvent.VK_C);
+ systemMenu.add(tmp);
+ }
+
+ /**
+ * This method creates a new JMenubar.
+ *
+ * @return A new JMenuBar.
+ */
+ protected JMenuBar createSystemMenuBar()
+ {
+ if (menuBar == null)
+ menuBar = new SystemMenuBar();
+ menuBar.removeAll();
+ return menuBar;
+ }
+
+ /**
+ * This method creates a new JMenu.
+ *
+ * @return A new JMenu.
+ */
+ protected JMenu createSystemMenu()
+ {
+ if (windowMenu == null)
+ windowMenu = new JMenu();
+ windowMenu.removeAll();
+ return windowMenu;
+ }
+
+ /**
+ * This method programmatically shows the JMenu.
+ */
+ protected void showSystemMenu()
+ {
+ // FIXME: Untested as KeyEvents are not hooked up.
+ menuBar.getMenu(1).getPopupMenu().show();
+ }
+
+ /**
+ * This method paints the TitlePane.
+ *
+ * @param g The Graphics object to paint with.
+ */
+ public void paintComponent(Graphics g)
+ {
+ paintTitleBackground(g);
+ if (frame.getTitle() != null && title != null)
+ {
+ Color saved = g.getColor();
+ Font f = title.getFont();
+ g.setFont(f);
+ FontMetrics fm = g.getFontMetrics(f);
+ if (frame.isSelected())
+ g.setColor(selectedTextColor);
+ else
+ g.setColor(notSelectedTextColor);
+ title.setText(getTitle(frame.getTitle(), fm, title.getBounds().width));
+ SwingUtilities.paintComponent(g, title, null, title.getBounds());
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * This method paints the TitlePane's background.
+ *
+ * @param g The Graphics object to paint with.
+ */
+ protected void paintTitleBackground(Graphics g)
+ {
+ if (!isOpaque())
+ return;
+
+ Color saved = g.getColor();
+ Dimension dims = getSize();
+
+ Color bg = getBackground();
+ if (frame.isSelected())
+ bg = selectedTitleColor;
+ else
+ bg = notSelectedTitleColor;
+ g.setColor(bg);
+ g.fillRect(0, 0, dims.width, dims.height);
+ g.setColor(saved);
+ }
+
+ /**
+ * This method returns the title string based on the available width and the
+ * font metrics.
+ *
+ * @param text The desired title.
+ * @param fm The FontMetrics of the font used.
+ * @param availableWidth The available width.
+ *
+ * @return The allowable string.
+ */
+ protected String getTitle(String text, FontMetrics fm, int availableWidth)
+ {
+ Rectangle vr = new Rectangle(0, 0, availableWidth, fm.getHeight());
+ Rectangle ir = new Rectangle();
+ Rectangle tr = new Rectangle();
+ String value = SwingUtilities.layoutCompoundLabel(this, fm, text, null,
+ SwingConstants.CENTER,
+ SwingConstants.LEFT,
+ SwingConstants.CENTER,
+ SwingConstants.LEFT, vr,
+ ir, tr, 0);
+ return value;
+ }
+
+ /**
+ * This method fires something similar to a WINDOW_CLOSING event.
+ *
+ * @param frame The JInternalFrame that is being closed.
+ */
+ protected void postClosingEvent(JInternalFrame frame)
+ {
+ // FIXME: Implement postClosingEvent when I figure out what
+ // it's supposed to do.
+ // It says that this fires an WINDOW_CLOSING like event.
+ // So the closest thing is some kind of InternalFrameEvent.
+ // But none is fired.
+ // Can't see it called or anything.
+ }
+
+ /**
+ * This method enables the actions for the TitlePane given the frame's
+ * properties.
+ */
+ protected void enableActions()
+ {
+ closeAction.setEnabled(frame.isClosable());
+
+ iconifyAction.setEnabled(frame.isIconifiable());
+ // The maximize action is responsible for restoring it
+ // as well, if clicked from the button
+ maximizeAction.setEnabled(frame.isMaximizable());
+
+ // The restoring action is only active when selected
+ // from the menu.
+ restoreAction.setEnabled(frame.isMaximum());
+
+ sizeAction.setEnabled(frame.isResizable());
+
+ // FIXME: Tie MoveAction enabled status to a variable.
+ moveAction.setEnabled(false);
+ }
+
+ /**
+ * This method creates a new PropertyChangeListener.
+ *
+ * @return A new PropertyChangeListener.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * This method creates a new LayoutManager for the TitlePane.
+ *
+ * @return A new LayoutManager.
+ */
+ protected LayoutManager createLayout()
+ {
+ return new TitlePaneLayout();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1766 @@
+/* BasicInternalFrameUI.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.LayoutManager2;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.DefaultDesktopManager;
+import javax.swing.DesktopManager;
+import javax.swing.JComponent;
+import javax.swing.JDesktopPane;
+import javax.swing.JInternalFrame;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.AbstractBorder;
+import javax.swing.event.InternalFrameEvent;
+import javax.swing.event.InternalFrameListener;
+import javax.swing.event.MouseInputAdapter;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InternalFrameUI;
+import javax.swing.plaf.UIResource;
+
+/**
+ * This is the UI delegate for the Basic look and feel for JInternalFrames.
+ */
+public class BasicInternalFrameUI extends InternalFrameUI
+{
+ /**
+ * This is a helper class that listens to the JInternalFrame for
+ * InternalFrameEvents.
+ */
+ protected class BasicInternalFrameListener implements InternalFrameListener
+ {
+ /**
+ * This method is called when the JInternalFrame is activated.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameActivated(InternalFrameEvent e)
+ {
+ frame.getGlassPane().setVisible(false);
+ }
+
+ /**
+ * This method is called when the JInternalFrame is closed.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameClosed(InternalFrameEvent e)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * This method is called when the JInternalFrame is closing.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameClosing(InternalFrameEvent e)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * This method is called when the JInternalFrame is deactivated.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameDeactivated(InternalFrameEvent e)
+ {
+ frame.getGlassPane().setVisible(true);
+ }
+
+ /**
+ * This method is called when the JInternalFrame is deiconified.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameDeiconified(InternalFrameEvent e)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * This method is called when the JInternalFrame is iconified.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameIconified(InternalFrameEvent e)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * This method is called when the JInternalFrame is opened.
+ *
+ * @param e The InternalFrameEvent.
+ */
+ public void internalFrameOpened(InternalFrameEvent e)
+ {
+ // FIXME: Implement.
+ }
+ }
+
+ /**
+ * This helper class listens to the edges of the JInternalFrame and the
+ * TitlePane for mouse events. It is responsible for dragging and resizing
+ * the JInternalFrame in response to the MouseEvents.
+ */
+ protected class BorderListener extends MouseInputAdapter
+ implements SwingConstants
+ {
+ /**
+ * The current shape of the cursor.
+ */
+ transient int showingCursor;
+
+ /** FIXME: Use for something. */
+ protected final int RESIZE_NONE = 0;
+
+ /** The x offset from the top left corner of the JInternalFrame. */
+ private transient int xOffset;
+
+ /** The y offset from the top left corner of the JInternalFrame. */
+ private transient int yOffset;
+
+ /** The direction that the resize is occuring in. */
+ private transient int direction = -1;
+
+ /** Cache rectangle that can be reused. */
+ private transient Rectangle cacheRect = new Rectangle();
+
+ /**
+ * This method is called when the mouse is clicked.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ // Do minimization/maximization when double-clicking in the title pane.
+ if (e.getSource() == titlePane && e.getClickCount() == 2)
+ try
+ {
+ if (frame.isMaximizable() && ! frame.isMaximum())
+ frame.setMaximum(true);
+ else if (frame.isMaximum())
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
+
+ // There is nothing to do when the mouse is clicked
+ // on the border.
+ }
+
+ /**
+ * This method is called when the mouse is dragged. This method is
+ * responsible for resizing or dragging the JInternalFrame.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ // If the frame is maximized, there is nothing that
+ // can be dragged around.
+ if (frame.isMaximum())
+ return;
+ DesktopManager dm = getDesktopManager();
+ Rectangle b = frame.getBounds();
+ Dimension min = frame.getMinimumSize();
+ if (min == null)
+ min = new Dimension(0, 0);
+ Insets insets = frame.getInsets();
+ int x = e.getX();
+ int y = e.getY();
+ if (e.getSource() == frame && frame.isResizable())
+ {
+ switch (direction)
+ {
+ case Cursor.N_RESIZE_CURSOR:
+ cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
+ - min.height),
+ b.width, b.height - y);
+ break;
+ case Cursor.NE_RESIZE_CURSOR:
+ cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
+ - min.height), x + 1,
+ b.height - y);
+ break;
+ case Cursor.E_RESIZE_CURSOR:
+ cacheRect.setBounds(b.x, b.y, x + 1, b.height);
+ break;
+ case Cursor.SE_RESIZE_CURSOR:
+ cacheRect.setBounds(b.x, b.y, x + 1, y + 1);
+ break;
+ case Cursor.S_RESIZE_CURSOR:
+ cacheRect.setBounds(b.x, b.y, b.width, y + 1);
+ break;
+ case Cursor.SW_RESIZE_CURSOR:
+ cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
+ b.y, b.width - x, y + 1);
+ break;
+ case Cursor.W_RESIZE_CURSOR:
+ cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
+ b.y, b.width - x, b.height);
+ break;
+ case Cursor.NW_RESIZE_CURSOR:
+ cacheRect.setBounds(
+ Math.min(b.x + x, b.x + b.width - min.width),
+ Math.min(b.y + y, b.y + b.height - min.height),
+ b.width - x, b.height - y);
+ break;
+ }
+ dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
+ Math.max(min.width, cacheRect.width),
+ Math.max(min.height, cacheRect.height));
+ setCursor(e);
+ }
+ else if (e.getSource() == titlePane)
+ {
+ Rectangle fBounds = frame.getBounds();
+ frame.putClientProperty("bufferedDragging", Boolean.TRUE);
+ dm.dragFrame(frame, e.getX() - xOffset + b.x, e.getY() - yOffset
+ + b.y);
+ }
+ }
+
+ /**
+ * This method is called when the mouse exits the JInternalFrame.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ if (showingCursor != Cursor.DEFAULT_CURSOR)
+ {
+ frame.setCursor(Cursor.getDefaultCursor());
+ showingCursor = Cursor.DEFAULT_CURSOR;
+ }
+ }
+
+ /**
+ * This method is called when the mouse is moved inside the JInternalFrame.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ // Turn off the resize cursor if we are in the frame header.
+ if (showingCursor != Cursor.DEFAULT_CURSOR && e.getSource() != frame)
+ {
+ frame.setCursor(Cursor.getDefaultCursor());
+ showingCursor = Cursor.DEFAULT_CURSOR;
+ }
+ else if (e.getSource() == frame && frame.isResizable())
+ {
+ setCursor(e);
+ }
+ }
+
+ /**
+ * Set the mouse cursor, how applicable.
+ *
+ * @param e the current mouse event.
+ */
+ void setCursor(MouseEvent e)
+ {
+ int cursor = sectionOfClick(e.getX(), e.getY());
+ if (cursor != showingCursor)
+ {
+ Cursor resize = Cursor.getPredefinedCursor(cursor);
+ frame.setCursor(resize);
+ showingCursor = cursor;
+ }
+ }
+
+ /**
+ * This method is called when the mouse is pressed.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ activateFrame(frame);
+ DesktopManager dm = getDesktopManager();
+ int x = e.getX();
+ int y = e.getY();
+ Insets insets = frame.getInsets();
+
+ if (e.getSource() == frame && frame.isResizable())
+ {
+ direction = sectionOfClick(x, y);
+ dm.beginResizingFrame(frame, direction);
+ }
+ else if (e.getSource() == titlePane)
+ {
+ Rectangle tBounds = titlePane.getBounds();
+
+ xOffset = e.getX() - tBounds.x + insets.left;
+ yOffset = e.getY() - tBounds.y + insets.top;
+
+ dm.beginDraggingFrame(frame);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is released.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ DesktopManager dm = getDesktopManager();
+ xOffset = 0;
+ yOffset = 0;
+ if (e.getSource() == frame && frame.isResizable())
+ dm.endResizingFrame(frame);
+ else if (e.getSource() == titlePane)
+ {
+ dm.endDraggingFrame(frame);
+ frame.putClientProperty("bufferedDragging", null);
+ }
+
+ setCursor(e);
+ }
+
+ /**
+ * This method determines the direction of the resize based on the
+ * coordinates and the size of the JInternalFrame.
+ *
+ * @param x The x coordinate of the MouseEvent.
+ * @param y The y coordinate of the MouseEvent.
+ *
+ * @return The cursor constant, determining the resizing direction.
+ */
+ private int sectionOfClick(int x, int y)
+ {
+ Rectangle b = frame.getBounds();
+ int corner = InternalFrameBorder.cornerSize;
+
+ if (x < corner && y < corner)
+ return Cursor.NW_RESIZE_CURSOR;
+ else if (x > b.width - corner && y < corner)
+ return Cursor.NE_RESIZE_CURSOR;
+ else if (x > b.width - corner && y > b.height - corner)
+ return Cursor.SE_RESIZE_CURSOR;
+ else if (x < corner && y > b.height - corner)
+ return Cursor.SW_RESIZE_CURSOR;
+ else if (y < corner)
+ return Cursor.N_RESIZE_CURSOR;
+ else if (x < corner)
+ return Cursor.W_RESIZE_CURSOR;
+ else if (y > b.height - corner)
+ return Cursor.S_RESIZE_CURSOR;
+ else if (x > b.width - corner)
+ return Cursor.E_RESIZE_CURSOR;
+
+ return Cursor.DEFAULT_CURSOR;
+ }
+ }
+
+ /**
+ * This helper class listens to the JDesktopPane that parents this
+ * JInternalFrame and listens for resize events and resizes the
+ * JInternalFrame appropriately.
+ */
+ protected class ComponentHandler implements ComponentListener
+ {
+ /**
+ * This method is called when the JDesktopPane is hidden.
+ *
+ * @param e
+ * The ComponentEvent fired.
+ */
+ public void componentHidden(ComponentEvent e)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called when the JDesktopPane is moved.
+ *
+ * @param e
+ * The ComponentEvent fired.
+ */
+ public void componentMoved(ComponentEvent e)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called when the JDesktopPane is resized.
+ *
+ * @param e
+ * The ComponentEvent fired.
+ */
+ public void componentResized(ComponentEvent e)
+ {
+ if (frame.isMaximum())
+ {
+ JDesktopPane pane = (JDesktopPane) e.getSource();
+ Insets insets = pane.getInsets();
+ Rectangle bounds = pane.getBounds();
+
+ frame.setBounds(bounds.x + insets.left, bounds.y + insets.top,
+ bounds.width - insets.left - insets.right,
+ bounds.height - insets.top - insets.bottom);
+ frame.revalidate();
+ frame.repaint();
+ }
+
+ // Sun also resizes the icons. but it doesn't seem to do anything.
+ }
+
+ /**
+ * This method is called when the JDesktopPane is shown.
+ *
+ * @param e
+ * The ComponentEvent fired.
+ */
+ public void componentShown(ComponentEvent e)
+ {
+ // Do nothing.
+ }
+ }
+
+ /**
+ * This helper class acts as the LayoutManager for JInternalFrames.
+ */
+ public class InternalFrameLayout implements LayoutManager
+ {
+ /**
+ * This method is called when the given Component is added to the
+ * JInternalFrame.
+ *
+ * @param name
+ * The name of the Component.
+ * @param c
+ * The Component added.
+ */
+ public void addLayoutComponent(String name, Component c)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is used to set the bounds of the children of the
+ * JInternalFrame.
+ *
+ * @param c
+ * The Container to lay out.
+ */
+ public void layoutContainer(Container c)
+ {
+ Dimension dims = frame.getSize();
+ Insets insets = frame.getInsets();
+
+ dims.width -= insets.left + insets.right;
+ dims.height -= insets.top + insets.bottom;
+
+ int nh = 0;
+ int sh = 0;
+ int ew = 0;
+ int ww = 0;
+
+ if (northPane != null)
+ {
+ Dimension nDims = northPane.getPreferredSize();
+ nh = Math.min(nDims.height, dims.height);
+
+ northPane.setBounds(insets.left, insets.top, dims.width, nh);
+ }
+
+ if (southPane != null)
+ {
+ Dimension sDims = southPane.getPreferredSize();
+ sh = Math.min(sDims.height, dims.height - nh);
+
+ southPane.setBounds(insets.left, insets.top + dims.height - sh,
+ dims.width, sh);
+ }
+
+ int remHeight = dims.height - sh - nh;
+
+ if (westPane != null)
+ {
+ Dimension wDims = westPane.getPreferredSize();
+ ww = Math.min(dims.width, wDims.width);
+
+ westPane.setBounds(insets.left, insets.top + nh, ww, remHeight);
+ }
+
+ if (eastPane != null)
+ {
+ Dimension eDims = eastPane.getPreferredSize();
+ ew = Math.min(eDims.width, dims.width - ww);
+
+ eastPane.setBounds(insets.left + dims.width - ew, insets.top + nh,
+ ew, remHeight);
+ }
+
+ int remWidth = dims.width - ww - ew;
+
+ frame.getRootPane().setBounds(insets.left + ww, insets.top + nh,
+ remWidth, remHeight);
+ }
+
+ /**
+ * This method returns the minimum layout size.
+ *
+ * @param c
+ * The Container to find a minimum layout size for.
+ * @return The minimum dimensions for the JInternalFrame.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return getSize(c, true);
+ }
+
+ /**
+ * Th8is method returns the preferred layout size.
+ *
+ * @param c
+ * The Container to find a preferred layout size for.
+ * @return The preferred dimensions for the JInternalFrame.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ return getSize(c, false);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param c
+ * DOCUMENT ME!
+ * @param min
+ * DOCUMENT ME!
+ * @return DOCUMENT ME!
+ */
+ private Dimension getSize(Container c, boolean min)
+ {
+ Insets insets = frame.getInsets();
+
+ Dimension contentDims = frame.getContentPane().getPreferredSize();
+ if (min)
+ contentDims.width = contentDims.height = 0;
+ int nWidth = 0;
+ int nHeight = 0;
+ int sWidth = 0;
+ int sHeight = 0;
+ int eWidth = 0;
+ int eHeight = 0;
+ int wWidth = 0;
+ int wHeight = 0;
+ Dimension dims;
+
+ if (northPane != null)
+ {
+ dims = northPane.getPreferredSize();
+ if (dims != null)
+ {
+ nWidth = dims.width;
+ nHeight = dims.height;
+ }
+ }
+
+ if (southPane != null)
+ {
+ dims = southPane.getPreferredSize();
+ if (dims != null)
+ {
+ sWidth = dims.width;
+ sHeight = dims.height;
+ }
+ }
+
+ if (eastPane != null)
+ {
+ dims = eastPane.getPreferredSize();
+ if (dims != null)
+ {
+ sWidth = dims.width;
+ sHeight = dims.height;
+ }
+ }
+
+ if (westPane != null)
+ {
+ dims = westPane.getPreferredSize();
+ if (dims != null)
+ {
+ wWidth = dims.width;
+ wHeight = dims.height;
+ }
+ }
+
+ int width = Math.max(sWidth, nWidth);
+ width = Math.max(width, contentDims.width + eWidth + wWidth);
+
+ int height = Math.max(eHeight, wHeight);
+ height = Math.max(height, contentDims.height);
+ height += nHeight + sHeight;
+
+ width += insets.left + insets.right;
+ height += insets.top + insets.bottom;
+
+ return new Dimension(width, height);
+ }
+
+ /**
+ * This method is called when a Component is removed from the
+ * JInternalFrame.
+ *
+ * @param c The Component that was removed.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * This helper class is used to listen to the JDesktopPane's glassPane for
+ * MouseEvents. The JInternalFrame can then be selected if a click is
+ * detected on its children.
+ */
+ protected class GlassPaneDispatcher implements MouseInputListener
+ {
+ /** The MouseEvent target. */
+ private transient Component mouseEventTarget;
+
+ private Component dragTarget;
+
+ /**
+ * Indicates if we are currently in a dragging operation or not.
+ */
+ private boolean isDragging;
+
+ /**
+ * This method is called when the mouse enters the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse is clicked on the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse is dragged in the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse exits the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse is moved in the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse is pressed in the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ // Experiments show that this seems to call the
+ // borderListener.mousePressed() method to activate the frame.
+ if (borderListener != null)
+ borderListener.mousePressed(e);
+ handleEvent(e);
+ }
+
+ /**
+ * This method is called when the mouse is released in the glass pane.
+ *
+ * @param e
+ * The MouseEvent.
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ handleEvent(e);
+ }
+
+ /**
+ * This is a helper method that dispatches the GlassPane MouseEvents to the
+ * proper component.
+ *
+ * @param e the mouse event to be dispatched
+ */
+ private void handleEvent(MouseEvent e)
+ {
+ // Find candidate component inside the JInternalFrame.
+ Component target = frame.getLayeredPane().findComponentAt(e.getX(),
+ e.getY());
+
+ // Now search upwards to find a component that actually has
+ // a MouseListener attached.
+ while (target != null
+ && target.getMouseListeners().length == 0
+ && target.getMouseMotionListeners().length == 0
+ && target.getMouseWheelListeners().length == 0)
+ {
+ target = target.getParent();
+ }
+
+ if (target != null)
+ {
+ int id = e.getID();
+ switch (id)
+ {
+ case MouseEvent.MOUSE_ENTERED:
+ // Now redispatch the thing.
+ if (! isDragging || frame.isSelected())
+ {
+ mouseEventTarget = target;
+ redispatch(id, e, mouseEventTarget);
+ }
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ if (! isDragging || frame.isSelected())
+ {
+ redispatch(id, e, mouseEventTarget);
+ }
+ break;
+ case MouseEvent.MOUSE_PRESSED:
+ mouseEventTarget = target;
+ redispatch(id, e, mouseEventTarget);
+ // Start dragging.
+ dragTarget = target;
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ if (isDragging)
+ {
+ redispatch(id, e, dragTarget);
+ isDragging = false;
+ }
+ else
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_MOVED:
+ if (target != mouseEventTarget)
+ {
+ // Create additional MOUSE_EXITED/MOUSE_ENTERED pairs.
+ redispatch(MouseEvent.MOUSE_EXITED, e, mouseEventTarget);
+ mouseEventTarget = target;
+ redispatch(MouseEvent.MOUSE_ENTERED, e, mouseEventTarget);
+ }
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_DRAGGED:
+ if (! isDragging)
+ isDragging = true;
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_WHEEL:
+ redispatch(id, e, mouseEventTarget);
+ break;
+ default:
+ assert false : "Must not reach here";
+ }
+ }
+ }
+
+ /**
+ * Redispatches the event to the real target with the specified id.
+ *
+ * @param id the new event ID
+ * @param e the original event
+ * @param target the real event target
+ */
+ private void redispatch(int id, MouseEvent e, Component target)
+ {
+ Point p = SwingUtilities.convertPoint(frame.getLayeredPane(), e.getX(),
+ e.getY(), target);
+ MouseEvent ev = new MouseEvent(target, id, e.getWhen(),
+ e.getModifiers() | e.getModifiersEx(),
+ p.x, p.y, e.getClickCount(),
+ e.isPopupTrigger());
+ target.dispatchEvent(ev);
+ }
+ }
+
+ /**
+ * This helper class listens for PropertyChangeEvents from the
+ * JInternalFrame.
+ */
+ public class InternalFramePropertyChangeListener
+ implements PropertyChangeListener
+ {
+
+ /**
+ * This method is called when one of the JInternalFrame's properties change.
+ *
+ * @param evt
+ * The PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ String property = evt.getPropertyName();
+ if (property.equals(JInternalFrame.IS_MAXIMUM_PROPERTY))
+ {
+ if (frame.isMaximum())
+ maximizeFrame(frame);
+ else
+ minimizeFrame(frame);
+ }
+ else if (property.equals(JInternalFrame.IS_ICON_PROPERTY))
+ {
+ if (frame.isIcon())
+ iconifyFrame(frame);
+ else
+ deiconifyFrame(frame);
+ }
+ else if (property.equals(JInternalFrame.IS_SELECTED_PROPERTY))
+ {
+ Component glassPane = frame.getGlassPane();
+ if (frame.isSelected())
+ {
+ activateFrame(frame);
+ glassPane.setVisible(false);
+ }
+ else
+ {
+ deactivateFrame(frame);
+ glassPane.setVisible(true);
+ }
+ }
+ else if (property.equals(JInternalFrame.ROOT_PANE_PROPERTY)
+ || property.equals(JInternalFrame.GLASS_PANE_PROPERTY))
+ {
+ Component old = (Component) evt.getOldValue();
+ if (old != null)
+ {
+ old.removeMouseListener(glassPaneDispatcher);
+ old.removeMouseMotionListener(glassPaneDispatcher);
+ }
+
+ Component newPane = (Component) evt.getNewValue();
+ if (newPane != null)
+ {
+ newPane.addMouseListener(glassPaneDispatcher);
+ newPane.addMouseMotionListener(glassPaneDispatcher);
+ }
+
+ frame.revalidate();
+ }
+ else if (property.equals(JInternalFrame.IS_CLOSED_PROPERTY))
+ {
+ if (evt.getNewValue() == Boolean.TRUE)
+ {
+ closeFrame(frame);
+ }
+ }
+ /*
+ * FIXME: need to add ancestor properties to JComponents. else if
+ * (evt.getPropertyName().equals(JComponent.ANCESTOR_PROPERTY)) { if
+ * (desktopPane != null)
+ * desktopPane.removeComponentListener(componentListener); desktopPane =
+ * frame.getDesktopPane(); if (desktopPane != null)
+ * desktopPane.addComponentListener(componentListener); }
+ */
+ }
+ }
+
+ /**
+ * This helper class is the border for the JInternalFrame.
+ */
+ class InternalFrameBorder extends AbstractBorder implements
+ UIResource
+ {
+ /**
+ * The width of the border.
+ */
+ static final int bSize = 5;
+
+ /**
+ * The size of the corners (also used by the mouse listener).
+ */
+ static final int cornerSize = 10;
+
+ /**
+ * This method returns whether the border is opaque.
+ *
+ * @return Whether the border is opaque.
+ */
+ public boolean isBorderOpaque()
+ {
+ return true;
+ }
+
+ /**
+ * This method returns the insets of the border.
+ *
+ * @param c
+ * The Component to find border insets for.
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(bSize, bSize, bSize, bSize);
+ }
+
+ /**
+ * This method paints the border.
+ *
+ * @param c
+ * The Component that owns the border.
+ * @param g
+ * The Graphics object to paint with.
+ * @param x
+ * The x coordinate to paint at.
+ * @param y
+ * The y coordinate to paint at.
+ * @param width
+ * The width of the Component.
+ * @param height
+ * The height of the Component.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int width,
+ int height)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+ Rectangle b = frame.getBounds();
+
+ Color d = c.getBackground();
+ g.setColor(d);
+ g.fillRect(0, 0, bSize, b.height);
+ g.fillRect(0, 0, b.width, bSize);
+ g.fillRect(0, b.height - bSize, b.width, bSize);
+ g.fillRect(b.width - bSize, 0, bSize, b.height);
+
+ int x1 = 0;
+ int x2 = bSize;
+ int x3 = b.width - bSize;
+ int x4 = b.width;
+
+ int y1 = 0;
+ int y2 = bSize;
+ int y3 = b.height - bSize;
+ int y4 = b.height;
+
+ g.setColor(Color.GRAY);
+ g.fillRect(0, 0, bSize, y4);
+ g.fillRect(0, 0, x4, bSize);
+ g.fillRect(0, y3, b.width, bSize);
+ g.fillRect(x3, 0, bSize, b.height);
+
+ g.fill3DRect(0, cornerSize, bSize, b.height - 2 * cornerSize, false);
+ g.fill3DRect(cornerSize, 0, b.width - 2 * cornerSize, bSize, false);
+ g.fill3DRect(cornerSize, b.height - bSize, b.width - 2 * cornerSize,
+ bSize, false);
+ g.fill3DRect(b.width - bSize, cornerSize, bSize,
+ b.height - 2 * cornerSize, false);
+
+ g.translate(-x, -y);
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * This action triggers the system menu.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private class ShowSystemMenuAction
+ extends AbstractAction
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if (titlePane != null)
+ {
+ titlePane.showSystemMenu();
+ }
+ }
+ }
+
+ /**
+ * The MouseListener that is responsible for dragging and resizing the
+ * JInternalFrame in response to MouseEvents.
+ */
+ protected MouseInputAdapter borderListener;
+
+ /**
+ * The ComponentListener that is responsible for resizing the JInternalFrame
+ * in response to ComponentEvents from the JDesktopPane.
+ */
+ protected ComponentListener componentListener;
+
+ /**
+ * The MouseListener that is responsible for activating the JInternalFrame
+ * when the mouse press activates one of its descendents.
+ */
+ protected MouseInputListener glassPaneDispatcher;
+
+ /**
+ * The PropertyChangeListener that is responsible for listening to
+ * PropertyChangeEvents from the JInternalFrame.
+ */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /** The InternalFrameListener that listens to the JInternalFrame. */
+ private transient BasicInternalFrameListener internalFrameListener;
+
+ /** The JComponent placed at the east region of the JInternalFrame. */
+ protected JComponent eastPane;
+
+ /** The JComponent placed at the north region of the JInternalFrame. */
+ protected JComponent northPane;
+
+ /** The JComponent placed at the south region of the JInternalFrame. */
+ protected JComponent southPane;
+
+ /** The JComponent placed at the west region of the JInternalFrame. */
+ protected JComponent westPane;
+
+ /**
+ * The Keystroke bound to open the menu.
+ * @deprecated
+ */
+ protected KeyStroke openMenuKey;
+
+ /** The TitlePane displayed at the top of the JInternalFrame. */
+ protected BasicInternalFrameTitlePane titlePane;
+
+ /** The JInternalFrame this UI is responsible for. */
+ protected JInternalFrame frame;
+
+ /** The LayoutManager used in the JInternalFrame. */
+ protected LayoutManager internalFrameLayout;
+
+ /** The JDesktopPane that is the parent of the JInternalFrame. */
+ private transient JDesktopPane desktopPane;
+
+ /**
+ * Creates a new BasicInternalFrameUI object.
+ *
+ * @param b The JInternalFrame this UI will represent.
+ */
+ public BasicInternalFrameUI(JInternalFrame b)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method will create a new BasicInternalFrameUI for the given
+ * JComponent.
+ *
+ * @param b The JComponent to create a BasicInternalFrameUI for.
+ *
+ * @return A new BasicInternalFrameUI.
+ */
+ public static ComponentUI createUI(JComponent b)
+ {
+ return new BasicInternalFrameUI((JInternalFrame) b);
+ }
+
+ /**
+ * This method installs a UI for the JInternalFrame.
+ *
+ * @param c The JComponent to install this UI on.
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JInternalFrame)
+ {
+ frame = (JInternalFrame) c;
+
+ installDefaults();
+ installListeners();
+ installComponents();
+ installKeyboardActions();
+
+ if (! frame.isSelected())
+ frame.getGlassPane().setVisible(true);
+ }
+ }
+
+ /**
+ * This method reverses the work done by installUI.
+ *
+ * @param c The JComponent to uninstall this UI for.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallKeyboardActions();
+ uninstallComponents();
+ uninstallListeners();
+ uninstallDefaults();
+
+ frame.getRootPane().getGlassPane().setVisible(false);
+ frame = null;
+ }
+
+ /**
+ * This method installs the defaults specified by the look and feel.
+ */
+ protected void installDefaults()
+ {
+ internalFrameLayout = createLayoutManager();
+ frame.setLayout(internalFrameLayout);
+ LookAndFeel.installBorder(frame, "InternalFrame.border");
+ frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
+
+ // Let the content pane inherit the background color from its
+ // frame by setting the background to null.
+ Component contentPane = frame.getContentPane();
+ if (contentPane != null
+ && contentPane.getBackground() instanceof UIResource)
+ {
+ contentPane.setBackground(null);
+ }
+ }
+
+ /**
+ * This method installs the keyboard actions for the JInternalFrame.
+ */
+ protected void installKeyboardActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ am.put("showSystemMenu", new ShowSystemMenuAction());
+
+ // The RI impl installs the audio actions as parent of the UI action map,
+ // so do we.
+ BasicLookAndFeel blaf = (BasicLookAndFeel) UIManager.getLookAndFeel();
+ ActionMap audioActionMap = blaf.getAudioActionMap();
+ am.setParent(audioActionMap);
+
+ SwingUtilities.replaceUIActionMap(frame, am);
+ }
+
+ /**
+ * This method installs the Components for the JInternalFrame.
+ */
+ protected void installComponents()
+ {
+ setNorthPane(createNorthPane(frame));
+ setSouthPane(createSouthPane(frame));
+ setEastPane(createEastPane(frame));
+ setWestPane(createWestPane(frame));
+ }
+
+ /**
+ * This method installs the listeners for the JInternalFrame.
+ */
+ protected void installListeners()
+ {
+ glassPaneDispatcher = createGlassPaneDispatcher();
+ createInternalFrameListener();
+ borderListener = createBorderListener(frame);
+ componentListener = createComponentListener();
+ propertyChangeListener = createPropertyChangeListener();
+
+ frame.addMouseListener(borderListener);
+ frame.addMouseMotionListener(borderListener);
+ frame.addInternalFrameListener(internalFrameListener);
+ frame.addPropertyChangeListener(propertyChangeListener);
+ frame.getRootPane().getGlassPane().addMouseListener(glassPaneDispatcher);
+ frame.getRootPane().getGlassPane().addMouseMotionListener(glassPaneDispatcher);
+ }
+
+ /**
+ * This method uninstalls the defaults for the JInternalFrame.
+ */
+ protected void uninstallDefaults()
+ {
+ frame.setBorder(null);
+ frame.setLayout(null);
+ internalFrameLayout = null;
+ }
+
+ /**
+ * This method uninstalls the Components for the JInternalFrame.
+ */
+ protected void uninstallComponents()
+ {
+ setNorthPane(null);
+ setSouthPane(null);
+ setEastPane(null);
+ setWestPane(null);
+ }
+
+ /**
+ * This method uninstalls the listeners for the JInternalFrame.
+ */
+ protected void uninstallListeners()
+ {
+ if (desktopPane != null)
+ desktopPane.removeComponentListener(componentListener);
+
+ frame.getRootPane().getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
+ frame.getRootPane().getGlassPane().removeMouseListener(glassPaneDispatcher);
+
+ frame.removePropertyChangeListener(propertyChangeListener);
+ frame.removeInternalFrameListener(internalFrameListener);
+ frame.removeMouseMotionListener(borderListener);
+ frame.removeMouseListener(borderListener);
+
+ propertyChangeListener = null;
+ componentListener = null;
+ borderListener = null;
+ internalFrameListener = null;
+ glassPaneDispatcher = null;
+ }
+
+ /**
+ * This method uninstalls the keyboard actions for the JInternalFrame.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ SwingUtilities.replaceUIActionMap(frame, null);
+ SwingUtilities.replaceUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW,
+ null);
+ }
+
+ /**
+ * This method creates a new LayoutManager for the JInternalFrame.
+ *
+ * @return A new LayoutManager for the JInternalFrame.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return new InternalFrameLayout();
+ }
+
+ /**
+ * This method creates a new PropertyChangeListener for the JInternalFrame.
+ *
+ * @return A new PropertyChangeListener for the JInternalFrame.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new InternalFramePropertyChangeListener();
+ }
+
+ /**
+ * This method returns the preferred size of the given JComponent.
+ *
+ * @param x The JComponent to find a preferred size for.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent x)
+ {
+ Dimension pref = null;
+ LayoutManager layout = frame.getLayout();
+ if (frame == x && layout != null)
+ pref = layout.preferredLayoutSize(frame);
+ else
+ pref = new Dimension(100, 100);
+ return pref;
+ }
+
+ /**
+ * This method returns the minimum size of the given JComponent.
+ *
+ * @param x The JComponent to find a minimum size for.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumSize(JComponent x)
+ {
+ Dimension min = null;
+ LayoutManager layout = frame.getLayout();
+ if (frame == x && layout != null)
+ min = layout.minimumLayoutSize(frame);
+ else
+ min = new Dimension(0, 0);
+ return min;
+ }
+
+ /**
+ * This method returns the maximum size of the given JComponent.
+ *
+ * @param x The JComponent to find a maximum size for.
+ *
+ * @return The maximum size.
+ */
+ public Dimension getMaximumSize(JComponent x)
+ {
+ Dimension max = null;
+ LayoutManager layout = frame.getLayout();
+ if (frame == x && layout != null && layout instanceof LayoutManager2)
+ max = ((LayoutManager2) layout).maximumLayoutSize(frame);
+ else
+ max = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ return max;
+ }
+
+ /**
+ * This method replaces the currentPane with the newPane. When replacing it
+ * also removes the MouseHandlers for the old pane and installs them on
+ * the new pane.
+ *
+ * @param currentPane The old pane to remove.
+ * @param newPane The new pane to install.
+ */
+ protected void replacePane(JComponent currentPane, JComponent newPane)
+ {
+ if (currentPane != null)
+ {
+ deinstallMouseHandlers(currentPane);
+ frame.remove(currentPane);
+ }
+
+ if (newPane != null)
+ {
+ installMouseHandlers(newPane);
+ frame.add(newPane);
+ }
+ }
+
+ /**
+ * This method removes the necessary MouseListeners from the given
+ * JComponent.
+ *
+ * @param c The JComponent to remove MouseListeners from.
+ */
+ protected void deinstallMouseHandlers(JComponent c)
+ {
+ c.removeMouseListener(borderListener);
+ c.removeMouseMotionListener(borderListener);
+ }
+
+ /**
+ * This method installs the necessary MouseListeners from the given
+ * JComponent.
+ *
+ * @param c The JComponent to install MouseListeners on.
+ */
+ protected void installMouseHandlers(JComponent c)
+ {
+ c.addMouseListener(borderListener);
+ c.addMouseMotionListener(borderListener);
+ }
+
+ /**
+ * This method creates the north pane used in the JInternalFrame.
+ *
+ * @param w The JInternalFrame to create a north pane for.
+ *
+ * @return The north pane.
+ */
+ protected JComponent createNorthPane(JInternalFrame w)
+ {
+ titlePane = new BasicInternalFrameTitlePane(w);
+ return titlePane;
+ }
+
+ /**
+ * This method creates the west pane used in the JInternalFrame.
+ *
+ * @param w The JInternalFrame to create a west pane for.
+ *
+ * @return The west pane.
+ */
+ protected JComponent createWestPane(JInternalFrame w)
+ {
+ return null;
+ }
+
+ /**
+ * This method creates the south pane used in the JInternalFrame.
+ *
+ * @param w The JInternalFrame to create a south pane for.
+ *
+ * @return The south pane.
+ */
+ protected JComponent createSouthPane(JInternalFrame w)
+ {
+ return null;
+ }
+
+ /**
+ * This method creates the east pane used in the JInternalFrame.
+ *
+ * @param w The JInternalFrame to create an east pane for.
+ *
+ * @return The east pane.
+ */
+ protected JComponent createEastPane(JInternalFrame w)
+ {
+ return null;
+ }
+
+ /**
+ * This method returns a new BorderListener for the given JInternalFrame.
+ *
+ * @param w The JIntenalFrame to create a BorderListener for.
+ *
+ * @return A new BorderListener.
+ */
+ protected MouseInputAdapter createBorderListener(JInternalFrame w)
+ {
+ return new BorderListener();
+ }
+
+ /**
+ * This method creates a new InternalFrameListener for the JInternalFrame.
+ */
+ protected void createInternalFrameListener()
+ {
+ internalFrameListener = new BasicInternalFrameListener();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected final boolean isKeyBindingRegistered()
+ {
+ // FIXME: Implement.
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ protected final void setKeyBindingRegistered(boolean b)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public final boolean isKeyBindingActive()
+ {
+ // FIXME: Implement.
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ protected final void setKeyBindingActive(boolean b)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected void setupMenuOpenKey()
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected void setupMenuCloseKey()
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * This method returns the north pane.
+ *
+ * @return The north pane.
+ */
+ public JComponent getNorthPane()
+ {
+ return northPane;
+ }
+
+ /**
+ * This method sets the north pane to be the given JComponent.
+ *
+ * @param c The new north pane.
+ */
+ public void setNorthPane(JComponent c)
+ {
+ replacePane(northPane, c);
+ northPane = c;
+ }
+
+ /**
+ * This method returns the south pane.
+ *
+ * @return The south pane.
+ */
+ public JComponent getSouthPane()
+ {
+ return southPane;
+ }
+
+ /**
+ * This method sets the south pane to be the given JComponent.
+ *
+ * @param c The new south pane.
+ */
+ public void setSouthPane(JComponent c)
+ {
+ replacePane(southPane, c);
+ southPane = c;
+ }
+
+ /**
+ * This method sets the east pane to be the given JComponent.
+ *
+ * @param c The new east pane.
+ */
+ public void setEastPane(JComponent c)
+ {
+ replacePane(eastPane, c);
+ eastPane = c;
+ }
+
+ /**
+ * This method returns the east pane.
+ *
+ * @return The east pane.
+ */
+ public JComponent getEastPane()
+ {
+ return eastPane;
+ }
+
+ /**
+ * This method sets the west pane to be the given JComponent.
+ *
+ * @param c The new west pane.
+ */
+ public void setWestPane(JComponent c)
+ {
+ replacePane(westPane, c);
+ westPane = c;
+ }
+
+ /**
+ * This method returns the west pane.
+ *
+ * @return The west pane.
+ */
+ public JComponent getWestPane()
+ {
+ return westPane;
+ }
+
+ /**
+ * This method returns the DesktopManager to use with the JInternalFrame.
+ *
+ * @return The DesktopManager to use with the JInternalFrame.
+ */
+ protected DesktopManager getDesktopManager()
+ {
+ DesktopManager value = null;
+ JDesktopPane pane = frame.getDesktopPane();
+ if (pane != null)
+ value = frame.getDesktopPane().getDesktopManager();
+ if (value == null)
+ value = createDesktopManager();
+ return value;
+ }
+
+ /**
+ * This method returns a default DesktopManager that can be used with this
+ * JInternalFrame.
+ *
+ * @return A default DesktopManager that can be used with this
+ * JInternalFrame.
+ */
+ protected DesktopManager createDesktopManager()
+ {
+ return new DefaultDesktopManager();
+ }
+
+ /**
+ * This is a convenience method that closes the JInternalFrame.
+ *
+ * @param f The JInternalFrame to close.
+ */
+ protected void closeFrame(JInternalFrame f)
+ {
+ getDesktopManager().closeFrame(f);
+ }
+
+ /**
+ * This is a convenience method that maximizes the JInternalFrame.
+ *
+ * @param f The JInternalFrame to maximize.
+ */
+ protected void maximizeFrame(JInternalFrame f)
+ {
+ getDesktopManager().maximizeFrame(f);
+ }
+
+ /**
+ * This is a convenience method that minimizes the JInternalFrame.
+ *
+ * @param f The JInternalFrame to minimize.
+ */
+ protected void minimizeFrame(JInternalFrame f)
+ {
+ getDesktopManager().minimizeFrame(f);
+ }
+
+ /**
+ * This is a convenience method that iconifies the JInternalFrame.
+ *
+ * @param f The JInternalFrame to iconify.
+ */
+ protected void iconifyFrame(JInternalFrame f)
+ {
+ getDesktopManager().iconifyFrame(f);
+ }
+
+ /**
+ * This is a convenience method that deiconifies the JInternalFrame.
+ *
+ * @param f The JInternalFrame to deiconify.
+ */
+ protected void deiconifyFrame(JInternalFrame f)
+ {
+ getDesktopManager().deiconifyFrame(f);
+ }
+
+ /**
+ * This is a convenience method that activates the JInternalFrame.
+ *
+ * @param f The JInternalFrame to activate.
+ */
+ protected void activateFrame(JInternalFrame f)
+ {
+ getDesktopManager().activateFrame(f);
+ }
+
+ /**
+ * This is a convenience method that deactivates the JInternalFrame.
+ *
+ * @param f the JInternalFrame to deactivate
+ */
+ protected void deactivateFrame(JInternalFrame f)
+ {
+ getDesktopManager().deactivateFrame(f);
+ }
+
+ /**
+ * This method returns a new ComponentListener for the JDesktopPane.
+ *
+ * @return A new ComponentListener.
+ */
+ protected ComponentListener createComponentListener()
+ {
+ return new ComponentHandler();
+ }
+
+ /**
+ * This method returns a new GlassPaneDispatcher.
+ *
+ * @return A new GlassPaneDispatcher.
+ */
+ protected MouseInputListener createGlassPaneDispatcher()
+ {
+ return new GlassPaneDispatcher();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,486 @@
+/* BasicLabelUI.java
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.Icon;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.LabelUI;
+import javax.swing.text.View;
+
+/**
+ * This is the Basic Look and Feel class for the JLabel. One BasicLabelUI
+ * object is used to paint all JLabels that utilize the Basic Look and Feel.
+ */
+public class BasicLabelUI extends LabelUI implements PropertyChangeListener
+{
+ /** The labelUI that is shared by all labels. */
+ protected static BasicLabelUI labelUI;
+
+ /**
+ * These fields hold the rectangles for the whole label,
+ * the icon and the text.
+ */
+ private Rectangle vr;
+ private Rectangle ir;
+ private Rectangle tr;
+
+ /**
+ * Creates a new BasicLabelUI object.
+ */
+ public BasicLabelUI()
+ {
+ super();
+ vr = new Rectangle();
+ ir = new Rectangle();
+ tr = new Rectangle();
+ }
+
+ /**
+ * Creates and returns a UI for the label. Since one UI is shared by all
+ * labels, this means creating only if necessary and returning the shared
+ * UI.
+ *
+ * @param c The {@link JComponent} that a UI is being created for.
+ *
+ * @return A label UI for the Basic Look and Feel.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ if (labelUI == null)
+ labelUI = new BasicLabelUI();
+ return labelUI;
+ }
+
+ /**
+ * Returns the preferred size of this component as calculated by the
+ * {@link #layoutCL(JLabel, FontMetrics, String, Icon, Rectangle, Rectangle,
+ * Rectangle)} method.
+ *
+ * @param c This {@link JComponent} to get a preferred size for.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JLabel lab = (JLabel) c;
+ Insets insets = lab.getInsets();
+ FontMetrics fm = lab.getFontMetrics(lab.getFont());
+ layoutCL(lab, fm, lab.getText(), lab.getIcon(), vr, ir, tr);
+ Rectangle cr = SwingUtilities.computeUnion(tr.x, tr.y, tr.width, tr.height,
+ ir);
+ return new Dimension(insets.left + cr.width + insets.right, insets.top
+ + cr.height + insets.bottom);
+
+ }
+
+ /**
+ * This method returns the minimum size of the {@link JComponent} given. If
+ * this method returns null, then it is up to the Layout Manager to give
+ * this component a minimum size.
+ *
+ * @param c The {@link JComponent} to get a minimum size for.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the maximum size of the {@link JComponent} given. If
+ * this method returns null, then it is up to the Layout Manager to give
+ * this component a maximum size.
+ *
+ * @param c The {@link JComponent} to get a maximum size for.
+ *
+ * @return The maximum size.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * The method that paints the label according to its current state.
+ *
+ * @param g The {@link Graphics} object to paint with.
+ * @param c The {@link JComponent} to paint.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ JLabel b = (JLabel) c;
+ FontMetrics fm = g.getFontMetrics();
+ vr = SwingUtilities.calculateInnerArea(c, vr);
+
+ if (vr.width < 0)
+ vr.width = 0;
+ if (vr.height < 0)
+ vr.height = 0;
+
+ Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
+
+ String text = layoutCL(b, fm, b.getText(), icon, vr, ir, tr);
+
+ if (icon != null)
+ icon.paintIcon(b, g, ir.x, ir.y);
+
+ Object htmlRenderer = b.getClientProperty(BasicHTML.propertyKey);
+ if (htmlRenderer == null)
+ {
+ if (text != null && !text.equals(""))
+ {
+ if (b.isEnabled())
+ paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+ else
+ paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+ }
+ }
+ else
+ {
+ ((View) htmlRenderer).paint(g, tr);
+ }
+ }
+
+ /**
+ * This method is simply calls SwingUtilities's layoutCompoundLabel.
+ *
+ * @param label The label to lay out.
+ * @param fontMetrics The FontMetrics for the font used.
+ * @param text The text to paint.
+ * @param icon The icon to draw.
+ * @param viewR The entire viewable rectangle.
+ * @param iconR The icon bounds rectangle.
+ * @param textR The text bounds rectangle.
+ *
+ * @return A possibly clipped version of the text.
+ */
+ protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text,
+ Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
+ {
+ return SwingUtilities.layoutCompoundLabel(label, fontMetrics, text, icon,
+ label.getVerticalAlignment(), label.getHorizontalAlignment(), label
+ .getVerticalTextPosition(), label.getHorizontalTextPosition(),
+ viewR, iconR, textR, label.getIconTextGap());
+ }
+
+ /**
+ * Paints the text if the label is disabled. By default, this paints the
+ * clipped text returned by layoutCompoundLabel using the
+ * background.brighter() color. It also paints the same text using the
+ * background.darker() color one pixel to the right and one pixel down.
+ *
+ * @param l The {@link JLabel} being painted.
+ * @param g The {@link Graphics} object to paint with.
+ * @param s The String to paint.
+ * @param textX The x coordinate of the start of the baseline.
+ * @param textY The y coordinate of the start of the baseline.
+ */
+ protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
+ int textY)
+ {
+ Color saved_color = g.getColor();
+
+ g.setColor(l.getBackground().brighter());
+
+ int mnemIndex = l.getDisplayedMnemonicIndex();
+
+ if (mnemIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
+ textY);
+ else
+ g.drawString(s, textX, textY);
+
+ g.setColor(l.getBackground().darker());
+ if (mnemIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX + 1,
+ textY + 1);
+ else
+ g.drawString(s, textX + 1, textY + 1);
+
+ g.setColor(saved_color);
+ }
+
+ /**
+ * Paints the text if the label is enabled. The text is painted using the
+ * foreground color.
+ *
+ * @param l The {@link JLabel} being painted.
+ * @param g The {@link Graphics} object to paint with.
+ * @param s The String to paint.
+ * @param textX The x coordinate of the start of the baseline.
+ * @param textY The y coordinate of the start of the baseline.
+ */
+ protected void paintEnabledText(JLabel l, Graphics g, String s, int textX,
+ int textY)
+ {
+ Color saved_color = g.getColor();
+ g.setColor(l.getForeground());
+
+ int mnemIndex = l.getDisplayedMnemonicIndex();
+
+ if (mnemIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
+ textY);
+ else
+ g.drawString(s, textX, textY);
+
+ g.setColor(saved_color);
+ }
+
+ /**
+ * This method installs the UI for the given {@link JComponent}. This
+ * method will install the component, defaults, listeners, and keyboard
+ * actions.
+ *
+ * @param c The {@link JComponent} that this UI is being installed on.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof JLabel)
+ {
+ JLabel l = (JLabel) c;
+
+ installComponents(l);
+ installDefaults(l);
+ installListeners(l);
+ installKeyboardActions(l);
+ }
+ }
+
+ /**
+ * This method uninstalls the UI for the given {@link JComponent}. This
+ * method will uninstall the component, defaults, listeners, and keyboard
+ * actions.
+ *
+ * @param c The {@link JComponent} that this UI is being installed on.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ super.uninstallUI(c);
+ if (c instanceof JLabel)
+ {
+ JLabel l = (JLabel) c;
+
+ uninstallKeyboardActions(l);
+ uninstallListeners(l);
+ uninstallDefaults(l);
+ uninstallComponents(l);
+ }
+ }
+
+ /**
+ * This method installs the components for this {@link JLabel}.
+ *
+ * @param c The {@link JLabel} to install components for.
+ */
+ protected void installComponents(JLabel c)
+ {
+ BasicHTML.updateRenderer(c, c.getText());
+ }
+
+ /**
+ * This method uninstalls the components for this {@link JLabel}.
+ *
+ * @param c The {@link JLabel} to uninstall components for.
+ */
+ protected void uninstallComponents(JLabel c)
+ {
+ c.putClientProperty(BasicHTML.propertyKey, null);
+ c.putClientProperty(BasicHTML.documentBaseKey, null);
+ }
+
+ /**
+ * This method installs the defaults that are defined in the Basic look and
+ * feel for this {@link JLabel}.
+ *
+ * @param c The {@link JLabel} to install defaults for.
+ */
+ protected void installDefaults(JLabel c)
+ {
+ LookAndFeel.installColorsAndFont(c, "Label.background", "Label.foreground",
+ "Label.font");
+ //XXX: There are properties we don't use called disabledForeground
+ //and disabledShadow.
+ }
+
+ /**
+ * This method uninstalls the defaults that are defined in the Basic look
+ * and feel for this {@link JLabel}.
+ *
+ * @param c The {@link JLabel} to uninstall defaults for.
+ */
+ protected void uninstallDefaults(JLabel c)
+ {
+ c.setForeground(null);
+ c.setBackground(null);
+ c.setFont(null);
+ }
+
+ /**
+ * Installs the keyboard actions for the given {@link JLabel}.
+ *
+ * @param l The {@link JLabel} to install keyboard actions for.
+ */
+ protected void installKeyboardActions(JLabel l)
+ {
+ Component c = l.getLabelFor();
+ if (c != null)
+ {
+ int mnemonic = l.getDisplayedMnemonic();
+ if (mnemonic > 0)
+ {
+ // add a keystroke for the given mnemonic mapping to 'press';
+ InputMap keyMap = new InputMap();
+ keyMap.put(KeyStroke.getKeyStroke(mnemonic, KeyEvent.VK_ALT),
+ "press");
+ SwingUtilities.replaceUIInputMap(l,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
+
+ // add an action to focus the component when 'press' happens
+ ActionMap map = new ActionMap();
+ map.put("press", new AbstractAction() {
+ public void actionPerformed(ActionEvent event)
+ {
+ JLabel label = (JLabel) event.getSource();
+ Component c = label.getLabelFor();
+ if (c != null)
+ c.requestFocus();
+ }
+ });
+ SwingUtilities.replaceUIActionMap(l, map);
+ }
+ }
+ }
+
+ /**
+ * This method uninstalls the keyboard actions for the given {@link JLabel}.
+ *
+ * @param l The {@link JLabel} to uninstall keyboard actions for.
+ */
+ protected void uninstallKeyboardActions(JLabel l)
+ {
+ SwingUtilities.replaceUIActionMap(l, null);
+ SwingUtilities.replaceUIInputMap(l, JComponent.WHEN_IN_FOCUSED_WINDOW,
+ null);
+ }
+
+ /**
+ * This method installs the listeners for the given {@link JLabel}. The UI
+ * delegate only listens to the label.
+ *
+ * @param c The {@link JLabel} to install listeners for.
+ */
+ protected void installListeners(JLabel c)
+ {
+ c.addPropertyChangeListener(this);
+ }
+
+ /**
+ * This method uninstalls the listeners for the given {@link JLabel}. The UI
+ * delegate only listens to the label.
+ *
+ * @param c The {@link JLabel} to uninstall listeners for.
+ */
+ protected void uninstallListeners(JLabel c)
+ {
+ c.removePropertyChangeListener(this);
+ }
+
+ /**
+ * This method is called whenever any JLabel's that use this UI has one of
+ * their properties change.
+ *
+ * @param e The {@link PropertyChangeEvent} that describes the change.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("text"))
+ {
+ String text = (String) e.getNewValue();
+ JLabel l = (JLabel) e.getSource();
+ BasicHTML.updateRenderer(l, text);
+ }
+ else if (e.getPropertyName().equals("displayedMnemonic"))
+ {
+ // update the key to action mapping
+ JLabel label = (JLabel) e.getSource();
+ if (label.getLabelFor() != null)
+ {
+ int oldMnemonic = ((Integer) e.getOldValue()).intValue();
+ int newMnemonic = ((Integer) e.getNewValue()).intValue();
+ InputMap keyMap = label.getInputMap(
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ keyMap.put(KeyStroke.getKeyStroke(oldMnemonic,
+ KeyEvent.ALT_DOWN_MASK), null);
+ keyMap.put(KeyStroke.getKeyStroke(newMnemonic,
+ KeyEvent.ALT_DOWN_MASK), "press");
+ }
+ }
+ else if (e.getPropertyName().equals("labelFor"))
+ {
+ JLabel label = (JLabel) e.getSource();
+ InputMap keyMap = label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
+ int mnemonic = label.getDisplayedMnemonic();
+ if (mnemonic > 0)
+ keyMap.put(KeyStroke.getKeyStroke(mnemonic, KeyEvent.ALT_DOWN_MASK),
+ "press");
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1421 @@
+/* BasicListUI.java --
+ Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.CellRendererPane;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.ListModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.TransferHandler;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ListUI;
+import javax.swing.plaf.UIResource;
+
+/**
+ * The Basic Look and Feel UI delegate for the
+ * JList.
+ */
+public class BasicListUI extends ListUI
+{
+
+ /**
+ * A helper class which listens for {@link FocusEvent}s
+ * from the JList.
+ */
+ public class FocusHandler implements FocusListener
+ {
+ /**
+ * Called when the JList acquires focus.
+ *
+ * @param e The FocusEvent representing focus acquisition
+ */
+ public void focusGained(FocusEvent e)
+ {
+ repaintCellFocus();
+ }
+
+ /**
+ * Called when the JList loses focus.
+ *
+ * @param e The FocusEvent representing focus loss
+ */
+ public void focusLost(FocusEvent e)
+ {
+ repaintCellFocus();
+ }
+
+ /**
+ * Helper method to repaint the focused cell's
+ * lost or acquired focus state.
+ */
+ protected void repaintCellFocus()
+ {
+ // TODO: Implement this properly.
+ }
+ }
+
+ /**
+ * A helper class which listens for {@link ListDataEvent}s generated by
+ * the {@link JList}'s {@link ListModel}.
+ *
+ * @see javax.swing.JList#getModel()
+ */
+ public class ListDataHandler implements ListDataListener
+ {
+ /**
+ * Called when a general change has happened in the model which cannot
+ * be represented in terms of a simple addition or deletion.
+ *
+ * @param e The event representing the change
+ */
+ public void contentsChanged(ListDataEvent e)
+ {
+ updateLayoutStateNeeded |= modelChanged;
+ list.revalidate();
+ }
+
+ /**
+ * Called when an interval of objects has been added to the model.
+ *
+ * @param e The event representing the addition
+ */
+ public void intervalAdded(ListDataEvent e)
+ {
+ updateLayoutStateNeeded |= modelChanged;
+ list.revalidate();
+ }
+
+ /**
+ * Called when an inteval of objects has been removed from the model.
+ *
+ * @param e The event representing the removal
+ */
+ public void intervalRemoved(ListDataEvent e)
+ {
+ updateLayoutStateNeeded |= modelChanged;
+ list.revalidate();
+ }
+ }
+
+ /**
+ * A helper class which listens for {@link ListSelectionEvent}s
+ * from the {@link JList}'s {@link ListSelectionModel}.
+ */
+ public class ListSelectionHandler implements ListSelectionListener
+ {
+ /**
+ * Called when the list selection changes.
+ *
+ * @param e The event representing the change
+ */
+ public void valueChanged(ListSelectionEvent e)
+ {
+ int index1 = e.getFirstIndex();
+ int index2 = e.getLastIndex();
+ Rectangle damaged = getCellBounds(list, index1, index2);
+ if (damaged != null)
+ list.repaint(damaged);
+ }
+ }
+
+ /**
+ * This class is used to mimmic the behaviour of the JDK when registering
+ * keyboard actions. It is the same as the private class used in JComponent
+ * for the same reason. This class receives an action event and dispatches
+ * it to the true receiver after altering the actionCommand property of the
+ * event.
+ */
+ private static class ActionListenerProxy
+ extends AbstractAction
+ {
+ ActionListener target;
+ String bindingCommandName;
+
+ public ActionListenerProxy(ActionListener li,
+ String cmd)
+ {
+ target = li;
+ bindingCommandName = cmd;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ ActionEvent derivedEvent = new ActionEvent(e.getSource(),
+ e.getID(),
+ bindingCommandName,
+ e.getModifiers());
+ target.actionPerformed(derivedEvent);
+ }
+ }
+
+ /**
+ * Implements the action for the JList's keyboard commands.
+ */
+ private class ListAction
+ extends AbstractAction
+ {
+ // TODO: Maybe make a couple of classes out of this bulk Action.
+ // Form logical groups of Actions when doing this.
+
+ /**
+ * Creates a new ListAction for the specified command.
+ *
+ * @param cmd the actionCommand to set
+ */
+ ListAction(String cmd)
+ {
+ putValue(ACTION_COMMAND_KEY, cmd);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ int lead = list.getLeadSelectionIndex();
+ int max = list.getModel().getSize() - 1;
+ DefaultListSelectionModel selModel
+ = (DefaultListSelectionModel) list.getSelectionModel();
+ String command = e.getActionCommand();
+ // Do nothing if list is empty
+ if (max == -1)
+ return;
+
+ if (command.equals("selectNextRow"))
+ {
+ selectNextIndex();
+ }
+ else if (command.equals("selectPreviousRow"))
+ {
+ selectPreviousIndex();
+ }
+ else if (command.equals("clearSelection"))
+ {
+ list.clearSelection();
+ }
+ else if (command.equals("selectAll"))
+ {
+ list.setSelectionInterval(0, max);
+ // this next line is to restore the lead selection index to the old
+ // position, because select-all should not change the lead index
+ list.addSelectionInterval(lead, lead);
+ }
+ else if (command.equals("selectLastRow"))
+ {
+ list.setSelectedIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("selectLastRowChangeLead"))
+ {
+ selModel.moveLeadSelectionIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("scrollDownExtendSelection"))
+ {
+ int target;
+ if (lead == list.getLastVisibleIndex())
+ {
+ target = Math.min(max, lead + (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getLastVisibleIndex();
+ selModel.setLeadSelectionIndex(target);
+ }
+ else if (command.equals("scrollDownChangeLead"))
+ {
+ int target;
+ if (lead == list.getLastVisibleIndex())
+ {
+ target = Math.min(max, lead + (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getLastVisibleIndex();
+ selModel.moveLeadSelectionIndex(target);
+ }
+ else if (command.equals("scrollUpExtendSelection"))
+ {
+ int target;
+ if (lead == list.getFirstVisibleIndex())
+ {
+ target = Math.max(0, lead - (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getFirstVisibleIndex();
+ selModel.setLeadSelectionIndex(target);
+ }
+ else if (command.equals("scrollUpChangeLead"))
+ {
+ int target;
+ if (lead == list.getFirstVisibleIndex())
+ {
+ target = Math.max(0, lead - (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getFirstVisibleIndex();
+ selModel.moveLeadSelectionIndex(target);
+ }
+ else if (command.equals("selectNextRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(Math.min(lead + 1, max));
+ }
+ else if (command.equals("selectFirstRow"))
+ {
+ list.setSelectedIndex(0);
+ }
+ else if (command.equals("selectFirstRowChangeLead"))
+ {
+ selModel.moveLeadSelectionIndex(0);
+ }
+ else if (command.equals("selectFirstRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(0);
+ }
+ else if (command.equals("selectPreviousRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(Math.max(0, lead - 1));
+ }
+ else if (command.equals("scrollUp"))
+ {
+ int target;
+ if (lead == list.getFirstVisibleIndex())
+ {
+ target = Math.max(0, lead - (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getFirstVisibleIndex();
+ list.setSelectedIndex(target);
+ }
+ else if (command.equals("selectLastRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("scrollDown"))
+ {
+ int target;
+ if (lead == list.getLastVisibleIndex())
+ {
+ target = Math.min(max, lead + (list.getLastVisibleIndex()
+ - list.getFirstVisibleIndex() + 1));
+ }
+ else
+ target = list.getLastVisibleIndex();
+ list.setSelectedIndex(target);
+ }
+ else if (command.equals("selectNextRowChangeLead"))
+ {
+ if (selModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ selectNextIndex();
+ else
+ {
+ selModel.moveLeadSelectionIndex(Math.min(max, lead + 1));
+ }
+ }
+ else if (command.equals("selectPreviousRowChangeLead"))
+ {
+ if (selModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ selectPreviousIndex();
+ else
+ {
+ selModel.moveLeadSelectionIndex(Math.max(0, lead - 1));
+ }
+ }
+ else if (command.equals("addToSelection"))
+ {
+ list.addSelectionInterval(lead, lead);
+ }
+ else if (command.equals("extendTo"))
+ {
+ selModel.setSelectionInterval(selModel.getAnchorSelectionIndex(),
+ lead);
+ }
+ else if (command.equals("toggleAndAnchor"))
+ {
+ if (!list.isSelectedIndex(lead))
+ list.addSelectionInterval(lead, lead);
+ else
+ list.removeSelectionInterval(lead, lead);
+ selModel.setAnchorSelectionIndex(lead);
+ }
+ else
+ {
+ // DEBUG: uncomment the following line to print out
+ // key bindings that aren't implemented yet
+
+ // System.out.println ("not implemented: "+e.getActionCommand());
+ }
+
+ list.ensureIndexIsVisible(list.getLeadSelectionIndex());
+ }
+ }
+
+ /**
+ * A helper class which listens for {@link MouseEvent}s
+ * from the {@link JList}.
+ */
+ public class MouseInputHandler implements MouseInputListener
+ {
+ /**
+ * Called when a mouse button press/release cycle completes
+ * on the {@link JList}
+ *
+ * @param event The event representing the mouse click
+ */
+ public void mouseClicked(MouseEvent event)
+ {
+ Point click = event.getPoint();
+ int index = locationToIndex(list, click);
+ if (index == -1)
+ return;
+ if (event.isShiftDown())
+ {
+ if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
+ list.setSelectedIndex(index);
+ else if (list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION)
+ // COMPAT: the IBM VM is compatible with the following line of code.
+ // However, compliance with Sun's VM would correspond to replacing
+ // getAnchorSelectionIndex() with getLeadSelectionIndex().This is
+ // both unnatural and contradictory to the way they handle other
+ // similar UI interactions.
+ list.setSelectionInterval(list.getAnchorSelectionIndex(), index);
+ else
+ // COMPAT: both Sun and IBM are compatible instead with:
+ // list.setSelectionInterval
+ // (list.getLeadSelectionIndex(),index);
+ // Note that for IBM this is contradictory to what they did in
+ // the above situation for SINGLE_INTERVAL_SELECTION.
+ // The most natural thing to do is the following:
+ if (list.isSelectedIndex(list.getAnchorSelectionIndex()))
+ list.getSelectionModel().setLeadSelectionIndex(index);
+ else
+ list.addSelectionInterval(list.getAnchorSelectionIndex(), index);
+ }
+ else if (event.isControlDown())
+ {
+ if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
+ list.setSelectedIndex(index);
+ else if (list.isSelectedIndex(index))
+ list.removeSelectionInterval(index, index);
+ else
+ list.addSelectionInterval(index, index);
+ }
+ else
+ list.setSelectedIndex(index);
+
+ list.ensureIndexIsVisible(list.getLeadSelectionIndex());
+ }
+
+ /**
+ * Called when a mouse button is pressed down on the
+ * {@link JList}.
+ *
+ * @param event The event representing the mouse press
+ */
+ public void mousePressed(MouseEvent event)
+ {
+ // We need to explicitly request focus.
+ list.requestFocusInWindow();
+ }
+
+ /**
+ * Called when a mouse button is released on
+ * the {@link JList}
+ *
+ * @param event The event representing the mouse press
+ */
+ public void mouseReleased(MouseEvent event)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Called when the mouse pointer enters the area bounded
+ * by the {@link JList}
+ *
+ * @param event The event representing the mouse entry
+ */
+ public void mouseEntered(MouseEvent event)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Called when the mouse pointer leaves the area bounded
+ * by the {@link JList}
+ *
+ * @param event The event representing the mouse exit
+ */
+ public void mouseExited(MouseEvent event)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Called when the mouse pointer moves over the area bounded
+ * by the {@link JList} while a button is held down.
+ *
+ * @param event The event representing the mouse drag
+ */
+ public void mouseDragged(MouseEvent event)
+ {
+ Point click = event.getPoint();
+ int index = locationToIndex(list, click);
+ if (index == -1)
+ return;
+ if (!event.isShiftDown() && !event.isControlDown())
+ list.setSelectedIndex(index);
+
+ list.ensureIndexIsVisible(list.getLeadSelectionIndex());
+ }
+
+ /**
+ * Called when the mouse pointer moves over the area bounded
+ * by the {@link JList}.
+ *
+ * @param event The event representing the mouse move
+ */
+ public void mouseMoved(MouseEvent event)
+ {
+ // TODO: What should be done here, if anything?
+ }
+ }
+
+ /**
+ * Helper class which listens to {@link PropertyChangeEvent}s
+ * from the {@link JList}.
+ */
+ public class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * Called when the {@link JList} changes one of its bound properties.
+ *
+ * @param e The event representing the property change
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("model"))
+ {
+ if (e.getOldValue() != null && e.getOldValue() instanceof ListModel)
+ {
+ ListModel oldModel = (ListModel) e.getOldValue();
+ oldModel.removeListDataListener(listDataListener);
+ }
+ if (e.getNewValue() != null && e.getNewValue() instanceof ListModel)
+ {
+ ListModel newModel = (ListModel) e.getNewValue();
+ newModel.addListDataListener(BasicListUI.this.listDataListener);
+ }
+
+ updateLayoutStateNeeded |= modelChanged;
+ }
+ else if (e.getPropertyName().equals("selectionModel"))
+ updateLayoutStateNeeded |= selectionModelChanged;
+ else if (e.getPropertyName().equals("font"))
+ updateLayoutStateNeeded |= fontChanged;
+ else if (e.getPropertyName().equals("fixedCellWidth"))
+ updateLayoutStateNeeded |= fixedCellWidthChanged;
+ else if (e.getPropertyName().equals("fixedCellHeight"))
+ updateLayoutStateNeeded |= fixedCellHeightChanged;
+ else if (e.getPropertyName().equals("prototypeCellValue"))
+ updateLayoutStateNeeded |= prototypeCellValueChanged;
+ else if (e.getPropertyName().equals("cellRenderer"))
+ updateLayoutStateNeeded |= cellRendererChanged;
+ }
+ }
+
+ /**
+ * A constant to indicate that the model has changed.
+ */
+ protected static final int modelChanged = 1;
+
+ /**
+ * A constant to indicate that the selection model has changed.
+ */
+ protected static final int selectionModelChanged = 2;
+
+ /**
+ * A constant to indicate that the font has changed.
+ */
+ protected static final int fontChanged = 4;
+
+ /**
+ * A constant to indicate that the fixedCellWidth has changed.
+ */
+ protected static final int fixedCellWidthChanged = 8;
+
+ /**
+ * A constant to indicate that the fixedCellHeight has changed.
+ */
+ protected static final int fixedCellHeightChanged = 16;
+
+ /**
+ * A constant to indicate that the prototypeCellValue has changed.
+ */
+ protected static final int prototypeCellValueChanged = 32;
+
+ /**
+ * A constant to indicate that the cellRenderer has changed.
+ */
+ protected static final int cellRendererChanged = 64;
+
+ /**
+ * Creates a new BasicListUI for the component.
+ *
+ * @param c The component to create a UI for
+ *
+ * @return A new UI
+ */
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicListUI();
+ }
+
+ /** The current focus listener. */
+ protected FocusListener focusListener;
+
+ /** The data listener listening to the model. */
+ protected ListDataListener listDataListener;
+
+ /** The selection listener listening to the selection model. */
+ protected ListSelectionListener listSelectionListener;
+
+ /** The mouse listener listening to the list. */
+ protected MouseInputListener mouseInputListener;
+
+ /** The property change listener listening to the list. */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /** Saved reference to the list this UI was created for. */
+ protected JList list;
+
+ /**
+ * The height of a single cell in the list. This field is used when the
+ * fixedCellHeight property of the list is set. Otherwise this field is
+ * set to <code>-1</code> and {@link #cellHeights} is used instead.
+ */
+ protected int cellHeight;
+
+ /** The width of a single cell in the list. */
+ protected int cellWidth;
+
+ /**
+ * An array of varying heights of cells in the list, in cases where each
+ * cell might have a different height. This field is used when the
+ * <code>fixedCellHeight</code> property of the list is not set. Otherwise
+ * this field is <code>null</code> and {@link #cellHeight} is used.
+ */
+ protected int[] cellHeights;
+
+ /**
+ * A bitmask that indicates which properties of the JList have changed.
+ * When nonzero, indicates that the UI class is out of
+ * date with respect to the underlying list, and must recalculate the
+ * list layout before painting or performing size calculations.
+ *
+ * @see #modelChanged
+ * @see #selectionModelChanged
+ * @see #fontChanged
+ * @see #fixedCellWidthChanged
+ * @see #fixedCellHeightChanged
+ * @see #prototypeCellValueChanged
+ * @see #cellRendererChanged
+ */
+ protected int updateLayoutStateNeeded;
+
+ /**
+ * The {@link CellRendererPane} that is used for painting.
+ */
+ protected CellRendererPane rendererPane;
+
+ /** The action bound to KeyStrokes. */
+ ListAction action;
+
+ /**
+ * Calculate the height of a particular row. If there is a fixed {@link
+ * #cellHeight}, return it; otherwise return the specific row height
+ * requested from the {@link #cellHeights} array. If the requested row
+ * is invalid, return <code>-1</code>.
+ *
+ * @param row The row to get the height of
+ *
+ * @return The height, in pixels, of the specified row
+ */
+ protected int getRowHeight(int row)
+ {
+ int height;
+ if (cellHeights == null)
+ height = cellHeight;
+ else
+ {
+ if (row < 0 || row >= cellHeights.length)
+ height = -1;
+ else
+ height = cellHeights[row];
+ }
+ return height;
+ }
+
+ /**
+ * Calculate the bounds of a particular cell, considering the upper left
+ * corner of the list as the origin position <code>(0,0)</code>.
+ *
+ * @param l Ignored; calculates over <code>this.list</code>
+ * @param index1 The first row to include in the bounds
+ * @param index2 The last row to incude in the bounds
+ *
+ * @return A rectangle encompassing the range of rows between
+ * <code>index1</code> and <code>index2</code> inclusive, or null
+ * such a rectangle couldn't be calculated for the given indexes.
+ */
+ public Rectangle getCellBounds(JList l, int index1, int index2)
+ {
+ maybeUpdateLayoutState();
+
+ if (l != list || cellWidth == -1)
+ return null;
+
+ int minIndex = Math.min(index1, index2);
+ int maxIndex = Math.max(index1, index2);
+ Point loc = indexToLocation(list, minIndex);
+
+ // When the layoutOrientation is VERTICAL, then the width == the list
+ // width. Otherwise the cellWidth field is used.
+ int width = cellWidth;
+ if (l.getLayoutOrientation() == JList.VERTICAL)
+ width = l.getWidth();
+
+ Rectangle bounds = new Rectangle(loc.x, loc.y, width,
+ getCellHeight(minIndex));
+ for (int i = minIndex + 1; i <= maxIndex; i++)
+ {
+ Point hiLoc = indexToLocation(list, i);
+ bounds = SwingUtilities.computeUnion(hiLoc.x, hiLoc.y, width,
+ getCellHeight(i), bounds);
+ }
+
+ return bounds;
+ }
+
+ /**
+ * Calculates the maximum cell height.
+ *
+ * @param index the index of the cell
+ *
+ * @return the maximum cell height
+ */
+ private int getCellHeight(int index)
+ {
+ int height = cellHeight;
+ if (height <= 0)
+ {
+ if (list.getLayoutOrientation() == JList.VERTICAL)
+ height = getRowHeight(index);
+ else
+ {
+ for (int j = 0; j < cellHeights.length; j++)
+ height = Math.max(height, cellHeights[j]);
+ }
+ }
+ return height;
+ }
+
+ /**
+ * Calculate the Y coordinate of the upper edge of a particular row,
+ * considering the Y coordinate <code>0</code> to occur at the top of the
+ * list.
+ *
+ * @param row The row to calculate the Y coordinate of
+ *
+ * @return The Y coordinate of the specified row, or <code>-1</code> if
+ * the specified row number is invalid
+ */
+ protected int convertRowToY(int row)
+ {
+ int y = 0;
+ for (int i = 0; i < row; ++i)
+ {
+ int h = getRowHeight(i);
+ if (h == -1)
+ return -1;
+ y += h;
+ }
+ return y;
+ }
+
+ /**
+ * Calculate the row number containing a particular Y coordinate,
+ * considering the Y coodrinate <code>0</code> to occur at the top of the
+ * list.
+ *
+ * @param y0 The Y coordinate to calculate the row number for
+ *
+ * @return The row number containing the specified Y value, or <code>-1</code>
+ * if the list model is empty
+ *
+ * @specnote This method is specified to return -1 for an invalid Y
+ * coordinate. However, some simple tests show that the behaviour
+ * is to return the index of the last list element for an Y
+ * coordinate that lies outside of the list bounds (even for
+ * negative indices). <code>-1</code>
+ * is only returned if the list model is empty.
+ */
+ protected int convertYToRow(int y0)
+ {
+ if (list.getModel().getSize() == 0)
+ return -1;
+
+ // When y0 < 0, then the JDK returns the maximum row index of the list. So
+ // do we.
+ if (y0 < 0)
+ return list.getModel().getSize() - 1;
+
+ // Update the layout if necessary.
+ maybeUpdateLayoutState();
+
+ int index = list.getModel().getSize() - 1;
+
+ // If a fixed cell height is set, then we can work more efficient.
+ if (cellHeight > 0)
+ index = Math.min(y0 / cellHeight, index);
+ // If we have no fixed cell height, we must add up each cell height up
+ // to y0.
+ else
+ {
+ int h = 0;
+ for (int row = 0; row < cellHeights.length; ++row)
+ {
+ h += cellHeights[row];
+ if (y0 < h)
+ {
+ index = row;
+ break;
+ }
+ }
+ }
+ return index;
+ }
+
+ /**
+ * Recomputes the {@link #cellHeights}, {@link #cellHeight}, and {@link
+ * #cellWidth} properties by examining the variouis properties of the
+ * {@link JList}.
+ */
+ protected void updateLayoutState()
+ {
+ int nrows = list.getModel().getSize();
+ cellHeight = -1;
+ cellWidth = -1;
+ if (cellHeights == null || cellHeights.length != nrows)
+ cellHeights = new int[nrows];
+ ListCellRenderer rend = list.getCellRenderer();
+ // Update the cellHeight(s) fields.
+ int fixedCellHeight = list.getFixedCellHeight();
+ if (fixedCellHeight > 0)
+ {
+ cellHeight = fixedCellHeight;
+ cellHeights = null;
+ }
+ else
+ {
+ cellHeight = -1;
+ for (int i = 0; i < nrows; ++i)
+ {
+ Component flyweight =
+ rend.getListCellRendererComponent(list,
+ list.getModel().getElementAt(i),
+ i, list.isSelectedIndex(i),
+ list.getSelectionModel().getAnchorSelectionIndex() == i);
+ Dimension dim = flyweight.getPreferredSize();
+ cellHeights[i] = dim.height;
+ }
+ }
+
+ // Update the cellWidth field.
+ int fixedCellWidth = list.getFixedCellWidth();
+ if (fixedCellWidth > 0)
+ cellWidth = fixedCellWidth;
+ else
+ {
+ for (int i = 0; i < nrows; ++i)
+ {
+ Component flyweight =
+ rend.getListCellRendererComponent(list,
+ list.getModel().getElementAt(i),
+ i, list.isSelectedIndex(i),
+ list.getSelectionModel().getAnchorSelectionIndex() == i);
+ Dimension dim = flyweight.getPreferredSize();
+ cellWidth = Math.max(cellWidth, dim.width);
+ }
+ }
+ }
+
+ /**
+ * Calls {@link #updateLayoutState} if {@link #updateLayoutStateNeeded}
+ * is nonzero, then resets {@link #updateLayoutStateNeeded} to zero.
+ */
+ protected void maybeUpdateLayoutState()
+ {
+ if (updateLayoutStateNeeded != 0)
+ {
+ updateLayoutState();
+ updateLayoutStateNeeded = 0;
+ }
+ }
+
+ /**
+ * Creates a new BasicListUI object.
+ */
+ public BasicListUI()
+ {
+ updateLayoutStateNeeded = 1;
+ rendererPane = new CellRendererPane();
+ }
+
+ /**
+ * Installs various default settings (mostly colors) from the {@link
+ * UIDefaults} into the {@link JList}
+ *
+ * @see #uninstallDefaults
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installColorsAndFont(list, "List.background",
+ "List.foreground", "List.font");
+ list.setSelectionForeground(UIManager.getColor("List.selectionForeground"));
+ list.setSelectionBackground(UIManager.getColor("List.selectionBackground"));
+ list.setOpaque(true);
+ }
+
+ /**
+ * Resets to <code>null</code> those defaults which were installed in
+ * {@link #installDefaults}
+ */
+ protected void uninstallDefaults()
+ {
+ list.setForeground(null);
+ list.setBackground(null);
+ list.setSelectionForeground(null);
+ list.setSelectionBackground(null);
+ }
+
+ /**
+ * Attaches all the listeners we have in the UI class to the {@link
+ * JList}, its model and its selection model.
+ *
+ * @see #uninstallListeners
+ */
+ protected void installListeners()
+ {
+ if (focusListener == null)
+ focusListener = createFocusListener();
+ list.addFocusListener(focusListener);
+ if (listDataListener == null)
+ listDataListener = createListDataListener();
+ list.getModel().addListDataListener(listDataListener);
+ if (listSelectionListener == null)
+ listSelectionListener = createListSelectionListener();
+ list.addListSelectionListener(listSelectionListener);
+ if (mouseInputListener == null)
+ mouseInputListener = createMouseInputListener();
+ list.addMouseListener(mouseInputListener);
+ list.addMouseMotionListener(mouseInputListener);
+ if (propertyChangeListener == null)
+ propertyChangeListener = createPropertyChangeListener();
+ list.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Detaches all the listeners we attached in {@link #installListeners}.
+ */
+ protected void uninstallListeners()
+ {
+ list.removeFocusListener(focusListener);
+ list.getModel().removeListDataListener(listDataListener);
+ list.removeListSelectionListener(listSelectionListener);
+ list.removeMouseListener(mouseInputListener);
+ list.removeMouseMotionListener(mouseInputListener);
+ list.removePropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Installs keyboard actions for this UI in the {@link JList}.
+ */
+ protected void installKeyboardActions()
+ {
+ // Install UI InputMap.
+ InputMap focusInputMap = (InputMap) UIManager.get("List.focusInputMap");
+ SwingUtilities.replaceUIInputMap(list, JComponent.WHEN_FOCUSED,
+ focusInputMap);
+
+ // Install UI ActionMap.
+ ActionMap am = (ActionMap) UIManager.get("List.actionMap");
+ if (am == null)
+ {
+ // Create the actionMap once and store it in the current UIDefaults
+ // for use in other components.
+ am = new ActionMapUIResource();
+ ListAction action;
+ action = new ListAction("selectPreviousRow");
+ am.put("selectPreviousRow", action);
+ action = new ListAction("selectNextRow");
+ am.put("selectNextRow", action);
+ action = new ListAction("selectPreviousRowExtendSelection");
+ am.put("selectPreviousRowExtendSelection", action);
+ action = new ListAction("selectNextRowExtendSelection");
+ am.put("selectNextRowExtendSelection", action);
+
+ action = new ListAction("selectPreviousColumn");
+ am.put("selectPreviousColumn", action);
+ action = new ListAction("selectNextColumn");
+ am.put("selectNextColumn", action);
+ action = new ListAction("selectPreviousColumnExtendSelection");
+ am.put("selectPreviousColumnExtendSelection", action);
+ action = new ListAction("selectNextColumnExtendSelection");
+ am.put("selectNextColumnExtendSelection", action);
+
+ action = new ListAction("selectFirstRow");
+ am.put("selectFirstRow", action);
+ action = new ListAction("selectLastRow");
+ am.put("selectLastRow", action);
+ action = new ListAction("selectFirstRowExtendSelection");
+ am.put("selectFirstRowExtendSelection", action);
+ action = new ListAction("selectLastRowExtendSelection");
+ am.put("selectLastRowExtendSelection", action);
+
+ action = new ListAction("scrollUp");
+ am.put("scrollUp", action);
+ action = new ListAction("scrollUpExtendSelection");
+ am.put("scrollUpExtendSelection", action);
+ action = new ListAction("scrollDown");
+ am.put("scrollDown", action);
+ action = new ListAction("scrollDownExtendSelection");
+ am.put("scrollDownExtendSelection", action);
+
+ action = new ListAction("selectAll");
+ am.put("selectAll", action);
+ action = new ListAction("clearSelection");
+ am.put("clearSelection", action);
+
+ am.put("copy", TransferHandler.getCopyAction());
+ am.put("cut", TransferHandler.getCutAction());
+ am.put("paste", TransferHandler.getPasteAction());
+
+ UIManager.put("List.actionMap", am);
+ }
+
+ SwingUtilities.replaceUIActionMap(list, am);
+ }
+
+ /**
+ * Uninstalls keyboard actions for this UI in the {@link JList}.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ // Uninstall the InputMap.
+ InputMap im = SwingUtilities.getUIInputMap(list, JComponent.WHEN_FOCUSED);
+ if (im instanceof UIResource)
+ SwingUtilities.replaceUIInputMap(list, JComponent.WHEN_FOCUSED, null);
+
+ // Uninstall the ActionMap.
+ if (SwingUtilities.getUIActionMap(list) instanceof UIResource)
+ SwingUtilities.replaceUIActionMap(list, null);
+ }
+
+ /**
+ * Installs the various aspects of the UI in the {@link JList}. In
+ * particular, calls {@link #installDefaults}, {@link #installListeners}
+ * and {@link #installKeyboardActions}. Also saves a reference to the
+ * provided component, cast to a {@link JList}.
+ *
+ * @param c The {@link JList} to install the UI into
+ */
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+ list = (JList) c;
+ installDefaults();
+ installListeners();
+ installKeyboardActions();
+ maybeUpdateLayoutState();
+ }
+
+ /**
+ * Uninstalls all the aspects of the UI which were installed in {@link
+ * #installUI}. When finished uninstalling, drops the saved reference to
+ * the {@link JList}.
+ *
+ * @param c Ignored; the UI is uninstalled from the {@link JList}
+ * reference saved during the call to {@link #installUI}
+ */
+ public void uninstallUI(final JComponent c)
+ {
+ uninstallKeyboardActions();
+ uninstallListeners();
+ uninstallDefaults();
+ list = null;
+ }
+
+ /**
+ * Gets the size this list would prefer to assume. This is calculated by
+ * calling {@link #getCellBounds} over the entire list.
+ *
+ * @param c Ignored; uses the saved {@link JList} reference
+ *
+ * @return DOCUMENT ME!
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ maybeUpdateLayoutState();
+ int size = list.getModel().getSize();
+ int visibleRows = list.getVisibleRowCount();
+ int layoutOrientation = list.getLayoutOrientation();
+
+ int h;
+ int w;
+ int maxCellHeight = cellHeight;
+ if (maxCellHeight <= 0)
+ {
+ for (int i = 0; i < cellHeights.length; i++)
+ maxCellHeight = Math.max(maxCellHeight, cellHeights[i]);
+ }
+ if (layoutOrientation == JList.HORIZONTAL_WRAP)
+ {
+ if (visibleRows > 0)
+ {
+ // We cast to double here to force double divisions.
+ double modelSize = size;
+ int neededColumns = (int) Math.ceil(modelSize / visibleRows);
+ int adjustedRows = (int) Math.ceil(modelSize / neededColumns);
+ h = maxCellHeight * adjustedRows;
+ w = cellWidth * neededColumns;
+ }
+ else
+ {
+ int neededColumns = Math.min(1, list.getWidth() / cellWidth);
+ h = size / neededColumns * maxCellHeight;
+ w = neededColumns * cellWidth;
+ }
+ }
+ else if (layoutOrientation == JList.VERTICAL_WRAP)
+ {
+ if (visibleRows > 0)
+ h = visibleRows * maxCellHeight;
+ else
+ h = Math.max(list.getHeight(), maxCellHeight);
+ int neededColumns = h / maxCellHeight;
+ w = cellWidth * neededColumns;
+ }
+ else
+ {
+ if (list.getFixedCellWidth() > 0)
+ w = list.getFixedCellWidth();
+ else
+ w = cellWidth;
+ if (list.getFixedCellHeight() > 0)
+ // FIXME: We need to add some cellVerticalMargins here, according
+ // to the specs.
+ h = list.getFixedCellHeight() * size;
+ else
+ h = maxCellHeight * size;
+ }
+ Insets insets = list.getInsets();
+ Dimension retVal = new Dimension(w + insets.left + insets.right,
+ h + insets.top + insets.bottom);
+ return retVal;
+ }
+
+ /**
+ * Paints a single cell in the list.
+ *
+ * @param g The graphics context to paint in
+ * @param row The row number to paint
+ * @param bounds The bounds of the cell to paint, assuming a coordinate
+ * system beginning at <code>(0,0)</code> in the upper left corner of the
+ * list
+ * @param rend A cell renderer to paint with
+ * @param data The data to provide to the cell renderer
+ * @param sel A selection model to provide to the cell renderer
+ * @param lead The lead selection index of the list
+ */
+ protected void paintCell(Graphics g, int row, Rectangle bounds,
+ ListCellRenderer rend, ListModel data,
+ ListSelectionModel sel, int lead)
+ {
+ boolean isSel = list.isSelectedIndex(row);
+ boolean hasFocus = (list.getLeadSelectionIndex() == row) && BasicListUI.this.list.hasFocus();
+ Component comp = rend.getListCellRendererComponent(list,
+ data.getElementAt(row),
+ row, isSel, hasFocus);
+ rendererPane.paintComponent(g, comp, list, bounds);
+ }
+
+ /**
+ * Paints the list by repeatedly calling {@link #paintCell} for each visible
+ * cell in the list.
+ *
+ * @param g The graphics context to paint with
+ * @param c Ignored; uses the saved {@link JList} reference
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ int nrows = list.getModel().getSize();
+ if (nrows == 0)
+ return;
+
+ maybeUpdateLayoutState();
+ ListCellRenderer render = list.getCellRenderer();
+ ListModel model = list.getModel();
+ ListSelectionModel sel = list.getSelectionModel();
+ int lead = sel.getLeadSelectionIndex();
+ Rectangle clip = g.getClipBounds();
+
+ int startIndex = locationToIndex(list, new Point(clip.x, clip.y));
+ int endIndex = locationToIndex(list, new Point(clip.x + clip.width,
+ clip.y + clip.height));
+
+ for (int row = startIndex; row <= endIndex; ++row)
+ {
+ Rectangle bounds = getCellBounds(list, row, row);
+ if (bounds != null && bounds.intersects(clip))
+ paintCell(g, row, bounds, render, model, sel, lead);
+ }
+ }
+
+ /**
+ * Computes the index of a list cell given a point within the list. If the
+ * location lies outside the bounds of the list, the greatest index in the
+ * list model is returned.
+ *
+ * @param l the list which on which the computation is based on
+ * @param location the coordinates
+ *
+ * @return the index of the list item that is located at the given
+ * coordinates or <code>-1</code> if the list model is empty
+ */
+ public int locationToIndex(JList l, Point location)
+ {
+ int layoutOrientation = list.getLayoutOrientation();
+ int index = -1;
+ switch (layoutOrientation)
+ {
+ case JList.VERTICAL:
+ index = convertYToRow(location.y);
+ break;
+ case JList.HORIZONTAL_WRAP:
+ // determine visible rows and cells per row
+ int maxCellHeight = getCellHeight(0);
+ int visibleRows = list.getHeight() / maxCellHeight;
+ int cellsPerRow = -1;
+ int numberOfItems = list.getModel().getSize();
+ cellsPerRow = numberOfItems / visibleRows + 1;
+
+ // determine index for the given location
+ int cellsPerColumn = numberOfItems / cellsPerRow + 1;
+ int gridX = Math.min(location.x / cellWidth, cellsPerRow - 1);
+ int gridY = Math.min(location.y / maxCellHeight, cellsPerColumn);
+ index = gridX + gridY * cellsPerRow;
+ break;
+ case JList.VERTICAL_WRAP:
+ // determine visible rows and cells per column
+ int maxCellHeight2 = getCellHeight(0);
+ int visibleRows2 = list.getHeight() / maxCellHeight2;
+ int numberOfItems2 = list.getModel().getSize();
+ int cellsPerRow2 = numberOfItems2 / visibleRows2 + 1;
+
+ int gridX2 = Math.min(location.x / cellWidth, cellsPerRow2 - 1);
+ int gridY2 = Math.min(location.y / maxCellHeight2, visibleRows2);
+ index = gridY2 + gridX2 * visibleRows2;
+ break;
+ }
+ return index;
+ }
+
+ public Point indexToLocation(JList l, int index)
+ {
+ int layoutOrientation = list.getLayoutOrientation();
+ Point loc = null;
+ switch (layoutOrientation)
+ {
+ case JList.VERTICAL:
+ loc = new Point(0, convertRowToY(index));
+ break;
+ case JList.HORIZONTAL_WRAP:
+ // determine visible rows and cells per row
+ int maxCellHeight = getCellHeight(0);
+ int visibleRows = list.getHeight() / maxCellHeight;
+ int numberOfCellsPerRow = -1;
+ int numberOfItems = list.getModel().getSize();
+ numberOfCellsPerRow = numberOfItems / visibleRows + 1;
+
+ // compute coordinates inside the grid
+ int gridX = index % numberOfCellsPerRow;
+ int gridY = index / numberOfCellsPerRow;
+ int locX = gridX * cellWidth;
+ int locY;
+ locY = gridY * maxCellHeight;
+ loc = new Point(locX, locY);
+ break;
+ case JList.VERTICAL_WRAP:
+ // determine visible rows and cells per column
+ int maxCellHeight2 = getCellHeight(0);
+ int visibleRows2 = list.getHeight() / maxCellHeight2;
+ // compute coordinates inside the grid
+ if (visibleRows2 > 0)
+ {
+ int gridY2 = index % visibleRows2;
+ int gridX2 = index / visibleRows2;
+ int locX2 = gridX2 * cellWidth;
+ int locY2 = gridY2 * maxCellHeight2;
+ loc = new Point(locX2, locY2);
+ }
+ else
+ loc = new Point(0, convertRowToY(index));
+ break;
+ }
+ return loc;
+ }
+
+ /**
+ * Creates and returns the focus listener for this UI.
+ *
+ * @return the focus listener for this UI
+ */
+ protected FocusListener createFocusListener()
+ {
+ return new FocusHandler();
+ }
+
+ /**
+ * Creates and returns the list data listener for this UI.
+ *
+ * @return the list data listener for this UI
+ */
+ protected ListDataListener createListDataListener()
+ {
+ return new ListDataHandler();
+ }
+
+ /**
+ * Creates and returns the list selection listener for this UI.
+ *
+ * @return the list selection listener for this UI
+ */
+ protected ListSelectionListener createListSelectionListener()
+ {
+ return new ListSelectionHandler();
+ }
+
+ /**
+ * Creates and returns the mouse input listener for this UI.
+ *
+ * @return the mouse input listener for this UI
+ */
+ protected MouseInputListener createMouseInputListener()
+ {
+ return new MouseInputHandler();
+ }
+
+ /**
+ * Creates and returns the property change listener for this UI.
+ *
+ * @return the property change listener for this UI
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Selects the next list item and force it to be visible.
+ */
+ protected void selectNextIndex()
+ {
+ int index = list.getSelectionModel().getLeadSelectionIndex();
+ if (index < list.getModel().getSize() - 1)
+ {
+ index++;
+ list.setSelectedIndex(index);
+ }
+ list.ensureIndexIsVisible(index);
+ }
+
+ /**
+ * Selects the previous list item and force it to be visible.
+ */
+ protected void selectPreviousIndex()
+ {
+ int index = list.getSelectionModel().getLeadSelectionIndex();
+ if (index > 0)
+ {
+ index--;
+ list.setSelectedIndex(index);
+ }
+ list.ensureIndexIsVisible(index);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1732 @@
+/* BasicLookAndFeel.java --
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.AWTEvent;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.SystemColor;
+import java.awt.Toolkit;
+import java.awt.event.AWTEventListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuSelectionManager;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.plaf.BorderUIResource;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.DimensionUIResource;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.plaf.IconUIResource;
+import javax.swing.plaf.InsetsUIResource;
+
+/**
+ * A basic implementation of Swing's Look and Feel framework. This can serve
+ * as a base for custom look and feel implementations.
+ *
+ * @author Andrew Selkirk
+ */
+public abstract class BasicLookAndFeel extends LookAndFeel
+ implements Serializable
+{
+
+ /**
+ * Helps closing menu popups when the user clicks outside of any menu area.
+ * This is implemented as an AWTEventListener that listens on the event
+ * queue directly, grabs all mouse events from there and finds out of they
+ * are targetted at a menu/submenu/menubar or not. If not,
+ * the MenuSelectionManager is messaged to close the currently opened menus,
+ * if any.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private class PopupHelper implements AWTEventListener
+ {
+
+ /**
+ * Receives an event from the event queue.
+ *
+ * @param event
+ */
+ public void eventDispatched(AWTEvent event)
+ {
+ if (event instanceof MouseEvent)
+ {
+ MouseEvent mouseEvent = (MouseEvent) event;
+ if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED)
+ mousePressed(mouseEvent);
+ }
+ }
+
+ /**
+ * Handles mouse pressed events from the event queue.
+ *
+ * @param ev the mouse pressed event
+ */
+ private void mousePressed(MouseEvent ev)
+ {
+ // Autoclose all menus managed by the MenuSelectionManager.
+ MenuSelectionManager m = MenuSelectionManager.defaultManager();
+ Component target = ev.getComponent();
+ if (target instanceof Container)
+ target = ((Container) target).findComponentAt(ev.getPoint());
+ if (m.getSelectedPath().length > 0
+ && ! m.isComponentPartOfCurrentMenu(target)
+ && (((JComponent)target).getClientProperty(DONT_CANCEL_POPUP) == null
+ || !((JComponent)target).getClientProperty(DONT_CANCEL_POPUP).equals(Boolean.TRUE)))
+ {
+ m.clearSelectedPath();
+ }
+ }
+
+ }
+
+ /**
+ * An action that can play an audio file.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private class AudioAction extends AbstractAction
+ {
+ /**
+ * The UIDefaults key that specifies the sound.
+ */
+ Object key;
+
+ /**
+ * Creates a new AudioAction.
+ *
+ * @param key the key that describes the audio action, normally a filename
+ * of an audio file relative to the current package
+ */
+ AudioAction(Object key)
+ {
+ this.key = key;
+ }
+
+ /**
+ * Plays the sound represented by this action.
+ *
+ * @param event the action event that triggers this audio action
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ // We only can handle strings for now.
+ if (key instanceof String)
+ {
+ String name = UIManager.getString(key);
+ InputStream stream = getClass().getResourceAsStream(name);
+ try
+ {
+ Clip clip = AudioSystem.getClip();
+ AudioInputStream audioStream =
+ AudioSystem.getAudioInputStream(stream);
+ clip.open(audioStream);
+ }
+ catch (LineUnavailableException ex)
+ {
+ // Nothing we can do about it.
+ }
+ catch (IOException ex)
+ {
+ // Nothing we can do about it.
+ }
+ catch (UnsupportedAudioFileException e)
+ {
+ // Nothing we can do about it.
+ }
+ }
+ }
+ }
+
+ static final long serialVersionUID = -6096995660290287879L;
+
+ /**
+ * This is a key for a client property that tells the PopupHelper that
+ * it shouldn't close popups when the mouse event target has this
+ * property set. This is used when the component handles popup closing
+ * itself.
+ */
+ static final String DONT_CANCEL_POPUP = "noCancelPopup";
+
+ /**
+ * Helps closing menu popups when user clicks outside of the menu area.
+ */
+ private transient PopupHelper popupHelper;
+
+ /**
+ * Maps the audio actions for this l&f.
+ */
+ private ActionMap audioActionMap;
+
+ /**
+ * Creates a new instance of the Basic look and feel.
+ */
+ public BasicLookAndFeel()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Creates and returns a new instance of the default resources for this look
+ * and feel.
+ *
+ * @return The UI defaults.
+ */
+ public UIDefaults getDefaults()
+ {
+ // Variables
+ UIDefaults def = new UIDefaults();
+ // Initialize Class Defaults
+ initClassDefaults(def);
+ // Initialize System Colour Defaults
+ initSystemColorDefaults(def);
+ // Initialize Component Defaults
+ initComponentDefaults(def);
+ // Return UI Defaults
+ return def;
+ }
+
+ /**
+ * Populates the <code>defaults</code> table with mappings between class IDs
+ * and fully qualified class names for the UI delegates.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
+ */
+ protected void initClassDefaults(UIDefaults defaults)
+ {
+ // Variables
+ Object[] uiDefaults;
+ // Initialize Class Defaults
+ uiDefaults = new Object[] {
+ "ButtonUI", "javax.swing.plaf.basic.BasicButtonUI",
+ "CheckBoxMenuItemUI", "javax.swing.plaf.basic.BasicCheckBoxMenuItemUI",
+ "CheckBoxUI", "javax.swing.plaf.basic.BasicCheckBoxUI",
+ "ColorChooserUI", "javax.swing.plaf.basic.BasicColorChooserUI",
+ "ComboBoxUI", "javax.swing.plaf.basic.BasicComboBoxUI",
+ "DesktopIconUI", "javax.swing.plaf.basic.BasicDesktopIconUI",
+ "DesktopPaneUI", "javax.swing.plaf.basic.BasicDesktopPaneUI",
+ "EditorPaneUI", "javax.swing.plaf.basic.BasicEditorPaneUI",
+ "FileChooserUI", "javax.swing.plaf.basic.BasicFileChooserUI",
+ "FormattedTextFieldUI", "javax.swing.plaf.basic.BasicFormattedTextFieldUI",
+ "InternalFrameUI", "javax.swing.plaf.basic.BasicInternalFrameUI",
+ "LabelUI", "javax.swing.plaf.basic.BasicLabelUI",
+ "ListUI", "javax.swing.plaf.basic.BasicListUI",
+ "MenuBarUI", "javax.swing.plaf.basic.BasicMenuBarUI",
+ "MenuItemUI", "javax.swing.plaf.basic.BasicMenuItemUI",
+ "MenuUI", "javax.swing.plaf.basic.BasicMenuUI",
+ "OptionPaneUI", "javax.swing.plaf.basic.BasicOptionPaneUI",
+ "PanelUI", "javax.swing.plaf.basic.BasicPanelUI",
+ "PasswordFieldUI", "javax.swing.plaf.basic.BasicPasswordFieldUI",
+ "PopupMenuSeparatorUI", "javax.swing.plaf.basic.BasicPopupMenuSeparatorUI",
+ "PopupMenuUI", "javax.swing.plaf.basic.BasicPopupMenuUI",
+ "ProgressBarUI", "javax.swing.plaf.basic.BasicProgressBarUI",
+ "RadioButtonMenuItemUI", "javax.swing.plaf.basic.BasicRadioButtonMenuItemUI",
+ "RadioButtonUI", "javax.swing.plaf.basic.BasicRadioButtonUI",
+ "RootPaneUI", "javax.swing.plaf.basic.BasicRootPaneUI",
+ "ScrollBarUI", "javax.swing.plaf.basic.BasicScrollBarUI",
+ "ScrollPaneUI", "javax.swing.plaf.basic.BasicScrollPaneUI",
+ "SeparatorUI", "javax.swing.plaf.basic.BasicSeparatorUI",
+ "SliderUI", "javax.swing.plaf.basic.BasicSliderUI",
+ "SplitPaneUI", "javax.swing.plaf.basic.BasicSplitPaneUI",
+ "SpinnerUI", "javax.swing.plaf.basic.BasicSpinnerUI",
+ "StandardDialogUI", "javax.swing.plaf.basic.BasicStandardDialogUI",
+ "TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI",
+ "TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI",
+ "TableUI", "javax.swing.plaf.basic.BasicTableUI",
+ "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
+ "TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI",
+ "TextFieldUI", "javax.swing.plaf.basic.BasicTextFieldUI",
+ "ToggleButtonUI", "javax.swing.plaf.basic.BasicToggleButtonUI",
+ "ToolBarSeparatorUI", "javax.swing.plaf.basic.BasicToolBarSeparatorUI",
+ "ToolBarUI", "javax.swing.plaf.basic.BasicToolBarUI",
+ "ToolTipUI", "javax.swing.plaf.basic.BasicToolTipUI",
+ "TreeUI", "javax.swing.plaf.basic.BasicTreeUI",
+ "ViewportUI", "javax.swing.plaf.basic.BasicViewportUI"
+ };
+ // Add Class Defaults to UI Defaults table
+ defaults.putDefaults(uiDefaults);
+ }
+
+ /**
+ * Populates the <code>defaults</code> table with system color defaults.
+ *
+ * This sets up a couple of default values and passes them to
+ * {@link #loadSystemColors(UIDefaults, String[], boolean)}. If the
+ * look and feel is a native look and feel, these defaults may be overridden
+ * by the corresponding SystemColor constants.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
+ */
+ protected void initSystemColorDefaults(UIDefaults defaults)
+ {
+ String[] defaultColors = new String[] {
+ "activeCaption", "#000080",
+ "activeCaptionBorder", "#C0C0C0",
+ "activeCaptionText", "#FFFFFF",
+ "control", "#C0C0C0",
+ "controlDkShadow", "#000000",
+ "controlHighlight", "#C0C0C0",
+ "controlLtHighlight", "#FFFFFF",
+ "controlShadow", "#808080",
+ "controlText", "#000000",
+ "desktop", "#005C5C",
+ "inactiveCaption", "#808080",
+ "inactiveCaptionBorder", "#C0C0C0",
+ "inactiveCaptionText", "#C0C0C0",
+ "info", "#FFFFE1",
+ "infoText", "#000000",
+ "menu", "#C0C0C0",
+ "menuText", "#000000",
+ "scrollbar", "#E0E0E0",
+ "text", "#C0C0C0",
+ "textHighlight", "#000080",
+ "textHighlightText", "#FFFFFF",
+ "textInactiveText", "#808080",
+ "textText", "#000000",
+ "window", "#FFFFFF",
+ "windowBorder", "#000000",
+ "windowText", "#000000"
+ };
+ loadSystemColors(defaults, defaultColors, isNativeLookAndFeel());
+ }
+
+ /**
+ * Populates the <code>defaults</code> table with the system colors. If
+ * <code>useNative</code> is <code>true</code>, the table is populated
+ * with the constants in {@link SystemColor}, otherwise the
+ * <code>systemColors</code> parameter is decoded into the defaults table.
+ * The system colors array is made up of pairs, where the first entry is the
+ * name of the system color, and the second entry is a string denoting
+ * an RGB color value like "#C0C0C0", which is decoded using
+ * {@link Color#decode(String)}.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
+ * @param systemColors defaults to use when <code>useNative</code> is
+ * <code>false</code>
+ * @param useNative when <code>true</code>, installs the values of the
+ * SystemColor constants, when <code>false</code>, install the values
+ * from <code>systemColors</code>
+ */
+ protected void loadSystemColors(UIDefaults defaults, String[] systemColors,
+ boolean useNative)
+ {
+ if (useNative)
+ {
+ defaults.put("activeCaption",
+ new ColorUIResource(SystemColor.ACTIVE_CAPTION));
+ defaults.put("activeCaptionBorder",
+ new ColorUIResource(SystemColor.ACTIVE_CAPTION_BORDER));
+ defaults.put("activeCaptionText",
+ new ColorUIResource(SystemColor.ACTIVE_CAPTION_TEXT));
+ defaults.put("control",
+ new ColorUIResource(SystemColor.CONTROL));
+ defaults.put("controlDkShadow",
+ new ColorUIResource(SystemColor.CONTROL_DK_SHADOW));
+ defaults.put("controlHighlight",
+ new ColorUIResource(SystemColor.CONTROL_HIGHLIGHT));
+ defaults.put("controlLtHighlight",
+ new ColorUIResource(SystemColor.CONTROL_LT_HIGHLIGHT));
+ defaults.put("controlShadow",
+ new ColorUIResource(SystemColor.CONTROL_SHADOW));
+ defaults.put("controlText",
+ new ColorUIResource(SystemColor.CONTROL_TEXT));
+ defaults.put("desktop",
+ new ColorUIResource(SystemColor.DESKTOP));
+ defaults.put("inactiveCaption",
+ new ColorUIResource(SystemColor.INACTIVE_CAPTION));
+ defaults.put("inactiveCaptionBorder",
+ new ColorUIResource(SystemColor.INACTIVE_CAPTION_BORDER));
+ defaults.put("inactiveCaptionText",
+ new ColorUIResource(SystemColor.INACTIVE_CAPTION_TEXT));
+ defaults.put("info",
+ new ColorUIResource(SystemColor.INFO));
+ defaults.put("infoText",
+ new ColorUIResource(SystemColor.INFO_TEXT));
+ defaults.put("menu",
+ new ColorUIResource(SystemColor.MENU));
+ defaults.put("menuText",
+ new ColorUIResource(SystemColor.MENU_TEXT));
+ defaults.put("scrollbar",
+ new ColorUIResource(SystemColor.SCROLLBAR));
+ defaults.put("text",
+ new ColorUIResource(SystemColor.TEXT));
+ defaults.put("textHighlight",
+ new ColorUIResource(SystemColor.TEXT_HIGHLIGHT));
+ defaults.put("textHighlightText",
+ new ColorUIResource(SystemColor.TEXT_HIGHLIGHT_TEXT));
+ defaults.put("textInactiveText",
+ new ColorUIResource(SystemColor.TEXT_INACTIVE_TEXT));
+ defaults.put("textText",
+ new ColorUIResource(SystemColor.TEXT_TEXT));
+ defaults.put("window",
+ new ColorUIResource(SystemColor.WINDOW));
+ defaults.put("windowBorder",
+ new ColorUIResource(SystemColor.WINDOW_BORDER));
+ defaults.put("windowText",
+ new ColorUIResource(SystemColor.WINDOW_TEXT));
+ }
+ else
+ {
+ for (int i = 0; i < systemColors.length; i += 2)
+ {
+ Color color = Color.BLACK;
+ try
+ {
+ color = Color.decode(systemColors[i + 1]);
+ }
+ catch (NumberFormatException e)
+ {
+ e.printStackTrace();
+ }
+ defaults.put(systemColors[i], new ColorUIResource(color));
+ }
+ }
+ }
+
+ /**
+ * Loads the resource bundle in 'resources/basic' and adds the contained
+ * key/value pairs to the <code>defaults</code> table.
+ *
+ * @param defaults the UI defaults to load the resources into
+ */
+ // FIXME: This method is not used atm and private and thus could be removed.
+ // However, I consider this method useful for providing localized
+ // descriptions and similar stuff and therefore think that we should use it
+ // instead and provide the resource bundles.
+ private void loadResourceBundle(UIDefaults defaults)
+ {
+ ResourceBundle bundle;
+ Enumeration e;
+ String key;
+ String value;
+ bundle = ResourceBundle.getBundle("resources/basic");
+ // Process Resources
+ e = bundle.getKeys();
+ while (e.hasMoreElements())
+ {
+ key = (String) e.nextElement();
+ value = bundle.getString(key);
+ defaults.put(key, value);
+ }
+ }
+
+ /**
+ * Populates the <code>defaults</code> table with UI default values for
+ * colors, fonts, keybindings and much more.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
+ */
+ protected void initComponentDefaults(UIDefaults defaults)
+ {
+ Object[] uiDefaults;
+
+ Color highLight = new Color(249, 247, 246);
+ Color light = new Color(239, 235, 231);
+ Color shadow = new Color(139, 136, 134);
+ Color darkShadow = new Color(16, 16, 16);
+
+ uiDefaults = new Object[] {
+
+ "AbstractUndoableEdit.undoText", "Undo",
+ "AbstractUndoableEdit.redoText", "Redo",
+ "Button.background", new ColorUIResource(Color.LIGHT_GRAY),
+ "Button.border",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults table)
+ {
+ return BasicBorders.getButtonBorder();
+ }
+ },
+ "Button.darkShadow", new ColorUIResource(Color.BLACK),
+ "Button.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Button.foreground", new ColorUIResource(Color.BLACK),
+ "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("SPACE"), "pressed",
+ KeyStroke.getKeyStroke("released SPACE"), "released"
+ }),
+ "Button.highlight", new ColorUIResource(Color.WHITE),
+ "Button.light", new ColorUIResource(Color.LIGHT_GRAY),
+ "Button.margin", new InsetsUIResource(2, 14, 2, 14),
+ "Button.shadow", new ColorUIResource(Color.GRAY),
+ "Button.textIconGap", new Integer(4),
+ "Button.textShiftOffset", new Integer(0),
+ "CheckBox.background", new ColorUIResource(new Color(204, 204, 204)),
+ "CheckBox.border", new BorderUIResource.CompoundBorderUIResource(null,
+ null),
+ "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("SPACE"), "pressed",
+ KeyStroke.getKeyStroke("released SPACE"), "released"
+ }),
+ "CheckBox.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "CheckBox.foreground", new ColorUIResource(darkShadow),
+ "CheckBox.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getCheckBoxIcon();
+ }
+ },
+ "CheckBox.checkIcon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getMenuItemCheckIcon();
+ }
+ },
+ "CheckBox.margin", new InsetsUIResource(2, 2, 2, 2),
+ "CheckBox.textIconGap", new Integer(4),
+ "CheckBox.textShiftOffset", new Integer(0),
+ "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog",
+ Font.PLAIN, 12),
+ "CheckBoxMenuItem.acceleratorForeground",
+ new ColorUIResource(new Color(16, 16, 16)),
+ "CheckBoxMenuItem.acceleratorSelectionForeground",
+ new ColorUIResource(Color.white),
+ "CheckBoxMenuItem.arrowIcon", BasicIconFactory.getMenuItemArrowIcon(),
+ "CheckBoxMenuItem.background", new ColorUIResource(light),
+ "CheckBoxMenuItem.border", new BasicBorders.MarginBorder(),
+ "CheckBoxMenuItem.borderPainted", Boolean.FALSE,
+ "CheckBoxMenuItem.checkIcon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getCheckBoxMenuItemIcon();
+ }
+ },
+ "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "CheckBoxMenuItem.foreground", new ColorUIResource(darkShadow),
+ "CheckBoxMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
+ "CheckBoxMenuItem.selectionBackground", new ColorUIResource(Color.black),
+ "CheckBoxMenuItem.selectionForeground", new ColorUIResource(Color.white),
+ "ColorChooser.background", new ColorUIResource(light),
+ "ColorChooser.cancelText", "Cancel",
+ "ColorChooser.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ColorChooser.foreground", new ColorUIResource(darkShadow),
+ "ColorChooser.hsbBlueText", "B",
+ "ColorChooser.hsbBrightnessText", "B",
+ "ColorChooser.hsbGreenText", "G",
+ "ColorChooser.hsbHueText", "H",
+ "ColorChooser.hsbNameText", "HSB",
+ "ColorChooser.hsbRedText", "R",
+ "ColorChooser.hsbSaturationText", "S",
+ "ColorChooser.okText", "OK",
+ "ColorChooser.previewText", "Preview",
+ "ColorChooser.resetText", "Reset",
+ "ColorChooser.rgbBlueMnemonic", "66",
+ "ColorChooser.rgbBlueText", "Blue",
+ "ColorChooser.rgbGreenMnemonic", "78",
+ "ColorChooser.rgbGreenText", "Green",
+ "ColorChooser.rgbNameText", "RGB",
+ "ColorChooser.rgbRedMnemonic", "68",
+ "ColorChooser.rgbRedText", "Red",
+ "ColorChooser.sampleText", "Sample Text Sample Text",
+ "ColorChooser.swatchesDefaultRecentColor", new ColorUIResource(light),
+ "ColorChooser.swatchesNameText", "Swatches",
+ "ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10),
+ "ColorChooser.swatchesRecentText", "Recent:",
+ "ColorChooser.swatchesSwatchSize", new Dimension(10, 10),
+ "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "hidePopup",
+ "PAGE_UP", "pageUpPassThrough",
+ "PAGE_DOWN", "pageDownPassThrough",
+ "HOME", "homePassThrough",
+ "END", "endPassThrough"
+ }),
+ "ComboBox.background", new ColorUIResource(Color.white),
+ "ComboBox.buttonBackground", new ColorUIResource(light),
+ "ComboBox.buttonDarkShadow", new ColorUIResource(darkShadow),
+ "ComboBox.buttonHighlight", new ColorUIResource(highLight),
+ "ComboBox.buttonShadow", new ColorUIResource(shadow),
+ "ComboBox.disabledBackground", new ColorUIResource(light),
+ "ComboBox.disabledForeground", new ColorUIResource(Color.gray),
+ "ComboBox.font", new FontUIResource("SansSerif", Font.PLAIN, 12),
+ "ComboBox.foreground", new ColorUIResource(Color.black),
+ "ComboBox.selectionBackground", new ColorUIResource(0, 0, 128),
+ "ComboBox.selectionForeground", new ColorUIResource(Color.white),
+ "Desktop.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "KP_LEFT", "left",
+ "KP_RIGHT", "right",
+ "ctrl F5", "restore",
+ "LEFT", "left",
+ "ctrl alt F6", "selectNextFrame",
+ "UP", "up",
+ "ctrl F6", "selectNextFrame",
+ "RIGHT", "right",
+ "DOWN", "down",
+ "ctrl F7", "move",
+ "ctrl F8", "resize",
+ "ESCAPE", "escape",
+ "ctrl TAB", "selectNextFrame",
+ "ctrl F9", "minimize",
+ "KP_UP", "up",
+ "ctrl F4", "close",
+ "KP_DOWN", "down",
+ "ctrl F10", "maximize",
+ "ctrl alt shift F6", "selectPreviousFrame"
+ }),
+ "DesktopIcon.border", new BorderUIResource.CompoundBorderUIResource(null,
+ null),
+ "EditorPane.background", new ColorUIResource(Color.white),
+ "EditorPane.border", BasicBorders.getMarginBorder(),
+ "EditorPane.caretBlinkRate", new Integer(500),
+ "EditorPane.caretForeground", new ColorUIResource(Color.black),
+ "EditorPane.font", new FontUIResource("Serif", Font.PLAIN, 12),
+ "EditorPane.foreground", new ColorUIResource(Color.black),
+ "EditorPane.inactiveForeground", new ColorUIResource(Color.gray),
+ "EditorPane.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("shift UP"), "selection-up",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("shift KP_UP"), "selection-up",
+ KeyStroke.getKeyStroke("DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("shift ctrl T"), "previous-link-action",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("shift PAGE_UP"), "selection-page-up",
+ KeyStroke.getKeyStroke("KP_UP"), "caret-up",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("ctrl HOME"), "caret-begin",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("ctrl END"), "caret-end",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("ctrl SPACE"), "activate-link-action",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ENTER"), "insert-break",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_UP"), "selection-page-left",
+ KeyStroke.getKeyStroke("shift DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("PAGE_DOWN"), "page-down",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_DOWN"), "selection-page-right",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("KP_DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("shift ctrl END"), "selection-end",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl T"), "next-link-action",
+ KeyStroke.getKeyStroke("shift KP_DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("TAB"), "insert-tab",
+ KeyStroke.getKeyStroke("UP"), "caret-up",
+ KeyStroke.getKeyStroke("shift ctrl HOME"), "selection-begin",
+ KeyStroke.getKeyStroke("shift PAGE_DOWN"), "selection-page-down",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("PAGE_UP"), "page-up",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard"
+ }),
+ "EditorPane.margin", new InsetsUIResource(3, 3, 3, 3),
+ "EditorPane.selectionBackground", new ColorUIResource(Color.black),
+ "EditorPane.selectionForeground", new ColorUIResource(Color.white),
+ "FileChooser.acceptAllFileFilterText", "All Files (*.*)",
+ "FileChooser.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "cancelSelection"
+ }),
+ "FileChooser.cancelButtonMnemonic", "67",
+ "FileChooser.cancelButtonText", "Cancel",
+ "FileChooser.cancelButtonToolTipText", "Abort file chooser dialog",
+ "FileChooser.directoryDescriptionText", "Directory",
+ "FileChooser.fileDescriptionText", "Generic File",
+ "FileChooser.directoryOpenButtonMnemonic", "79",
+ "FileChooser.helpButtonMnemonic", "72",
+ "FileChooser.helpButtonText", "Help",
+ "FileChooser.helpButtonToolTipText", "FileChooser help",
+ "FileChooser.newFolderErrorSeparator", ":",
+ "FileChooser.newFolderErrorText", "Error creating new folder",
+ "FileChooser.openButtonMnemonic", "79",
+ "FileChooser.openButtonText", "Open",
+ "FileChooser.openButtonToolTipText", "Open selected file",
+ "FileChooser.saveButtonMnemonic", "83",
+ "FileChooser.saveButtonText", "Save",
+ "FileChooser.saveButtonToolTipText", "Save selected file",
+ "FileChooser.updateButtonMnemonic", "85",
+ "FileChooser.updateButtonText", "Update",
+ "FileChooser.updateButtonToolTipText", "Update directory listing",
+ "FocusManagerClassName", "TODO",
+ "FormattedTextField.background", new ColorUIResource(light),
+ "FormattedTextField.caretForeground", new ColorUIResource(Color.black),
+ "FormattedTextField.margin", new InsetsUIResource(0, 0, 0, 0),
+ "FormattedTextField.caretBlinkRate", new Integer(500),
+ "FormattedTextField.font",
+ new FontUIResource("SansSerif", Font.PLAIN, 12),
+ "FormattedTextField.foreground", new ColorUIResource(Color.black),
+ "FormattedTextField.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("KP_UP"), "increment",
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("KP_DOWN"), "decrement",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("UP"), "increment",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("ESCAPE"), "reset-field-edit",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("DOWN"), "decrement",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("ENTER"), "notify-field-accept",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward"
+ }),
+ "FormattedTextField.inactiveBackground", new ColorUIResource(light),
+ "FormattedTextField.inactiveForeground", new ColorUIResource(Color.gray),
+ "FormattedTextField.selectionBackground",
+ new ColorUIResource(Color.black),
+ "FormattedTextField.selectionForeground",
+ new ColorUIResource(Color.white),
+ "FormView.resetButtonText", "Reset",
+ "FormView.submitButtonText", "Submit Query",
+ "InternalFrame.activeTitleBackground", new ColorUIResource(0, 0, 128),
+ "InternalFrame.activeTitleForeground", new ColorUIResource(Color.white),
+ "InternalFrame.border",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults table)
+ {
+ Color lineColor = new Color(238, 238, 238);
+ Border inner = BorderFactory.createLineBorder(lineColor, 1);
+ Color shadowInner = new Color(184, 207, 229);
+ Color shadowOuter = new Color(122, 138, 153);
+ Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
+ Color.WHITE,
+ Color.WHITE,
+ shadowOuter,
+ shadowInner);
+ Border border = new BorderUIResource.CompoundBorderUIResource(outer,
+ inner);
+ return border;
+ }
+ },
+ "InternalFrame.borderColor", new ColorUIResource(light),
+ "InternalFrame.borderDarkShadow", new ColorUIResource(Color.BLACK),
+ "InternalFrame.borderHighlight", new ColorUIResource(Color.WHITE),
+ "InternalFrame.borderLight", new ColorUIResource(Color.LIGHT_GRAY),
+ "InternalFrame.borderShadow", new ColorUIResource(Color.GRAY),
+ "InternalFrame.closeIcon", BasicIconFactory.createEmptyFrameIcon(),
+ "InternalFrame.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return new IconUIResource(BasicIconFactory.createEmptyFrameIcon());
+ }
+ },
+ "InternalFrame.iconifyIcon", BasicIconFactory.createEmptyFrameIcon(),
+ "InternalFrame.inactiveTitleBackground", new ColorUIResource(Color.gray),
+ "InternalFrame.inactiveTitleForeground",
+ new ColorUIResource(Color.lightGray),
+ "InternalFrame.maximizeIcon", BasicIconFactory.createEmptyFrameIcon(),
+ "InternalFrame.minimizeIcon", BasicIconFactory.createEmptyFrameIcon(),
+ "InternalFrame.titleFont", new FontUIResource("Dialog", Font.BOLD, 12),
+ "InternalFrame.windowBindings", new Object[] {
+ "shift ESCAPE", "showSystemMenu",
+ "ctrl SPACE", "showSystemMenu",
+ "ESCAPE", "showSystemMenu"
+ },
+ "Label.background", new ColorUIResource(light),
+ "Label.disabledForeground", new ColorUIResource(Color.white),
+ "Label.disabledShadow", new ColorUIResource(shadow),
+ "Label.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Label.foreground", new ColorUIResource(darkShadow),
+ "List.background", new ColorUIResource(Color.white),
+ "List.border", new BasicBorders.MarginBorder(),
+ "List.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("ctrl DOWN"), "selectNextRowChangeLead",
+ KeyStroke.getKeyStroke("shift UP"), "selectPreviousRowExtendSelection",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "selectNextColumnChangeLead",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selectPreviousColumnExtendSelection",
+ KeyStroke.getKeyStroke("shift KP_UP"), "selectPreviousRowExtendSelection",
+ KeyStroke.getKeyStroke("DOWN"), "selectNextRow",
+ KeyStroke.getKeyStroke("ctrl UP"), "selectPreviousRowChangeLead",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "selectPreviousColumnChangeLead",
+ KeyStroke.getKeyStroke("CUT"), "cut",
+ KeyStroke.getKeyStroke("END"), "selectLastRow",
+ KeyStroke.getKeyStroke("shift PAGE_UP"), "scrollUpExtendSelection",
+ KeyStroke.getKeyStroke("KP_UP"), "selectPreviousRow",
+ KeyStroke.getKeyStroke("shift ctrl UP"), "selectPreviousRowExtendSelection",
+ KeyStroke.getKeyStroke("ctrl HOME"), "selectFirstRowChangeLead",
+ KeyStroke.getKeyStroke("shift LEFT"), "selectPreviousColumnExtendSelection",
+ KeyStroke.getKeyStroke("ctrl END"), "selectLastRowChangeLead",
+ KeyStroke.getKeyStroke("ctrl PAGE_DOWN"), "scrollDownChangeLead",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selectNextColumnExtendSelection",
+ KeyStroke.getKeyStroke("LEFT"), "selectPreviousColumn",
+ KeyStroke.getKeyStroke("ctrl PAGE_UP"), "scrollUpChangeLead",
+ KeyStroke.getKeyStroke("KP_LEFT"), "selectPreviousColumn",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selectNextColumnExtendSelection",
+ KeyStroke.getKeyStroke("SPACE"), "addToSelection",
+ KeyStroke.getKeyStroke("ctrl SPACE"), "toggleAndAnchor",
+ KeyStroke.getKeyStroke("shift SPACE"), "extendTo",
+ KeyStroke.getKeyStroke("shift ctrl SPACE"), "moveSelectionTo",
+ KeyStroke.getKeyStroke("shift ctrl DOWN"), "selectNextRowExtendSelection",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "clearSelection",
+ KeyStroke.getKeyStroke("shift HOME"), "selectFirstRowExtendSelection",
+ KeyStroke.getKeyStroke("RIGHT"), "selectNextColumn",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_UP"), "scrollUpExtendSelection",
+ KeyStroke.getKeyStroke("shift DOWN"), "selectNextRowExtendSelection",
+ KeyStroke.getKeyStroke("PAGE_DOWN"), "scrollDown",
+ KeyStroke.getKeyStroke("shift ctrl KP_UP"), "selectPreviousRowExtendSelection",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selectPreviousColumnExtendSelection",
+ KeyStroke.getKeyStroke("ctrl X"), "cut",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_DOWN"), "scrollDownExtendSelection",
+ KeyStroke.getKeyStroke("ctrl SLASH"), "selectAll",
+ KeyStroke.getKeyStroke("ctrl C"), "copy",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "selectNextColumnChangeLead",
+ KeyStroke.getKeyStroke("shift END"), "selectLastRowExtendSelection",
+ KeyStroke.getKeyStroke("shift ctrl KP_DOWN"), "selectNextRowExtendSelection",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "selectPreviousColumnChangeLead",
+ KeyStroke.getKeyStroke("HOME"), "selectFirstRow",
+ KeyStroke.getKeyStroke("ctrl V"), "paste",
+ KeyStroke.getKeyStroke("KP_DOWN"), "selectNextRow",
+ KeyStroke.getKeyStroke("ctrl KP_DOWN"), "selectNextRowChangeLead",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selectNextColumnExtendSelection",
+ KeyStroke.getKeyStroke("ctrl A"), "selectAll",
+ KeyStroke.getKeyStroke("shift ctrl END"), "selectLastRowExtendSelection",
+ KeyStroke.getKeyStroke("COPY"), "copy",
+ KeyStroke.getKeyStroke("ctrl KP_UP"), "selectPreviousRowChangeLead",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selectPreviousColumnExtendSelection",
+ KeyStroke.getKeyStroke("shift KP_DOWN"), "selectNextRowExtendSelection",
+ KeyStroke.getKeyStroke("UP"), "selectPreviousRow",
+ KeyStroke.getKeyStroke("shift ctrl HOME"), "selectFirstRowExtendSelection",
+ KeyStroke.getKeyStroke("shift PAGE_DOWN"), "scrollDownExtendSelection",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "selectNextColumn",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selectNextColumnExtendSelection",
+ KeyStroke.getKeyStroke("PAGE_UP"), "scrollUp",
+ KeyStroke.getKeyStroke("PASTE"), "paste"
+ }),
+ "List.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "List.foreground", new ColorUIResource(Color.black),
+ "List.selectionBackground", new ColorUIResource(0, 0, 128),
+ "List.selectionForeground", new ColorUIResource(Color.white),
+ "List.focusCellHighlightBorder",
+ new BorderUIResource.
+ LineBorderUIResource(new ColorUIResource(Color.yellow)),
+ "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Menu.crossMenuMnemonic", Boolean.TRUE,
+ "Menu.acceleratorForeground", new ColorUIResource(darkShadow),
+ "Menu.acceleratorSelectionForeground", new ColorUIResource(Color.white),
+ "Menu.arrowIcon", BasicIconFactory.getMenuArrowIcon(),
+ "Menu.background", new ColorUIResource(light),
+ "Menu.border", new BasicBorders.MarginBorder(),
+ "Menu.borderPainted", Boolean.FALSE,
+ "Menu.checkIcon", BasicIconFactory.getMenuItemCheckIcon(),
+ "Menu.consumesTabs", Boolean.TRUE,
+ "Menu.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Menu.foreground", new ColorUIResource(darkShadow),
+ "Menu.margin", new InsetsUIResource(2, 2, 2, 2),
+ "Menu.selectedWindowInputMapBindings", new Object[] {
+ "ESCAPE", "cancel",
+ "DOWN", "selectNext",
+ "KP_DOWN", "selectNext",
+ "UP", "selectPrevious",
+ "KP_UP", "selectPrevious",
+ "LEFT", "selectParent",
+ "KP_LEFT", "selectParent",
+ "RIGHT", "selectChild",
+ "KP_RIGHT", "selectChild",
+ "ENTER", "return",
+ "SPACE", "return"
+ },
+ "Menu.menuPopupOffsetX", new Integer(0),
+ "Menu.menuPopupOffsetY", new Integer(0),
+ "Menu.submenuPopupOffsetX", new Integer(0),
+ "Menu.submenuPopupOffsetY", new Integer(0),
+ "Menu.selectionBackground", new ColorUIResource(Color.black),
+ "Menu.selectionForeground", new ColorUIResource(Color.white),
+ "MenuBar.background", new ColorUIResource(light),
+ "MenuBar.border", new BasicBorders.MenuBarBorder(null, null),
+ "MenuBar.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "MenuBar.foreground", new ColorUIResource(darkShadow),
+ "MenuBar.highlight", new ColorUIResource(highLight),
+ "MenuBar.shadow", new ColorUIResource(shadow),
+ "MenuBar.windowBindings", new Object[] {
+ "F10", "takeFocus"
+ },
+ "MenuItem.acceleratorDelimiter", "+",
+ "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "MenuItem.acceleratorForeground", new ColorUIResource(darkShadow),
+ "MenuItem.acceleratorSelectionForeground",
+ new ColorUIResource(Color.white),
+ "MenuItem.arrowIcon", BasicIconFactory.getMenuItemArrowIcon(),
+ "MenuItem.background", new ColorUIResource(light),
+ "MenuItem.border", new BasicBorders.MarginBorder(),
+ "MenuItem.borderPainted", Boolean.FALSE,
+ "MenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "MenuItem.foreground", new ColorUIResource(darkShadow),
+ "MenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
+ "MenuItem.selectionBackground", new ColorUIResource(Color.black),
+ "MenuItem.selectionForeground", new ColorUIResource(Color.white),
+ "OptionPane.background", new ColorUIResource(light),
+ "OptionPane.border",
+ new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
+ "OptionPane.buttonAreaBorder",
+ new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
+ "OptionPane.buttonClickThreshhold", new Integer(500),
+ "OptionPane.cancelButtonText", "Cancel",
+ "OptionPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "OptionPane.foreground", new ColorUIResource(darkShadow),
+ "OptionPane.messageAreaBorder",
+ new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
+ "OptionPane.messageForeground", new ColorUIResource(darkShadow),
+ "OptionPane.minimumSize",
+ new DimensionUIResource(BasicOptionPaneUI.MinimumWidth,
+ BasicOptionPaneUI.MinimumHeight),
+ "OptionPane.noButtonText", "No",
+ "OptionPane.okButtonText", "OK",
+ "OptionPane.windowBindings", new Object[] {
+ "ESCAPE", "close"
+ },
+ "OptionPane.yesButtonText", "Yes",
+ "Panel.background", new ColorUIResource(light),
+ "Panel.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Panel.foreground", new ColorUIResource(Color.black),
+ "PasswordField.background", new ColorUIResource(light),
+ "PasswordField.border", new BasicBorders.FieldBorder(null, null,
+ null, null),
+ "PasswordField.caretBlinkRate", new Integer(500),
+ "PasswordField.caretForeground", new ColorUIResource(Color.black),
+ "PasswordField.font", new FontUIResource("MonoSpaced", Font.PLAIN, 12),
+ "PasswordField.foreground", new ColorUIResource(Color.black),
+ "PasswordField.inactiveBackground", new ColorUIResource(light),
+ "PasswordField.inactiveForeground", new ColorUIResource(Color.gray),
+ "PasswordField.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-end-line",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-begin-line",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-end-line",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-begin-line",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-begin-line",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-end-line",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("ENTER"), "notify-field-accept",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward"
+ }),
+ "PasswordField.margin", new InsetsUIResource(0, 0, 0, 0),
+ "PasswordField.selectionBackground", new ColorUIResource(Color.black),
+ "PasswordField.selectionForeground", new ColorUIResource(Color.white),
+ "PopupMenu.background", new ColorUIResource(light),
+ "PopupMenu.border", new BorderUIResource.BevelBorderUIResource(0),
+ "PopupMenu.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "PopupMenu.foreground", new ColorUIResource(darkShadow),
+ "PopupMenu.selectedWindowInputMapBindings",
+ new Object[] {"ESCAPE", "cancel",
+ "DOWN", "selectNext",
+ "KP_DOWN", "selectNext",
+ "UP", "selectPrevious",
+ "KP_UP", "selectPrevious",
+ "LEFT", "selectParent",
+ "KP_LEFT", "selectParent",
+ "RIGHT", "selectChild",
+ "KP_RIGHT", "selectChild",
+ "ENTER", "return",
+ "SPACE", "return"
+ },
+ "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
+ new Object[] {"LEFT", "selectChild",
+ "KP_LEFT", "selectChild",
+ "RIGHT", "selectParent",
+ "KP_RIGHT", "selectParent",
+ },
+ "ProgressBar.background", new ColorUIResource(Color.LIGHT_GRAY),
+ "ProgressBar.border",
+ new BorderUIResource.LineBorderUIResource(Color.GREEN, 2),
+ "ProgressBar.cellLength", new Integer(1),
+ "ProgressBar.cellSpacing", new Integer(0),
+ "ProgressBar.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ProgressBar.foreground", new ColorUIResource(0, 0, 128),
+ "ProgressBar.selectionBackground", new ColorUIResource(0, 0, 128),
+ "ProgressBar.selectionForeground", new ColorUIResource(Color.LIGHT_GRAY),
+ "ProgressBar.repaintInterval", new Integer(50),
+ "ProgressBar.cycleTime", new Integer(3000),
+ "RadioButton.background", new ColorUIResource(light),
+ "RadioButton.border", new BorderUIResource.CompoundBorderUIResource(null,
+ null),
+ "RadioButton.darkShadow", new ColorUIResource(shadow),
+ "RadioButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("SPACE"), "pressed",
+ KeyStroke.getKeyStroke("released SPACE"), "released"
+ }),
+ "RadioButton.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "RadioButton.foreground", new ColorUIResource(darkShadow),
+ "RadioButton.highlight", new ColorUIResource(highLight),
+ "RadioButton.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getRadioButtonIcon();
+ }
+ },
+ "RadioButton.light", new ColorUIResource(highLight),
+ "RadioButton.margin", new InsetsUIResource(2, 2, 2, 2),
+ "RadioButton.shadow", new ColorUIResource(shadow),
+ "RadioButton.textIconGap", new Integer(4),
+ "RadioButton.textShiftOffset", new Integer(0),
+ "RadioButtonMenuItem.acceleratorFont",
+ new FontUIResource("Dialog", Font.PLAIN, 12),
+ "RadioButtonMenuItem.acceleratorForeground",
+ new ColorUIResource(darkShadow),
+ "RadioButtonMenuItem.acceleratorSelectionForeground",
+ new ColorUIResource(Color.white),
+ "RadioButtonMenuItem.arrowIcon", BasicIconFactory.getMenuItemArrowIcon(),
+ "RadioButtonMenuItem.background", new ColorUIResource(light),
+ "RadioButtonMenuItem.border", new BasicBorders.MarginBorder(),
+ "RadioButtonMenuItem.borderPainted", Boolean.FALSE,
+ "RadioButtonMenuItem.checkIcon", BasicIconFactory.getRadioButtonMenuItemIcon(),
+ "RadioButtonMenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "RadioButtonMenuItem.foreground", new ColorUIResource(darkShadow),
+ "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
+ "RadioButtonMenuItem.selectionBackground",
+ new ColorUIResource(Color.black),
+ "RadioButtonMenuItem.selectionForeground",
+ new ColorUIResource(Color.white),
+ "RootPane.defaultButtonWindowKeyBindings", new Object[] {
+ "ENTER", "press",
+ "released ENTER", "release",
+ "ctrl ENTER", "press",
+ "ctrl released ENTER", "release"
+ },
+ "ScrollBar.background", new ColorUIResource(224, 224, 224),
+ "ScrollBar.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "PAGE_UP", "negativeBlockIncrement",
+ "PAGE_DOWN", "positiveBlockIncrement",
+ "END", "maxScroll",
+ "HOME", "minScroll",
+ "LEFT", "negativeUnitIncrement",
+ "KP_UP", "negativeUnitIncrement",
+ "KP_DOWN", "positiveUnitIncrement",
+ "UP", "negativeUnitIncrement",
+ "RIGHT", "positiveUnitIncrement",
+ "KP_LEFT", "negativeUnitIncrement",
+ "DOWN", "positiveUnitIncrement",
+ "KP_RIGHT", "positiveUnitIncrement"
+ }),
+ "ScrollBar.foreground", new ColorUIResource(light),
+ "ScrollBar.maximumThumbSize", new DimensionUIResource(4096, 4096),
+ "ScrollBar.minimumThumbSize", new DimensionUIResource(8, 8),
+ "ScrollBar.thumb", new ColorUIResource(light),
+ "ScrollBar.thumbDarkShadow", new ColorUIResource(shadow),
+ "ScrollBar.thumbHighlight", new ColorUIResource(highLight),
+ "ScrollBar.thumbShadow", new ColorUIResource(shadow),
+ "ScrollBar.track", new ColorUIResource(light),
+ "ScrollBar.trackHighlight", new ColorUIResource(shadow),
+ "ScrollBar.width", new Integer(16),
+ "ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "PAGE_UP", "scrollUp",
+ "KP_LEFT", "unitScrollLeft",
+ "ctrl PAGE_DOWN", "scrollRight",
+ "PAGE_DOWN", "scrollDown",
+ "KP_RIGHT", "unitScrollRight",
+ "LEFT", "unitScrollLeft",
+ "ctrl END", "scrollEnd",
+ "UP", "unitScrollUp",
+ "RIGHT", "unitScrollRight",
+ "DOWN", "unitScrollDown",
+ "ctrl HOME", "scrollHome",
+ "ctrl PAGE_UP", "scrollLeft",
+ "KP_UP", "unitScrollUp",
+ "KP_DOWN", "unitScrollDown"
+ }),
+ "ScrollPane.background", new ColorUIResource(light),
+ "ScrollPane.border", new BorderUIResource.EtchedBorderUIResource(),
+ "ScrollPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ScrollPane.foreground", new ColorUIResource(darkShadow),
+ "Separator.background", new ColorUIResource(highLight),
+ "Separator.foreground", new ColorUIResource(shadow),
+ "Separator.highlight", new ColorUIResource(highLight),
+ "Separator.shadow", new ColorUIResource(shadow),
+ "Slider.background", new ColorUIResource(light),
+ "Slider.focus", new ColorUIResource(shadow),
+ "Slider.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl PAGE_DOWN", "negativeBlockIncrement",
+ "PAGE_DOWN", "negativeBlockIncrement",
+ "PAGE_UP", "positiveBlockIncrement",
+ "ctrl PAGE_UP", "positiveBlockIncrement",
+ "KP_RIGHT", "positiveUnitIncrement",
+ "DOWN", "negativeUnitIncrement",
+ "KP_LEFT", "negativeUnitIncrement",
+ "RIGHT", "positiveUnitIncrement",
+ "KP_DOWN", "negativeUnitIncrement",
+ "UP", "positiveUnitIncrement",
+ "KP_UP", "positiveUnitIncrement",
+ "LEFT", "negativeUnitIncrement",
+ "HOME", "minScroll",
+ "END", "maxScroll"
+ }),
+ "Slider.focusInsets", new InsetsUIResource(2, 2, 2, 2),
+ "Slider.foreground", new ColorUIResource(light),
+ "Slider.highlight", new ColorUIResource(highLight),
+ "Slider.shadow", new ColorUIResource(shadow),
+ "Slider.thumbHeight", new Integer(20),
+ "Slider.thumbWidth", new Integer(11),
+ "Slider.tickHeight", new Integer(12),
+ "Spinner.background", new ColorUIResource(light),
+ "Spinner.foreground", new ColorUIResource(light),
+ "Spinner.arrowButtonSize", new DimensionUIResource(16, 5),
+ "Spinner.editorBorderPainted", Boolean.FALSE,
+ "Spinner.font", new FontUIResource("MonoSpaced", Font.PLAIN, 12),
+ "SplitPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "F6", "toggleFocus",
+ "F8", "startResize",
+ "END", "selectMax",
+ "HOME", "selectMin",
+ "LEFT", "negativeIncrement",
+ "KP_UP", "negativeIncrement",
+ "KP_DOWN", "positiveIncrement",
+ "UP", "negativeIncrement",
+ "RIGHT", "positiveIncrement",
+ "KP_LEFT", "negativeIncrement",
+ "DOWN", "positiveIncrement",
+ "KP_RIGHT", "positiveIncrement",
+ "shift ctrl pressed TAB", "focusOutBackward",
+ "ctrl pressed TAB", "focusOutForward"
+ }),
+ "SplitPane.background", new ColorUIResource(light),
+ "SplitPane.border", new BasicBorders.SplitPaneBorder(null, null),
+ "SplitPane.darkShadow", new ColorUIResource(shadow),
+ "SplitPane.dividerSize", new Integer(7),
+ "SplitPane.highlight", new ColorUIResource(highLight),
+ "SplitPane.shadow", new ColorUIResource(shadow),
+ "SplitPaneDivider.border", BasicBorders.getSplitPaneDividerBorder(),
+ "SplitPaneDivider.draggingColor", new ColorUIResource(Color.DARK_GRAY),
+ "TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl PAGE_DOWN", "navigatePageDown",
+ "ctrl PAGE_UP", "navigatePageUp",
+ "ctrl UP", "requestFocus",
+ "ctrl KP_UP", "requestFocus"
+ }),
+ "TabbedPane.background", new ColorUIResource(light),
+ "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
+ "TabbedPane.darkShadow", new ColorUIResource(shadow),
+ "TabbedPane.focus", new ColorUIResource(darkShadow),
+ "TabbedPane.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("ctrl DOWN"), "requestFocusForVisibleComponent",
+ KeyStroke.getKeyStroke("KP_UP"), "navigateUp",
+ KeyStroke.getKeyStroke("LEFT"), "navigateLeft",
+ KeyStroke.getKeyStroke("ctrl KP_DOWN"), "requestFocusForVisibleComponent",
+ KeyStroke.getKeyStroke("UP"), "navigateUp",
+ KeyStroke.getKeyStroke("KP_DOWN"), "navigateDown",
+ KeyStroke.getKeyStroke("KP_LEFT"), "navigateLeft",
+ KeyStroke.getKeyStroke("RIGHT"), "navigateRight",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "navigateRight",
+ KeyStroke.getKeyStroke("DOWN"), "navigateDown"
+ }),
+ "TabbedPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TabbedPane.foreground", new ColorUIResource(darkShadow),
+ "TabbedPane.highlight", new ColorUIResource(highLight),
+ "TabbedPane.light", new ColorUIResource(highLight),
+ "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
+ "TabbedPane.shadow", new ColorUIResource(shadow),
+ "TabbedPane.tabbedPaneContentBorderInsets", new InsetsUIResource(3, 2, 1, 2),
+ "TabbedPane.tabbedPaneTabPadInsets", new InsetsUIResource(1, 1, 1, 1),
+ "TabbedPane.tabsOpaque", Boolean.TRUE,
+ "TabbedPane.tabAreaInsets", new InsetsUIResource(3, 2, 0, 2),
+ "TabbedPane.tabInsets", new InsetsUIResource(0, 4, 1, 4),
+ "TabbedPane.tabRunOverlay", new Integer(2),
+ "TabbedPane.textIconGap", new Integer(4),
+ "Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl DOWN", "selectNextRowChangeLead",
+ "ctrl RIGHT", "selectNextColumnChangeLead",
+ "ctrl UP", "selectPreviousRowChangeLead",
+ "ctrl LEFT", "selectPreviousColumnChangeLead",
+ "CUT", "cut",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "shift ctrl SPACE", "moveSelectionTo",
+ "ctrl X", "cut",
+ "ctrl C", "copy",
+ "ctrl KP_RIGHT", "selectNextColumnChangeLead",
+ "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
+ "ctrl V", "paste",
+ "ctrl KP_DOWN", "selectNextRowChangeLead",
+ "COPY", "copy",
+ "ctrl KP_UP", "selectPreviousRowChangeLead",
+ "PASTE", "paste",
+ "shift PAGE_DOWN", "scrollDownExtendSelection",
+ "PAGE_DOWN", "scrollDownChangeSelection",
+ "END", "selectLastColumn",
+ "shift END", "selectLastColumnExtendSelection",
+ "HOME", "selectFirstColumn",
+ "ctrl END", "selectLastRow",
+ "ctrl shift END", "selectLastRowExtendSelection",
+ "LEFT", "selectPreviousColumn",
+ "shift HOME", "selectFirstColumnExtendSelection",
+ "UP", "selectPreviousRow",
+ "RIGHT", "selectNextColumn",
+ "ctrl HOME", "selectFirstRow",
+ "shift LEFT", "selectPreviousColumnExtendSelection",
+ "DOWN", "selectNextRow",
+ "ctrl shift HOME", "selectFirstRowExtendSelection",
+ "shift UP", "selectPreviousRowExtendSelection",
+ "F2", "startEditing",
+ "shift RIGHT", "selectNextColumnExtendSelection",
+ "TAB", "selectNextColumnCell",
+ "shift DOWN", "selectNextRowExtendSelection",
+ "ENTER", "selectNextRowCell",
+ "KP_UP", "selectPreviousRow",
+ "KP_DOWN", "selectNextRow",
+ "KP_LEFT", "selectPreviousColumn",
+ "KP_RIGHT", "selectNextColumn",
+ "shift TAB", "selectPreviousColumnCell",
+ "ctrl A", "selectAll",
+ "shift ENTER", "selectPreviousRowCell",
+ "shift KP_DOWN", "selectNextRowExtendSelection",
+ "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ESCAPE", "cancel",
+ "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
+ "shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl PAGE_UP", "scrollLeftChangeSelection",
+ "shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
+ "ctrl PAGE_DOWN", "scrollRightChangeSelection",
+ "PAGE_UP", "scrollUpChangeSelection",
+ "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift UP", "selectPreviousRowExtendSelection",
+ "ctrl shift RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift DOWN", "selectNextRowExtendSelection",
+ "ctrl BACK_SLASH", "clearSelection",
+ "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl SLASH", "selectAll",
+ "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
+ }),
+ "Table.background", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "Table.focusCellBackground", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "Table.focusCellForeground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
+ "Table.focusCellHighlightBorder",
+ new BorderUIResource.LineBorderUIResource(
+ new ColorUIResource(255, 255, 0)),
+ "Table.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Table.foreground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
+ "Table.gridColor", new ColorUIResource(new ColorUIResource(128, 128, 128)),
+ "Table.scrollPaneBorder", new BorderUIResource.BevelBorderUIResource(0),
+ "Table.selectionBackground", new ColorUIResource(new ColorUIResource(0, 0, 128)),
+ "Table.selectionForeground", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "TableHeader.background", new ColorUIResource(new ColorUIResource(192, 192, 192)),
+ "TableHeader.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TableHeader.foreground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
+
+ "TextArea.background", new ColorUIResource(light),
+ "TextArea.border", new BorderUIResource(BasicBorders.getMarginBorder()),
+ "TextArea.caretBlinkRate", new Integer(500),
+ "TextArea.caretForeground", new ColorUIResource(Color.black),
+ "TextArea.font", new FontUIResource("MonoSpaced", Font.PLAIN, 12),
+ "TextArea.foreground", new ColorUIResource(Color.black),
+ "TextArea.inactiveForeground", new ColorUIResource(Color.gray),
+ "TextArea.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("shift UP"), "selection-up",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("shift KP_UP"), "selection-up",
+ KeyStroke.getKeyStroke("DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("shift ctrl T"), "previous-link-action",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("shift PAGE_UP"), "selection-page-up",
+ KeyStroke.getKeyStroke("KP_UP"), "caret-up",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("ctrl HOME"), "caret-begin",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("ctrl END"), "caret-end",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("ctrl SPACE"), "activate-link-action",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ENTER"), "insert-break",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_UP"), "selection-page-left",
+ KeyStroke.getKeyStroke("shift DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("PAGE_DOWN"), "page-down",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_DOWN"), "selection-page-right",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("KP_DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("shift ctrl END"), "selection-end",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl T"), "next-link-action",
+ KeyStroke.getKeyStroke("shift KP_DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("TAB"), "insert-tab",
+ KeyStroke.getKeyStroke("UP"), "caret-up",
+ KeyStroke.getKeyStroke("shift ctrl HOME"), "selection-begin",
+ KeyStroke.getKeyStroke("shift PAGE_DOWN"), "selection-page-down",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("PAGE_UP"), "page-up",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard"
+ }),
+ "TextArea.margin", new InsetsUIResource(0, 0, 0, 0),
+ "TextArea.selectionBackground", new ColorUIResource(Color.black),
+ "TextArea.selectionForeground", new ColorUIResource(Color.white),
+ "TextField.background", new ColorUIResource(light),
+ "TextField.border", new BasicBorders.FieldBorder(null, null, null, null),
+ "TextField.caretBlinkRate", new Integer(500),
+ "TextField.caretForeground", new ColorUIResource(Color.black),
+ "TextField.darkShadow", new ColorUIResource(shadow),
+ "TextField.font", new FontUIResource("SansSerif", Font.PLAIN, 12),
+ "TextField.foreground", new ColorUIResource(Color.black),
+ "TextField.highlight", new ColorUIResource(highLight),
+ "TextField.inactiveBackground", new ColorUIResource(Color.LIGHT_GRAY),
+ "TextField.inactiveForeground", new ColorUIResource(Color.GRAY),
+ "TextField.light", new ColorUIResource(highLight),
+ "TextField.highlight", new ColorUIResource(light),
+ "TextField.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("ENTER"), "notify-field-accept",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-next-word"
+ }),
+ "TextField.margin", new InsetsUIResource(0, 0, 0, 0),
+ "TextField.selectionBackground", new ColorUIResource(Color.black),
+ "TextField.selectionForeground", new ColorUIResource(Color.white),
+ "TextPane.background", new ColorUIResource(Color.white),
+ "TextPane.border", BasicBorders.getMarginBorder(),
+ "TextPane.caretBlinkRate", new Integer(500),
+ "TextPane.caretForeground", new ColorUIResource(Color.black),
+ "TextPane.font", new FontUIResource("Serif", Font.PLAIN, 12),
+ "TextPane.foreground", new ColorUIResource(Color.black),
+ "TextPane.inactiveForeground", new ColorUIResource(Color.gray),
+ "TextPane.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("shift UP"), "selection-up",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift ctrl LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("shift KP_UP"), "selection-up",
+ KeyStroke.getKeyStroke("DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("shift ctrl T"), "previous-link-action",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("CUT"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("END"), "caret-end-line",
+ KeyStroke.getKeyStroke("shift PAGE_UP"), "selection-page-up",
+ KeyStroke.getKeyStroke("KP_UP"), "caret-up",
+ KeyStroke.getKeyStroke("DELETE"), "delete-next",
+ KeyStroke.getKeyStroke("ctrl HOME"), "caret-begin",
+ KeyStroke.getKeyStroke("shift LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("ctrl END"), "caret-end",
+ KeyStroke.getKeyStroke("BACK_SPACE"), "delete-previous",
+ KeyStroke.getKeyStroke("shift ctrl RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("KP_LEFT"), "caret-backward",
+ KeyStroke.getKeyStroke("shift KP_RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("ctrl SPACE"), "activate-link-action",
+ KeyStroke.getKeyStroke("ctrl H"), "delete-previous",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "unselect",
+ KeyStroke.getKeyStroke("ENTER"), "insert-break",
+ KeyStroke.getKeyStroke("shift HOME"), "selection-begin-line",
+ KeyStroke.getKeyStroke("RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_UP"), "selection-page-left",
+ KeyStroke.getKeyStroke("shift DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("PAGE_DOWN"), "page-down",
+ KeyStroke.getKeyStroke("shift KP_LEFT"), "selection-backward",
+ KeyStroke.getKeyStroke("shift ctrl O"), "toggle-componentOrientation",
+ KeyStroke.getKeyStroke("ctrl X"), "cut-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_DOWN"), "selection-page-right",
+ KeyStroke.getKeyStroke("ctrl C"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "caret-next-word",
+ KeyStroke.getKeyStroke("shift END"), "selection-end-line",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "caret-previous-word",
+ KeyStroke.getKeyStroke("HOME"), "caret-begin-line",
+ KeyStroke.getKeyStroke("ctrl V"), "paste-from-clipboard",
+ KeyStroke.getKeyStroke("KP_DOWN"), "caret-down",
+ KeyStroke.getKeyStroke("ctrl A"), "select-all",
+ KeyStroke.getKeyStroke("shift RIGHT"), "selection-forward",
+ KeyStroke.getKeyStroke("shift ctrl END"), "selection-end",
+ KeyStroke.getKeyStroke("COPY"), "copy-to-clipboard",
+ KeyStroke.getKeyStroke("shift ctrl KP_LEFT"), "selection-previous-word",
+ KeyStroke.getKeyStroke("ctrl T"), "next-link-action",
+ KeyStroke.getKeyStroke("shift KP_DOWN"), "selection-down",
+ KeyStroke.getKeyStroke("TAB"), "insert-tab",
+ KeyStroke.getKeyStroke("UP"), "caret-up",
+ KeyStroke.getKeyStroke("shift ctrl HOME"), "selection-begin",
+ KeyStroke.getKeyStroke("shift PAGE_DOWN"), "selection-page-down",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "caret-forward",
+ KeyStroke.getKeyStroke("shift ctrl KP_RIGHT"), "selection-next-word",
+ KeyStroke.getKeyStroke("PAGE_UP"), "page-up",
+ KeyStroke.getKeyStroke("PASTE"), "paste-from-clipboard"
+ }),
+ "TextPane.margin", new InsetsUIResource(3, 3, 3, 3),
+ "TextPane.selectionBackground", new ColorUIResource(Color.black),
+ "TextPane.selectionForeground", new ColorUIResource(Color.white),
+ "TitledBorder.border", new BorderUIResource.EtchedBorderUIResource(),
+ "TitledBorder.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TitledBorder.titleColor", new ColorUIResource(darkShadow),
+ "ToggleButton.background", new ColorUIResource(light),
+ "ToggleButton.border",
+ new BorderUIResource.CompoundBorderUIResource(null, null),
+ "ToggleButton.darkShadow", new ColorUIResource(shadow),
+ "ToggleButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("SPACE"), "pressed",
+ KeyStroke.getKeyStroke("released SPACE"), "released"
+ }),
+ "ToggleButton.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ToggleButton.foreground", new ColorUIResource(darkShadow),
+ "ToggleButton.highlight", new ColorUIResource(highLight),
+ "ToggleButton.light", new ColorUIResource(light),
+ "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
+ "ToggleButton.shadow", new ColorUIResource(shadow),
+ "ToggleButton.textIconGap", new Integer(4),
+ "ToggleButton.textShiftOffset", new Integer(0),
+ "ToolBar.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "UP", "navigateUp",
+ "KP_UP", "navigateUp",
+ "DOWN", "navigateDown",
+ "KP_DOWN", "navigateDown",
+ "LEFT", "navigateLeft",
+ "KP_LEFT", "navigateLeft",
+ "RIGHT", "navigateRight",
+ "KP_RIGHT", "navigateRight"
+ }),
+ "ToolBar.background", new ColorUIResource(light),
+ "ToolBar.border", new BorderUIResource.EtchedBorderUIResource(),
+ "ToolBar.darkShadow", new ColorUIResource(shadow),
+ "ToolBar.dockingBackground", new ColorUIResource(light),
+ "ToolBar.dockingForeground", new ColorUIResource(Color.red),
+ "ToolBar.floatingBackground", new ColorUIResource(light),
+ "ToolBar.floatingForeground", new ColorUIResource(Color.darkGray),
+ "ToolBar.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ToolBar.foreground", new ColorUIResource(darkShadow),
+ "ToolBar.highlight", new ColorUIResource(highLight),
+ "ToolBar.light", new ColorUIResource(highLight),
+ "ToolBar.separatorSize", new DimensionUIResource(10, 10),
+ "ToolBar.shadow", new ColorUIResource(shadow),
+ "ToolTip.background", new ColorUIResource(light),
+ "ToolTip.border", new BorderUIResource.LineBorderUIResource(Color.lightGray),
+ "ToolTip.font", new FontUIResource("SansSerif", Font.PLAIN, 12),
+ "ToolTip.foreground", new ColorUIResource(darkShadow),
+ "Tree.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "cancel"
+ }),
+ "Tree.background", new ColorUIResource(new Color(255, 255, 255)),
+ "Tree.changeSelectionWithFocus", Boolean.TRUE,
+ "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
+ "Tree.editorBorder", new BorderUIResource.LineBorderUIResource(Color.lightGray),
+ "Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ KeyStroke.getKeyStroke("ctrl DOWN"), "selectNextChangeLead",
+ KeyStroke.getKeyStroke("shift UP"), "selectPreviousExtendSelection",
+ KeyStroke.getKeyStroke("ctrl RIGHT"), "scrollRight",
+ KeyStroke.getKeyStroke("shift KP_UP"), "selectPreviousExtendSelection",
+ KeyStroke.getKeyStroke("DOWN"), "selectNext",
+ KeyStroke.getKeyStroke("ctrl UP"), "selectPreviousChangeLead",
+ KeyStroke.getKeyStroke("ctrl LEFT"), "scrollLeft",
+ KeyStroke.getKeyStroke("CUT"), "cut",
+ KeyStroke.getKeyStroke("END"), "selectLast",
+ KeyStroke.getKeyStroke("shift PAGE_UP"), "scrollUpExtendSelection",
+ KeyStroke.getKeyStroke("KP_UP"), "selectPrevious",
+ KeyStroke.getKeyStroke("shift ctrl UP"), "selectPreviousExtendSelection",
+ KeyStroke.getKeyStroke("ctrl HOME"), "selectFirstChangeLead",
+ KeyStroke.getKeyStroke("ctrl END"), "selectLastChangeLead",
+ KeyStroke.getKeyStroke("ctrl PAGE_DOWN"), "scrollDownChangeLead",
+ KeyStroke.getKeyStroke("LEFT"), "selectParent",
+ KeyStroke.getKeyStroke("ctrl PAGE_UP"), "scrollUpChangeLead",
+ KeyStroke.getKeyStroke("KP_LEFT"), "selectParent",
+ KeyStroke.getKeyStroke("SPACE"), "addToSelection",
+ KeyStroke.getKeyStroke("ctrl SPACE"), "toggleAndAnchor",
+ KeyStroke.getKeyStroke("shift SPACE"), "extendTo",
+ KeyStroke.getKeyStroke("shift ctrl SPACE"), "moveSelectionTo",
+ KeyStroke.getKeyStroke("ADD"), "expand",
+ KeyStroke.getKeyStroke("ctrl BACK_SLASH"), "clearSelection",
+ KeyStroke.getKeyStroke("shift ctrl DOWN"), "selectNextExtendSelection",
+ KeyStroke.getKeyStroke("shift HOME"), "selectFirstExtendSelection",
+ KeyStroke.getKeyStroke("RIGHT"), "selectChild",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_UP"), "scrollUpExtendSelection",
+ KeyStroke.getKeyStroke("shift DOWN"), "selectNextExtendSelection",
+ KeyStroke.getKeyStroke("PAGE_DOWN"), "scrollDownChangeSelection",
+ KeyStroke.getKeyStroke("shift ctrl KP_UP"), "selectPreviousExtendSelection",
+ KeyStroke.getKeyStroke("SUBTRACT"), "collapse",
+ KeyStroke.getKeyStroke("ctrl X"), "cut",
+ KeyStroke.getKeyStroke("shift ctrl PAGE_DOWN"), "scrollDownExtendSelection",
+ KeyStroke.getKeyStroke("ctrl SLASH"), "selectAll",
+ KeyStroke.getKeyStroke("ctrl C"), "copy",
+ KeyStroke.getKeyStroke("ctrl KP_RIGHT"), "scrollRight",
+ KeyStroke.getKeyStroke("shift END"), "selectLastExtendSelection",
+ KeyStroke.getKeyStroke("shift ctrl KP_DOWN"), "selectNextExtendSelection",
+ KeyStroke.getKeyStroke("ctrl KP_LEFT"), "scrollLeft",
+ KeyStroke.getKeyStroke("HOME"), "selectFirst",
+ KeyStroke.getKeyStroke("ctrl V"), "paste",
+ KeyStroke.getKeyStroke("KP_DOWN"), "selectNext",
+ KeyStroke.getKeyStroke("ctrl A"), "selectAll",
+ KeyStroke.getKeyStroke("ctrl KP_DOWN"), "selectNextChangeLead",
+ KeyStroke.getKeyStroke("shift ctrl END"), "selectLastExtendSelection",
+ KeyStroke.getKeyStroke("COPY"), "copy",
+ KeyStroke.getKeyStroke("ctrl KP_UP"), "selectPreviousChangeLead",
+ KeyStroke.getKeyStroke("shift KP_DOWN"), "selectNextExtendSelection",
+ KeyStroke.getKeyStroke("UP"), "selectPrevious",
+ KeyStroke.getKeyStroke("shift ctrl HOME"), "selectFirstExtendSelection",
+ KeyStroke.getKeyStroke("shift PAGE_DOWN"), "scrollDownExtendSelection",
+ KeyStroke.getKeyStroke("KP_RIGHT"), "selectChild",
+ KeyStroke.getKeyStroke("F2"), "startEditing",
+ KeyStroke.getKeyStroke("PAGE_UP"), "scrollUpChangeSelection",
+ KeyStroke.getKeyStroke("PASTE"), "paste"
+ }),
+ "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Tree.foreground", new ColorUIResource(Color.black),
+ "Tree.hash", new ColorUIResource(new Color(184, 207, 228)),
+ "Tree.leftChildIndent", new Integer(7),
+ "Tree.rightChildIndent", new Integer(13),
+ "Tree.rowHeight", new Integer(16),
+ "Tree.scrollsOnExpand", Boolean.TRUE,
+ "Tree.selectionBackground", new ColorUIResource(Color.black),
+ "Tree.nonSelectionBackground", new ColorUIResource(new Color(255, 255, 255)),
+ "Tree.selectionBorderColor", new ColorUIResource(Color.black),
+ "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(Color.black),
+ "Tree.selectionForeground", new ColorUIResource(new Color(255, 255, 255)),
+ "Viewport.background", new ColorUIResource(light),
+ "Viewport.foreground", new ColorUIResource(Color.black),
+ "Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)
+ };
+ defaults.putDefaults(uiDefaults);
+ }
+
+ /**
+ * Returns the <code>ActionMap</code> that stores all the actions that are
+ * responsibly for rendering auditory cues.
+ *
+ * @return the action map that stores all the actions that are
+ * responsibly for rendering auditory cues
+ *
+ * @see #createAudioAction
+ * @see #playSound
+ *
+ * @since 1.4
+ */
+ protected ActionMap getAudioActionMap()
+ {
+ if (audioActionMap != null)
+ audioActionMap = new ActionMap();
+ return audioActionMap;
+ }
+
+ /**
+ * Creates an <code>Action</code> that can play an auditory cue specified by
+ * the key. The UIDefaults value for the key is normally a String that points
+ * to an audio file relative to the current package.
+ *
+ * @param key a UIDefaults key that specifies the sound
+ *
+ * @return an action that can play the sound
+ *
+ * @see #playSound
+ *
+ * @since 1.4
+ */
+ protected Action createAudioAction(Object key)
+ {
+ return new AudioAction(key);
+ }
+
+ /**
+ * Plays the sound of the action if it is listed in
+ * <code>AuditoryCues.playList</code>.
+ *
+ * @param audioAction the audio action to play
+ *
+ * @since 1.4
+ */
+ protected void playSound(Action audioAction)
+ {
+ if (audioAction instanceof AudioAction)
+ {
+ Object[] playList = (Object[]) UIManager.get("AuditoryCues.playList");
+ for (int i = 0; i < playList.length; ++i)
+ {
+ if (playList[i].equals(((AudioAction) audioAction).key))
+ {
+ ActionEvent ev = new ActionEvent(this,
+ ActionEvent.ACTION_PERFORMED,
+ (String) playList[i]);
+ audioAction.actionPerformed(ev);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Initializes the Look and Feel.
+ */
+ public void initialize()
+ {
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ popupHelper = new PopupHelper();
+ toolkit.addAWTEventListener(popupHelper, AWTEvent.MOUSE_EVENT_MASK);
+ }
+
+ /**
+ * Uninitializes the Look and Feel.
+ */
+ public void uninitialize()
+ {
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ toolkit.removeAWTEventListener(popupHelper);
+ popupHelper = null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,481 @@
+/* BasicMenuBarUI.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.BoxLayout;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuBarUI;
+
+/**
+ * UI Delegate for JMenuBar.
+ */
+public class BasicMenuBarUI extends MenuBarUI
+{
+
+ /**
+ * This action is performed for the action command 'takeFocus'.
+ */
+ private static class FocusAction
+ extends AbstractAction
+ {
+
+ /**
+ * Creates a new FocusAction.
+ */
+ FocusAction()
+ {
+ super("takeFocus");
+ }
+
+ /**
+ * Performs the action.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ // In the JDK this action seems to pop up the first menu of the
+ // menu bar.
+ JMenuBar menuBar = (JMenuBar) event.getSource();
+ MenuSelectionManager defaultManager =
+ MenuSelectionManager.defaultManager();
+ MenuElement me[];
+ MenuElement subElements[];
+ JMenu menu = menuBar.getMenu(0);
+ if (menu != null)
+ {
+ me = new MenuElement[3];
+ me[0] = (MenuElement) menuBar;
+ me[1] = (MenuElement) menu;
+ me[2] = (MenuElement) menu.getPopupMenu();
+ defaultManager.setSelectedPath(me);
+ }
+ }
+
+ }
+
+ protected ChangeListener changeListener;
+
+ /*ContainerListener that listens to the ContainerEvents fired from menu bar*/
+ protected ContainerListener containerListener;
+
+ /*Property change listeners that listener to PropertyChangeEvent from menu bar*/
+ private PropertyChangeListener propertyChangeListener;
+
+ /* menu bar for which this UI delegate is for*/
+ protected JMenuBar menuBar;
+
+ /* MouseListener that listens to the mouseEvents fired from menu bar*/
+ private MouseInputListener mouseListener;
+
+ /**
+ * Creates a new BasicMenuBarUI object.
+ */
+ public BasicMenuBarUI()
+ {
+ changeListener = createChangeListener();
+ containerListener = createContainerListener();
+ propertyChangeListener = new PropertyChangeHandler();
+ mouseListener = new MouseInputHandler();
+ }
+
+ /**
+ * Creates ChangeListener
+ *
+ * @return The ChangeListener
+ */
+ protected ChangeListener createChangeListener()
+ {
+ return new ChangeHandler();
+ }
+
+ /**
+ * Creates ContainerListener() to listen for ContainerEvents
+ * fired by JMenuBar.
+ *
+ * @return The ContainerListener
+ */
+ protected ContainerListener createContainerListener()
+ {
+ return new ContainerHandler();
+ }
+
+ /**
+ * Factory method to create a BasicMenuBarUI for the given {@link
+ * JComponent}, which should be a {@link JMenuBar}.
+ *
+ * @param x The {@link JComponent} a UI is being created for.
+ *
+ * @return A BasicMenuBarUI for the {@link JComponent}.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicMenuBarUI();
+ }
+
+ /**
+ * Returns maximum size for the specified menu bar
+ *
+ * @param c component for which to get maximum size
+ *
+ * @return Maximum size for the specified menu bar
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ // let layout manager calculate its size
+ return null;
+ }
+
+ /**
+ * Returns maximum allowed size of JMenuBar.
+ *
+ * @param c menuBar for which to return maximum size
+ *
+ * @return Maximum size of the give menu bar.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ // let layout manager calculate its size
+ return null;
+ }
+
+ /**
+ * Returns preferred size of JMenuBar.
+ *
+ * @param c menuBar for which to return preferred size
+ *
+ * @return Preferred size of the give menu bar.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ // let layout manager calculate its size
+ return null;
+ }
+
+ /**
+ * Initializes any default properties that this UI has from the defaults for
+ * the Basic look and feel.
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installBorder(menuBar, "MenuBar.border");
+ LookAndFeel.installColorsAndFont(menuBar, "MenuBar.background",
+ "MenuBar.foreground", "MenuBar.font");
+ menuBar.setOpaque(true);
+ }
+
+ /**
+ * This method installs the keyboard actions for the JMenuBar.
+ */
+ protected void installKeyboardActions()
+ {
+ // Install InputMap.
+ Object[] bindings =
+ (Object[]) SharedUIDefaults.get("MenuBar.windowBindings");
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(menuBar, bindings);
+ SwingUtilities.replaceUIInputMap(menuBar,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // Install ActionMap.
+ SwingUtilities.replaceUIActionMap(menuBar, getActionMap());
+ }
+
+ /**
+ * Creates and returns the shared action map for JTrees.
+ *
+ * @return the shared action map for JTrees
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("MenuBar.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("MenuBar.actionMap", am);
+ }
+ return am;
+ }
+
+ /**
+ * Creates the default actions when there are none specified by the L&F.
+ *
+ * @return the default actions
+ */
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new FocusAction();
+ am.put(action.getValue(Action.NAME), action);
+ return am;
+ }
+
+ /**
+ * This method installs the listeners needed for this UI to function.
+ */
+ protected void installListeners()
+ {
+ menuBar.addContainerListener(containerListener);
+ menuBar.addPropertyChangeListener(propertyChangeListener);
+ menuBar.addMouseListener(mouseListener);
+ }
+
+ /**
+ * Installs and initializes all fields for this UI delegate. Any properties
+ * of the UI that need to be initialized and/or set to defaults will be
+ * done now. It will also install any listeners necessary.
+ *
+ * @param c The {@link JComponent} that is having this UI installed.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ menuBar = (JMenuBar) c;
+ menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.X_AXIS));
+ installDefaults();
+ installListeners();
+ installKeyboardActions();
+ }
+
+ /**
+ * This method uninstalls the defaults and nulls any objects created during
+ * install.
+ */
+ protected void uninstallDefaults()
+ {
+ menuBar.setBackground(null);
+ menuBar.setBorder(null);
+ menuBar.setFont(null);
+ menuBar.setForeground(null);
+ }
+
+ /**
+ * This method reverses the work done in installKeyboardActions.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ SwingUtilities.replaceUIInputMap(menuBar,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, null);
+ SwingUtilities.replaceUIActionMap(menuBar, null);
+ }
+
+ /**
+ * Unregisters all the listeners that this UI delegate was using.
+ */
+ protected void uninstallListeners()
+ {
+ menuBar.removeContainerListener(containerListener);
+ menuBar.removePropertyChangeListener(propertyChangeListener);
+ menuBar.removeMouseListener(mouseListener);
+ }
+
+ /**
+ * Performs the opposite of installUI. Any properties or resources that need
+ * to be cleaned up will be done now. It will also uninstall any listeners
+ * it has. In addition, any properties of this UI will be nulled.
+ *
+ * @param c The {@link JComponent} that is having this UI uninstalled.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults();
+ uninstallListeners();
+ uninstallKeyboardActions();
+ menuBar = null;
+ }
+
+ private class ChangeHandler implements ChangeListener
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ // TODO: What should be done here, if anything?
+ }
+ }
+
+ /**
+ * This class handles ContainerEvents fired by JMenuBar. It revalidates
+ * and repaints menu bar whenever menu is added or removed from it.
+ */
+ private class ContainerHandler implements ContainerListener
+ {
+ /**
+ * This method is called whenever menu is added to the menu bar
+ *
+ * @param e The ContainerEvent.
+ */
+ public void componentAdded(ContainerEvent e)
+ {
+ menuBar.revalidate();
+ menuBar.repaint();
+ }
+
+ /**
+ * This method is called whenever menu is removed from the menu bar.
+ *
+ * @param e The ContainerEvent.
+ */
+ public void componentRemoved(ContainerEvent e)
+ {
+ menuBar.revalidate();
+ menuBar.repaint();
+ }
+ }
+
+ /**
+ * This class handles PropertyChangeEvents fired from the JMenuBar
+ */
+ private class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * This method is called whenever one of the properties of the MenuBar
+ * changes.
+ *
+ * @param e The PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("borderPainted"))
+ menuBar.repaint();
+ if (e.getPropertyName().equals("margin"))
+ menuBar.repaint();
+ }
+ }
+
+ private class MouseInputHandler implements MouseInputListener
+ {
+ /**
+ * Handles mouse clicked event
+ *
+ * @param e Mouse event
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ MenuElement[] me = menuBar.getSubElements();
+
+ for (int i = 0; i < me.length; i++)
+ {
+ JMenu menu = menuBar.getMenu(i);
+ if (menu != null)
+ menu.setSelected(false);
+ }
+ }
+
+ /**
+ * Handles mouse pressed event
+ *
+ * @param e Mouse event
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Handles mouse released event
+ *
+ * @param e Mouse event
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Handles mouse exited event
+ *
+ * @param e Mouse event
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Handles mouse dragged event
+ *
+ * @param e Mouse event
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Handles mouse moved event
+ *
+ * @param e Mouse event
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Handles mouse entered event
+ *
+ * @param e Mouse event
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1375 @@
+/* BasicMenuItemUI.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import gnu.classpath.SystemProperties;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
+import javax.swing.ActionMap;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
+import javax.swing.InputMap;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.MenuDragMouseEvent;
+import javax.swing.event.MenuDragMouseListener;
+import javax.swing.event.MenuKeyEvent;
+import javax.swing.event.MenuKeyListener;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentInputMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuItemUI;
+import javax.swing.text.View;
+
+/**
+ * UI Delegate for JMenuItem.
+ */
+public class BasicMenuItemUI extends MenuItemUI
+{
+ /**
+ * Font to be used when displaying menu item's accelerator.
+ */
+ protected Font acceleratorFont;
+
+ /**
+ * Color to be used when displaying menu item's accelerator.
+ */
+ protected Color acceleratorForeground;
+
+ /**
+ * Color to be used when displaying menu item's accelerator when menu item is
+ * selected.
+ */
+ protected Color acceleratorSelectionForeground;
+
+ /**
+ * Icon that is displayed after the text to indicated that this menu contains
+ * submenu.
+ */
+ protected Icon arrowIcon;
+
+ /**
+ * Icon that is displayed before the text. This icon is only used in
+ * JCheckBoxMenuItem or JRadioBoxMenuItem.
+ */
+ protected Icon checkIcon;
+
+ /**
+ * Number of spaces between icon and text.
+ */
+ protected int defaultTextIconGap = 4;
+
+ /**
+ * Color of the text when menu item is disabled
+ */
+ protected Color disabledForeground;
+
+ /**
+ * The menu Drag mouse listener listening to the menu item.
+ */
+ protected MenuDragMouseListener menuDragMouseListener;
+
+ /**
+ * The menu item itself
+ */
+ protected JMenuItem menuItem;
+
+ /**
+ * Menu Key listener listening to the menu item.
+ */
+ protected MenuKeyListener menuKeyListener;
+
+ /**
+ * mouse input listener listening to menu item.
+ */
+ protected MouseInputListener mouseInputListener;
+
+ /**
+ * Indicates if border should be painted
+ */
+ protected boolean oldBorderPainted;
+
+ /**
+ * Color of text that is used when menu item is selected
+ */
+ protected Color selectionBackground;
+
+ /**
+ * Color of the text that is used when menu item is selected.
+ */
+ protected Color selectionForeground;
+
+ /**
+ * String that separates description of the modifiers and the key
+ */
+ private String acceleratorDelimiter;
+
+ /**
+ * ItemListener to listen for item changes in the menu item
+ */
+ private ItemListener itemListener;
+
+ /**
+ * Number of spaces between accelerator and menu item's label.
+ */
+ private int defaultAcceleratorLabelGap = 10;
+
+ /**
+ * The gap between different menus on the MenuBar.
+ */
+ private int MenuGap = 10;
+
+ /** A PropertyChangeListener to make UI updates after property changes **/
+ PropertyChangeHandler propertyChangeListener;
+
+ /**
+ * The view rectangle used for layout of the menu item.
+ */
+ private Rectangle viewRect;
+
+ /**
+ * The rectangle that holds the area of the label.
+ */
+ private Rectangle textRect;
+
+ /**
+ * The rectangle that holds the area of the accelerator.
+ */
+ private Rectangle accelRect;
+
+ /**
+ * The rectangle that holds the area of the icon.
+ */
+ private Rectangle iconRect;
+
+ /**
+ * The rectangle that holds the area of the icon.
+ */
+ private Rectangle arrowIconRect;
+
+ /**
+ * The rectangle that holds the area of the check icon.
+ */
+ private Rectangle checkIconRect;
+
+ /**
+ * A rectangle used for temporary storage to avoid creation of new
+ * rectangles.
+ */
+ private Rectangle cachedRect;
+
+ /**
+ * A class to handle PropertChangeEvents for the JMenuItem
+ * @author Anthony Balkissoon abalkiss at redhat dot com.
+ */
+ class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * This method is called when a property of the menuItem is changed.
+ * Currently it is only used to update the accelerator key bindings.
+ *
+ * @param e
+ * the PropertyChangeEvent
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ String property = e.getPropertyName();
+ if (property.equals("accelerator"))
+ {
+ InputMap map = SwingUtilities.getUIInputMap(menuItem,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ if (map != null)
+ map.remove((KeyStroke) e.getOldValue());
+ else
+ map = new ComponentInputMapUIResource(menuItem);
+
+ KeyStroke accelerator = (KeyStroke) e.getNewValue();
+ if (accelerator != null)
+ map.put(accelerator, "doClick");
+ }
+ // TextLayout caching for speed-up drawing of text.
+ else if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+ || property.equals("font"))
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+ == null)
+
+ {
+ AbstractButton b = (AbstractButton) e.getSource();
+ String text = b.getText();
+ if (text == null)
+ text = "";
+ FontRenderContext frc = new FontRenderContext(new AffineTransform(),
+ false, false);
+ TextLayout layout = new TextLayout(text, b.getFont(), frc);
+ b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
+ }
+ }
+ }
+
+ /**
+ * A class to handle accelerator keys. This is the Action we will
+ * perform when the accelerator key for this JMenuItem is pressed.
+ * @author Anthony Balkissoon abalkiss at redhat dot com
+ *
+ */
+ class ClickAction extends AbstractAction
+ {
+ /**
+ * This is what is done when the accelerator key for the JMenuItem is
+ * pressed.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ doClick(MenuSelectionManager.defaultManager());
+ }
+ }
+
+ /**
+ * Creates a new BasicMenuItemUI object.
+ */
+ public BasicMenuItemUI()
+ {
+ mouseInputListener = createMouseInputListener(menuItem);
+ menuDragMouseListener = createMenuDragMouseListener(menuItem);
+ menuKeyListener = createMenuKeyListener(menuItem);
+ itemListener = new ItemHandler();
+ propertyChangeListener = new PropertyChangeHandler();
+
+ // Initialize rectangles for layout.
+ viewRect = new Rectangle();
+ textRect = new Rectangle();
+ iconRect = new Rectangle();
+ arrowIconRect = new Rectangle();
+ checkIconRect = new Rectangle();
+ accelRect = new Rectangle();
+ cachedRect = new Rectangle();
+ }
+
+ /**
+ * Create MenuDragMouseListener to listen for mouse dragged events.
+ *
+ * @param c
+ * menu item to listen to
+ * @return The MenuDragMouseListener
+ */
+ protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
+ {
+ return new MenuDragMouseHandler();
+ }
+
+ /**
+ * Creates MenuKeyListener to listen to key events occuring when menu item is
+ * visible on the screen.
+ *
+ * @param c
+ * menu item to listen to
+ * @return The MenuKeyListener
+ */
+ protected MenuKeyListener createMenuKeyListener(JComponent c)
+ {
+ return new MenuKeyHandler();
+ }
+
+ /**
+ * Handles mouse input events occuring for this menu item
+ *
+ * @param c
+ * menu item to listen to
+ * @return The MouseInputListener
+ */
+ protected MouseInputListener createMouseInputListener(JComponent c)
+ {
+ return new MouseInputHandler();
+ }
+
+ /**
+ * Factory method to create a BasicMenuItemUI for the given {@link
+ * JComponent}, which should be a {@link JMenuItem}.
+ *
+ * @param c
+ * The {@link JComponent} a UI is being created for.
+ * @return A BasicMenuItemUI for the {@link JComponent}.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicMenuItemUI();
+ }
+
+ /**
+ * Programatically clicks menu item.
+ *
+ * @param msm
+ * MenuSelectionManager for the menu hierarchy
+ */
+ protected void doClick(MenuSelectionManager msm)
+ {
+ menuItem.doClick();
+ msm.clearSelectedPath();
+ }
+
+ /**
+ * Returns maximum size for the specified menu item
+ *
+ * @param c
+ * component for which to get maximum size
+ * @return Maximum size for the specified menu item.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return null;
+ }
+
+ /**
+ * Returns minimum size for the specified menu item
+ *
+ * @param c
+ * component for which to get minimum size
+ * @return Minimum size for the specified menu item.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return null;
+ }
+
+ /**
+ * Returns path to this menu item.
+ *
+ * @return $MenuElement[]$ Returns array of menu elements that constitute a
+ * path to this menu item.
+ */
+ public MenuElement[] getPath()
+ {
+ ArrayList path = new ArrayList();
+
+ // Path to menu should also include its popup menu.
+ if (menuItem instanceof JMenu)
+ path.add(((JMenu) menuItem).getPopupMenu());
+
+ Component c = menuItem;
+ while (c instanceof MenuElement)
+ {
+ path.add(0, (MenuElement) c);
+
+ if (c instanceof JPopupMenu)
+ c = ((JPopupMenu) c).getInvoker();
+ else
+ c = c.getParent();
+ }
+
+ MenuElement[] pathArray = new MenuElement[path.size()];
+ path.toArray(pathArray);
+ return pathArray;
+ }
+
+ /**
+ * Returns preferred size for the given menu item.
+ *
+ * @param c
+ * menu item for which to get preferred size
+ * @param checkIcon
+ * check icon displayed in the given menu item
+ * @param arrowIcon
+ * arrow icon displayed in the given menu item
+ * @param defaultTextIconGap
+ * space between icon and text in the given menuItem
+ * @return $Dimension$ preferred size for the given menu item
+ */
+ protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,
+ Icon arrowIcon,
+ int defaultTextIconGap)
+ {
+ JMenuItem m = (JMenuItem) c;
+ String accelText = getAcceleratorString(m);
+
+ // Layout the menu item. The result gets stored in the rectangle
+ // fields of this class.
+ layoutMenuItem(m, accelText);
+
+ // The union of the text and icon areas is the label area.
+ cachedRect.setBounds(textRect);
+ Rectangle pref = SwingUtilities.computeUnion(iconRect.x, iconRect.y,
+ iconRect.width,
+ iconRect.height,
+ cachedRect);
+
+ // Find the widest menu item text and accelerator and store it in
+ // client properties of the parent, so that we can align the accelerators
+ // properly. Of course, we only need can do this, if the parent is
+ // a JComponent and this menu item is not a toplevel menu.
+ Container parent = m.getParent();
+ if (parent != null && parent instanceof JComponent
+ && !(m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ JComponent p = (JComponent) parent;
+
+ // The widest text so far.
+ Integer maxTextWidth = (Integer) p.getClientProperty("maxTextWidth");
+ int maxTextValue = maxTextWidth == null ? 0 : maxTextWidth.intValue();
+ if (pref.width < maxTextValue)
+ pref.width = maxTextValue;
+ else
+ p.putClientProperty("maxTextWidth", new Integer(pref.width));
+
+ // The widest accelerator so far.
+ Integer maxAccelWidth = (Integer) p.getClientProperty("maxAccelWidth");
+ int maxAccelValue = maxAccelWidth == null ? 0
+ : maxAccelWidth.intValue();
+ if (accelRect.width > maxAccelValue)
+ {
+ maxAccelValue = accelRect.width;
+ p.putClientProperty("maxAccelWidth", new Integer(accelRect.width));
+ }
+ pref.width += maxAccelValue;
+ pref.width += defaultTextIconGap;
+ }
+
+ // Add arrow and check size if appropriate.
+ if (! (m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ pref.width += checkIconRect.width;
+ pref.width += defaultTextIconGap;
+ pref.width += arrowIconRect.width;
+ pref.width += defaultTextIconGap;
+ }
+
+ // Add a gap ~2 times as wide as the defaultTextIconGap.
+ pref.width += 2 * defaultTextIconGap;
+
+ // Respect the insets of the menu item.
+ Insets i = m.getInsets();
+ pref.width += i.left + i.right;
+ pref.height += i.top + i.bottom;
+
+ // Return a copy, so that nobody messes with our textRect.
+ return pref.getSize();
+ }
+
+ /**
+ * Returns preferred size of the given component
+ *
+ * @param c
+ * component for which to return preferred size
+ * @return $Dimension$ preferred size for the given component
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return getPreferredMenuItemSize(c, checkIcon, arrowIcon,
+ defaultTextIconGap);
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "MenuItem"
+ */
+ protected String getPropertyPrefix()
+ {
+ return "MenuItem";
+ }
+
+ /**
+ * This method installs the components for this {@link JMenuItem}.
+ *
+ * @param menuItem
+ * The {@link JMenuItem} to install components for.
+ */
+ protected void installComponents(JMenuItem menuItem)
+ {
+ // FIXME: Need to implement
+ }
+
+ /**
+ * This method installs the defaults that are defined in the Basic look and
+ * feel for this {@link JMenuItem}.
+ */
+ protected void installDefaults()
+ {
+ String prefix = getPropertyPrefix();
+ LookAndFeel.installBorder(menuItem, prefix + ".border");
+ LookAndFeel.installColorsAndFont(menuItem, prefix + ".background",
+ prefix + ".foreground", prefix + ".font");
+ menuItem.setMargin(UIManager.getInsets(prefix + ".margin"));
+ acceleratorFont = UIManager.getFont(prefix + ".acceleratorFont");
+ acceleratorForeground = UIManager.getColor(prefix
+ + ".acceleratorForeground");
+ acceleratorSelectionForeground = UIManager.getColor(prefix
+ + ".acceleratorSelectionForeground");
+ selectionBackground = UIManager.getColor(prefix + ".selectionBackground");
+ selectionForeground = UIManager.getColor(prefix + ".selectionForeground");
+ acceleratorDelimiter = UIManager.getString(prefix + ".acceleratorDelimiter");
+ checkIcon = UIManager.getIcon(prefix + ".checkIcon");
+
+ menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
+ menuItem.setHorizontalAlignment(SwingConstants.LEADING);
+ }
+
+ /**
+ * This method installs the keyboard actions for this {@link JMenuItem}.
+ */
+ protected void installKeyboardActions()
+ {
+ InputMap focusedWindowMap = SwingUtilities.getUIInputMap(menuItem,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ if (focusedWindowMap == null)
+ focusedWindowMap = new ComponentInputMapUIResource(menuItem);
+ KeyStroke accelerator = menuItem.getAccelerator();
+ if (accelerator != null)
+ focusedWindowMap.put(accelerator, "doClick");
+ SwingUtilities.replaceUIInputMap(menuItem,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, focusedWindowMap);
+
+ ActionMap UIActionMap = SwingUtilities.getUIActionMap(menuItem);
+ if (UIActionMap == null)
+ UIActionMap = new ActionMapUIResource();
+ UIActionMap.put("doClick", new ClickAction());
+ SwingUtilities.replaceUIActionMap(menuItem, UIActionMap);
+ }
+
+ /**
+ * This method installs the listeners for the {@link JMenuItem}.
+ */
+ protected void installListeners()
+ {
+ menuItem.addMouseListener(mouseInputListener);
+ menuItem.addMouseMotionListener(mouseInputListener);
+ menuItem.addMenuDragMouseListener(menuDragMouseListener);
+ menuItem.addMenuKeyListener(menuKeyListener);
+ menuItem.addItemListener(itemListener);
+ menuItem.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Installs and initializes all fields for this UI delegate. Any properties of
+ * the UI that need to be initialized and/or set to defaults will be done now.
+ * It will also install any listeners necessary.
+ *
+ * @param c
+ * The {@link JComponent} that is having this UI installed.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ menuItem = (JMenuItem) c;
+ installDefaults();
+ installComponents(menuItem);
+ installListeners();
+ installKeyboardActions();
+ }
+
+ /**
+ * Paints given menu item using specified graphics context
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * Menu Item to paint
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ paintMenuItem(g, c, checkIcon, arrowIcon, selectionBackground,
+ c.getForeground(), defaultTextIconGap);
+ }
+
+ /**
+ * Paints background of the menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param menuItem
+ * menu item to paint
+ * @param bgColor
+ * Background color to use when painting menu item
+ */
+ protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
+ {
+ // Menu item is considered to be highlighted when it is selected.
+ // But we don't want to paint the background of JCheckBoxMenuItems
+ ButtonModel mod = menuItem.getModel();
+ Color saved = g.getColor();
+ if (mod.isArmed() || ((menuItem instanceof JMenu) && mod.isSelected()))
+ {
+ g.setColor(bgColor);
+ g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
+ }
+ else if (menuItem.isOpaque())
+ {
+ g.setColor(menuItem.getBackground());
+ g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
+ }
+ g.setColor(saved);
+ }
+
+ /**
+ * Paints specified menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * menu item to paint
+ * @param checkIcon
+ * check icon to use when painting menu item
+ * @param arrowIcon
+ * arrow icon to use when painting menu item
+ * @param background
+ * Background color of the menu item
+ * @param foreground
+ * Foreground color of the menu item
+ * @param defaultTextIconGap
+ * space to use between icon and text when painting menu item
+ */
+ protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon,
+ Icon arrowIcon, Color background,
+ Color foreground, int defaultTextIconGap)
+ {
+ JMenuItem m = (JMenuItem) c;
+
+ // Fetch fonts.
+ Font oldFont = g.getFont();
+ Font font = c.getFont();
+ g.setFont(font);
+ FontMetrics accelFm = m.getFontMetrics(acceleratorFont);
+
+ // Create accelerator string.
+ String accelText = getAcceleratorString(m);
+
+ // Layout menu item. The result gets stored in the rectangle fields
+ // of this class.
+ layoutMenuItem(m, accelText);
+
+ // Paint the background.
+ paintBackground(g, m, background);
+
+ Color oldColor = g.getColor();
+
+ // Paint the check icon.
+ if (checkIcon != null)
+ {
+ checkIcon.paintIcon(m, g, checkIconRect.x, checkIconRect.y);
+ }
+
+ // Paint the icon.
+ ButtonModel model = m.getModel();
+ if (m.getIcon() != null)
+ {
+ // Determine icon depending on the menu item
+ // state (normal/disabled/pressed).
+ Icon icon;
+ if (! m.isEnabled())
+ {
+ icon = m.getDisabledIcon();
+ }
+ else if (model.isPressed() && model.isArmed())
+ {
+ icon = m.getPressedIcon();
+ if (icon == null)
+ {
+ icon = m.getIcon();
+ }
+ }
+ else
+ {
+ icon = m.getIcon();
+ }
+
+ if (icon != null)
+ {
+ icon.paintIcon(m, g, iconRect.x, iconRect.y);
+ }
+ }
+
+ // Paint the text.
+ String text = m.getText();
+ if (text != null)
+ {
+ // Handle HTML.
+ View html = (View) m.getClientProperty(BasicHTML.propertyKey);
+ if (html != null)
+ {
+ html.paint(g, textRect);
+ }
+ else
+ {
+ paintText(g, m, textRect, text);
+ }
+ }
+
+ // Paint accelerator text.
+ if (! accelText.equals(""))
+ {
+ // Align the accelerator text. In getPreferredMenuItemSize() we
+ // store a client property 'maxAccelWidth' in the parent which holds
+ // the maximum accelerator width for the children of this parent.
+ // We use this here to align the accelerators properly.
+ int accelOffset = 0;
+ Container parent = m.getParent();
+ if (parent != null && parent instanceof JComponent)
+ {
+ JComponent p = (JComponent) parent;
+ Integer maxAccelWidth =
+ (Integer) p.getClientProperty("maxAccelWidth");
+ int maxAccelValue = maxAccelWidth == null ? 0
+ : maxAccelWidth.intValue();
+ accelOffset = maxAccelValue - accelRect.width;
+ }
+
+ g.setFont(acceleratorFont);
+ if (! m.isEnabled())
+ {
+ // Paint accelerator disabled.
+ g.setColor(disabledForeground);
+ }
+ else
+ {
+ if (m.isArmed() || (m instanceof JMenu && m.isSelected()))
+ g.setColor(acceleratorSelectionForeground);
+ else
+ g.setColor(acceleratorForeground);
+ }
+ g.drawString(accelText, accelRect.x - accelOffset,
+ accelRect.y + accelFm.getAscent());
+ }
+
+ // Paint arrow.
+ if (arrowIcon != null
+ && ! (m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ arrowIcon.paintIcon(m, g, arrowIconRect.x, arrowIconRect.y);
+ }
+
+ g.setFont(oldFont);
+ g.setColor(oldColor);
+
+ }
+
+ /**
+ * Paints label for the given menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param menuItem
+ * menu item for which to draw its label
+ * @param textRect
+ * rectangle specifiying position of the text relative to the given
+ * menu item
+ * @param text
+ * label of the menu item
+ */
+ protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect,
+ String text)
+ {
+ Font f = menuItem.getFont();
+ g.setFont(f);
+ FontMetrics fm = g.getFontMetrics(f);
+
+ if (text != null && !text.equals(""))
+ {
+ if (menuItem.isEnabled())
+ {
+ // Menu item is considered to be highlighted when it is selected.
+ // But not if it's a JCheckBoxMenuItem
+ ButtonModel mod = menuItem.getModel();
+ if ((menuItem.isSelected() && checkIcon == null)
+ || (mod != null && mod.isArmed())
+ && (menuItem.getParent() instanceof MenuElement))
+ g.setColor(selectionForeground);
+ else
+ g.setColor(menuItem.getForeground());
+ }
+ else
+ // FIXME: should fix this to use 'disabledForeground', but its
+ // default value in BasicLookAndFeel is null.
+
+ // FIXME: should there be different foreground colours for selected
+ // or deselected, when disabled?
+ g.setColor(Color.gray);
+
+ int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
+
+ if (mnemonicIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(menuItem, g, text,
+ mnemonicIndex,
+ textRect.x,
+ textRect.y
+ + fm.getAscent());
+ else
+ BasicGraphicsUtils.drawString(menuItem, g, text, 0, textRect.x,
+ textRect.y + fm.getAscent());
+ }
+ }
+
+ /**
+ * This method uninstalls the components for this {@link JMenuItem}.
+ *
+ * @param menuItem
+ * The {@link JMenuItem} to uninstall components for.
+ */
+ protected void uninstallComponents(JMenuItem menuItem)
+ {
+ // FIXME: need to implement
+ }
+
+ /**
+ * This method uninstalls the defaults and sets any objects created during
+ * install to null
+ */
+ protected void uninstallDefaults()
+ {
+ menuItem.setForeground(null);
+ menuItem.setBackground(null);
+ menuItem.setBorder(null);
+ menuItem.setMargin(null);
+ menuItem.setBackground(null);
+ menuItem.setBorder(null);
+ menuItem.setFont(null);
+ menuItem.setForeground(null);
+ menuItem.setMargin(null);
+ acceleratorFont = null;
+ acceleratorForeground = null;
+ acceleratorSelectionForeground = null;
+ arrowIcon = null;
+ selectionBackground = null;
+ selectionForeground = null;
+ acceleratorDelimiter = null;
+ }
+
+ /**
+ * Uninstalls any keyboard actions.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ SwingUtilities.replaceUIInputMap(menuItem,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, null);
+ }
+
+ /**
+ * Unregisters all the listeners that this UI delegate was using.
+ */
+ protected void uninstallListeners()
+ {
+ menuItem.removeMouseListener(mouseInputListener);
+ menuItem.removeMenuDragMouseListener(menuDragMouseListener);
+ menuItem.removeMenuKeyListener(menuKeyListener);
+ menuItem.removeItemListener(itemListener);
+ menuItem.removePropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Performs the opposite of installUI. Any properties or resources that need
+ * to be cleaned up will be done now. It will also uninstall any listeners it
+ * has. In addition, any properties of this UI will be nulled.
+ *
+ * @param c
+ * The {@link JComponent} that is having this UI uninstalled.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallListeners();
+ uninstallDefaults();
+ uninstallComponents(menuItem);
+ menuItem = null;
+ }
+
+ /**
+ * This method calls paint.
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * The menu item to paint
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ paint(g, c);
+ }
+
+ /**
+ * Return text representation of the specified accelerator
+ *
+ * @param accelerator
+ * Accelerator for which to return string representation
+ * @return $String$ Text representation of the given accelerator
+ */
+ private String getAcceleratorText(KeyStroke accelerator)
+ {
+ // convert keystroke into string format
+ String modifiersText = "";
+ int modifiers = accelerator.getModifiers();
+ char keyChar = accelerator.getKeyChar();
+ int keyCode = accelerator.getKeyCode();
+
+ if (modifiers != 0)
+ modifiersText = KeyEvent.getKeyModifiersText(modifiers)
+ + acceleratorDelimiter;
+
+ if (keyCode == KeyEvent.VK_UNDEFINED)
+ return modifiersText + keyChar;
+ else
+ return modifiersText + KeyEvent.getKeyText(keyCode);
+ }
+
+ /**
+ * Calculates and return rectange in which accelerator should be displayed
+ *
+ * @param accelerator
+ * accelerator for which to return the display rectangle
+ * @param fm
+ * The font metrics used to measure the text
+ * @return $Rectangle$ reactangle which will be used to display accelerator
+ */
+ private Rectangle getAcceleratorRect(KeyStroke accelerator, FontMetrics fm)
+ {
+ int width = fm.stringWidth(getAcceleratorText(accelerator));
+ int height = fm.getHeight();
+ return new Rectangle(0, 0, width, height);
+ }
+
+ /**
+ * This class handles mouse events occuring inside the menu item. Most of the
+ * events are forwarded for processing to MenuSelectionManager of the current
+ * menu hierarchy.
+ */
+ protected class MouseInputHandler implements MouseInputListener
+ {
+ /**
+ * Creates a new MouseInputHandler object.
+ */
+ protected MouseInputHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is called when mouse is clicked on the menu item. It forwards
+ * this event to MenuSelectionManager.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ /**
+ * This method is called when mouse is dragged inside the menu item. It
+ * forwards this event to MenuSelectionManager.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ /**
+ * This method is called when mouse enters menu item. When this happens menu
+ * item is considered to be selected and selection path in
+ * MenuSelectionManager is set. This event is also forwarded to
+ * MenuSelection Manager for further processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ Component source = (Component) e.getSource();
+ if (source.getParent() instanceof MenuElement)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(getPath());
+ manager.processMouseEvent(e);
+ }
+ }
+
+ /**
+ * This method is called when mouse exits menu item. The event is forwarded
+ * to MenuSelectionManager for processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ /**
+ * This method is called when mouse is inside the menu item. This event is
+ * forwarder to MenuSelectionManager for further processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ /**
+ * This method is called when mouse is pressed. This event is forwarded to
+ * MenuSelectionManager for further processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ /**
+ * This method is called when mouse is released. If the mouse is released
+ * inside this menuItem, then this menu item is considered to be chosen and
+ * the menu hierarchy should be closed.
+ *
+ * @param e
+ * A {@link MouseEvent}.
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ Rectangle size = menuItem.getBounds();
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
+ && e.getY() < size.height)
+ {
+ manager.clearSelectedPath();
+ menuItem.doClick();
+ }
+
+ else
+ manager.processMouseEvent(e);
+ }
+ }
+
+ /**
+ * This class handles mouse dragged events.
+ */
+ private class MenuDragMouseHandler implements MenuDragMouseListener
+ {
+ /**
+ * Tbis method is invoked when mouse is dragged over the menu item.
+ *
+ * @param e
+ * The MenuDragMouseEvent
+ */
+ public void menuDragMouseDragged(MenuDragMouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(e.getPath());
+ }
+
+ /**
+ * Tbis method is invoked when mouse enters the menu item while it is being
+ * dragged.
+ *
+ * @param e
+ * The MenuDragMouseEvent
+ */
+ public void menuDragMouseEntered(MenuDragMouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(e.getPath());
+ }
+
+ /**
+ * Tbis method is invoked when mouse exits the menu item while it is being
+ * dragged
+ *
+ * @param e the MenuDragMouseEvent
+ */
+ public void menuDragMouseExited(MenuDragMouseEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * Tbis method is invoked when mouse was dragged and released inside the
+ * menu item.
+ *
+ * @param e
+ * The MenuDragMouseEvent
+ */
+ public void menuDragMouseReleased(MenuDragMouseEvent e)
+ {
+ MenuElement[] path = e.getPath();
+
+ if (path[path.length - 1] instanceof JMenuItem)
+ ((JMenuItem) path[path.length - 1]).doClick();
+
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+ }
+
+ /**
+ * This class handles key events occuring when menu item is visible on the
+ * screen.
+ */
+ private class MenuKeyHandler implements MenuKeyListener
+ {
+ /**
+ * This method is invoked when key has been pressed
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
+ */
+ public void menuKeyPressed(MenuKeyEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * This method is invoked when key has been pressed
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
+ */
+ public void menuKeyReleased(MenuKeyEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+
+ /**
+ * This method is invoked when key has been typed It handles the mnemonic
+ * key for the menu item.
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
+ */
+ public void menuKeyTyped(MenuKeyEvent e)
+ {
+ // TODO: What should be done here, if anything?
+ }
+ }
+
+ /**
+ * Helper class that listens for item changes to the properties of the {@link
+ * JMenuItem}.
+ */
+ private class ItemHandler implements ItemListener
+ {
+ /**
+ * This method is called when one of the menu item changes.
+ *
+ * @param evt A {@link ItemEvent}.
+ */
+ public void itemStateChanged(ItemEvent evt)
+ {
+ boolean state = false;
+ if (menuItem instanceof JCheckBoxMenuItem)
+ {
+ if (evt.getStateChange() == ItemEvent.SELECTED)
+ state = true;
+ ((JCheckBoxMenuItem) menuItem).setState(state);
+ }
+ menuItem.revalidate();
+ menuItem.repaint();
+ }
+ }
+
+ /**
+ * A helper method to create the accelerator string from the menu item's
+ * accelerator property. The returned string is empty if there is
+ * no accelerator defined.
+ *
+ * @param m the menu item
+ *
+ * @return the accelerator string, not null
+ */
+ private String getAcceleratorString(JMenuItem m)
+ {
+ // Create accelerator string.
+ KeyStroke accel = m.getAccelerator();
+ String accelText = "";
+ if (accel != null)
+ {
+ int mods = accel.getModifiers();
+ if (mods > 0)
+ {
+ accelText = KeyEvent.getKeyModifiersText(mods);
+ accelText += acceleratorDelimiter;
+ }
+ int keycode = accel.getKeyCode();
+ if (keycode != 0)
+ accelText += KeyEvent.getKeyText(keycode);
+ else
+ accelText += accel.getKeyChar();
+ }
+ return accelText;
+ }
+
+ /**
+ * A helper method that lays out the menu item. The layout is stored
+ * in the fields of this class.
+ *
+ * @param m the menu item to layout
+ * @param accelText the accelerator text
+ */
+ private void layoutMenuItem(JMenuItem m, String accelText)
+ {
+ int width = m.getWidth();
+ int height = m.getHeight();
+
+ // Reset rectangles.
+ iconRect.setBounds(0, 0, 0, 0);
+ textRect.setBounds(0, 0, 0, 0);
+ accelRect.setBounds(0, 0, 0, 0);
+ checkIconRect.setBounds(0, 0, 0, 0);
+ arrowIconRect.setBounds(0, 0, 0, 0);
+ viewRect.setBounds(0, 0, width, height);
+
+ // Substract insets to the view rect.
+ Insets insets = m.getInsets();
+ viewRect.x += insets.left;
+ viewRect.y += insets.top;
+ viewRect.width -= insets.left + insets.right;
+ viewRect.height -= insets.top + insets.bottom;
+
+ // Fetch the fonts.
+ Font font = m.getFont();
+ FontMetrics fm = m.getFontMetrics(font);
+ FontMetrics accelFm = m.getFontMetrics(acceleratorFont);
+
+ String text = m.getText();
+ SwingUtilities.layoutCompoundLabel(m, fm, text, m.getIcon(),
+ m.getVerticalAlignment(),
+ m.getHorizontalAlignment(),
+ m.getVerticalTextPosition(),
+ m.getHorizontalTextPosition(),
+ viewRect, iconRect, textRect,
+ defaultTextIconGap);
+
+ // Initialize accelerator width and height.
+ if (! accelText.equals(""))
+ {
+ accelRect.width = accelFm.stringWidth(accelText);
+ accelRect.height = accelFm.getHeight();
+ }
+
+ // Initialize check and arrow icon width and height.
+ if (! (m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ if (checkIcon != null)
+ {
+ checkIconRect.width = checkIcon.getIconWidth();
+ checkIconRect.height = checkIcon.getIconHeight();
+ }
+ if (arrowIcon != null)
+ {
+ arrowIconRect.width = arrowIcon.getIconWidth();
+ arrowIconRect.height = arrowIcon.getIconHeight();
+ }
+ }
+
+ // The union of the icon and text of the menu item is the 'label area'.
+ cachedRect.setBounds(textRect);
+ Rectangle labelRect = SwingUtilities.computeUnion(iconRect.x,
+ iconRect.y,
+ iconRect.width,
+ iconRect.height,
+ cachedRect);
+ textRect.x += defaultTextIconGap;
+ iconRect.x += defaultTextIconGap;
+
+ // Layout accelerator rect.
+ accelRect.x = viewRect.x + viewRect.width - arrowIconRect.width
+ - defaultTextIconGap - accelRect.width;
+ // Layout check and arrow icons only when not in toplevel menu.
+ if (! (m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ checkIconRect.x = viewRect.x + defaultTextIconGap;
+ textRect.x += defaultTextIconGap + checkIconRect.width;
+ iconRect.x += defaultTextIconGap + checkIconRect.width;
+ arrowIconRect.x = viewRect.x + viewRect.width - defaultTextIconGap
+ - arrowIconRect.width;
+ }
+
+ // Align the accelerator text and all the icons vertically centered to
+ // the menu text.
+ accelRect.y = labelRect.y + (labelRect.height / 2)
+ - (accelRect.height / 2);
+ if (! (m instanceof JMenu && ((JMenu) m).isTopLevelMenu()))
+ {
+ arrowIconRect.y = labelRect.y + (labelRect.height / 2)
+ - (arrowIconRect.height / 2);
+ checkIconRect.y = labelRect.y + (labelRect.height / 2)
+ - (checkIconRect.height / 2);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,573 @@
+/* BasicMenuUI.java
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JComponent;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JPopupMenu;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuSelectionManager;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.MenuDragMouseEvent;
+import javax.swing.event.MenuDragMouseListener;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuKeyEvent;
+import javax.swing.event.MenuKeyListener;
+import javax.swing.event.MenuListener;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * UI Delegate for JMenu
+ */
+public class BasicMenuUI extends BasicMenuItemUI
+{
+ protected ChangeListener changeListener;
+
+ /* MenuListener listens to MenuEvents fired by JMenu */
+ protected MenuListener menuListener;
+
+ /* PropertyChangeListner that listens to propertyChangeEvents occuring in JMenu*/
+ protected PropertyChangeListener propertyChangeListener;
+
+ /**
+ * Creates a new BasicMenuUI object.
+ */
+ public BasicMenuUI()
+ {
+ mouseInputListener = createMouseInputListener((JMenu) menuItem);
+ menuListener = createMenuListener((JMenu) menuItem);
+ propertyChangeListener = createPropertyChangeListener((JMenu) menuItem);
+ }
+
+ /**
+ * This method creates a new ChangeListener.
+ *
+ * @return A new ChangeListener.
+ */
+ protected ChangeListener createChangeListener(JComponent c)
+ {
+ return new ChangeHandler((JMenu) c, this);
+ }
+
+ /**
+ * This method creates new MenuDragMouseListener to listen to mouse dragged events
+ * occuring in the Menu
+ *
+ * @param c the menu to listen to
+ *
+ * @return The MenuDrageMouseListener
+ */
+ protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
+ {
+ return new MenuDragMouseHandler();
+ }
+
+ /**
+ * This method creates new MenuDragKeyListener to listen to key events
+ *
+ * @param c the menu to listen to
+ *
+ * @return The MenuKeyListener
+ */
+ protected MenuKeyListener createMenuKeyListener(JComponent c)
+ {
+ return new MenuKeyHandler();
+ }
+
+ /**
+ * This method creates new MenuListener to listen to menu events
+ * occuring in the Menu
+ *
+ * @param c the menu to listen to
+ *
+ * @return The MenuListener
+ */
+ protected MenuListener createMenuListener(JComponent c)
+ {
+ return new MenuHandler();
+ }
+
+ /**
+ * This method creates new MouseInputListener to listen to mouse input events
+ * occuring in the Menu
+ *
+ * @param c the menu to listen to
+ *
+ * @return The MouseInputListener
+ */
+ protected MouseInputListener createMouseInputListener(JComponent c)
+ {
+ return new MouseInputHandler();
+ }
+
+ /**
+ * This method creates newPropertyChangeListener to listen to property changes
+ * occuring in the Menu
+ *
+ * @param c the menu to listen to
+ *
+ * @return The PropertyChangeListener
+ */
+ protected PropertyChangeListener createPropertyChangeListener(JComponent c)
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * This method creates a new BasicMenuUI.
+ *
+ * @param c The JComponent to create a UI for.
+ *
+ * @return A new BasicMenuUI.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicMenuUI();
+ }
+
+ /**
+ * Get the component's maximum size.
+ *
+ * @param c The JComponent for which to get maximum size
+ *
+ * @return The maximum size of the component
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return c.getPreferredSize();
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "Menu"
+ */
+ protected String getPropertyPrefix()
+ {
+ return "Menu";
+ }
+
+ /**
+ * Initializes any default properties that this UI has from the defaults for
+ * the Basic look and feel.
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installBorder(menuItem, "Menu.border");
+ LookAndFeel.installColorsAndFont(menuItem, "Menu.background",
+ "Menu.foreground", "Menu.font");
+ menuItem.setMargin(UIManager.getInsets("Menu.margin"));
+ acceleratorFont = UIManager.getFont("Menu.acceleratorFont");
+ acceleratorForeground = UIManager.getColor("Menu.acceleratorForeground");
+ acceleratorSelectionForeground = UIManager.getColor("Menu.acceleratorSelectionForeground");
+ selectionBackground = UIManager.getColor("Menu.selectionBackground");
+ selectionForeground = UIManager.getColor("Menu.selectionForeground");
+ arrowIcon = UIManager.getIcon("Menu.arrowIcon");
+ oldBorderPainted = UIManager.getBoolean("Menu.borderPainted");
+ }
+
+ /**
+ * Installs any keyboard actions. The list of keys that need to be bound are
+ * listed in Basic look and feel's defaults.
+ *
+ */
+ protected void installKeyboardActions()
+ {
+ super.installKeyboardActions();
+ }
+
+ /**
+ * Creates and registers all the listeners for this UI delegate.
+ */
+ protected void installListeners()
+ {
+ super.installListeners();
+ ((JMenu) menuItem).addMenuListener(menuListener);
+ }
+
+ protected void setupPostTimer(JMenu menu)
+ throws NotImplementedException
+ {
+ // TODO: Implement this properly.
+ }
+
+ /**
+ * This method uninstalls the defaults and sets any objects created during
+ * install to null
+ */
+ protected void uninstallDefaults()
+ {
+ menuItem.setBackground(null);
+ menuItem.setBorder(null);
+ menuItem.setFont(null);
+ menuItem.setForeground(null);
+ menuItem.setMargin(null);
+ acceleratorFont = null;
+ acceleratorForeground = null;
+ acceleratorSelectionForeground = null;
+ selectionBackground = null;
+ selectionForeground = null;
+ arrowIcon = null;
+ }
+
+ /**
+ * Uninstalls any keyboard actions. The list of keys used are listed in
+ * Basic look and feel's defaults.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ super.installKeyboardActions();
+ }
+
+ /**
+ * Unregisters all the listeners that this UI delegate was using. In
+ * addition, it will also null any listeners that it was using.
+ */
+ protected void uninstallListeners()
+ {
+ super.uninstallListeners();
+ ((JMenu) menuItem).removeMenuListener(menuListener);
+ }
+
+ /**
+ * This class is used by menus to handle mouse events occuring in the
+ * menu.
+ */
+ protected class MouseInputHandler implements MouseInputListener
+ {
+ public void mouseClicked(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ private boolean popupVisible()
+ {
+ JMenuBar mb = (JMenuBar) ((JMenu) menuItem).getParent();
+ // check if mb.isSelected because if no menus are selected
+ // we don't have to look through the list for popup menus
+ if (!mb.isSelected())
+ return false;
+ for (int i = 0; i < mb.getMenuCount(); i++)
+ {
+ JMenu m = mb.getMenu(i);
+ if (m != null && m.isPopupMenuVisible())
+ return true;
+ }
+ return false;
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ /* When mouse enters menu item, it should be considered selected
+
+ if (i) if this menu is a submenu in some other menu
+ (ii) or if this menu is in a menu bar and some other menu in a
+ menu bar was just selected and has its popup menu visible.
+ (If nothing was selected, menu should be pressed before
+ it will be selected)
+ */
+ JMenu menu = (JMenu) menuItem;
+
+ // NOTE: the following if used to require !menu.isArmed but I could find
+ // no reason for this and it was preventing some JDK-compatible behaviour.
+ // Specifically, if a menu is selected but its popup menu not visible,
+ // and then another menu is selected whose popup menu IS visible, when
+ // the mouse is moved over the first menu, its popup menu should become
+ // visible.
+
+ if (! menu.isTopLevelMenu() || popupVisible())
+ {
+ // set new selection and forward this event to MenuSelectionManager
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(getPath());
+ manager.processMouseEvent(e);
+ }
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ JMenu menu = (JMenu) menuItem;
+ manager.processMouseEvent(e);
+
+ // Menu should be displayed when the menu is pressed only if
+ // it is top-level menu
+ if (menu.isTopLevelMenu())
+ {
+ if (menu.getPopupMenu().isVisible())
+ // If menu is visible and menu button was pressed..
+ // then need to cancel the menu
+ manager.clearSelectedPath();
+ else
+ {
+ // Display the menu
+ int x = 0;
+ int y = menu.getHeight();
+
+ manager.setSelectedPath(getPath());
+
+ JMenuBar mb = (JMenuBar) menu.getParent();
+
+ // set selectedIndex of the selectionModel of a menuBar
+ mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu));
+ }
+ }
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.processMouseEvent(e);
+ }
+ }
+
+ /**
+ * This class handles MenuEvents fired by the JMenu
+ */
+ private class MenuHandler implements MenuListener
+ {
+ /**
+ * This method is called when menu is cancelled. The menu is cancelled
+ * when its popup menu is closed without selection. It clears selected index
+ * in the selectionModel of the menu parent.
+ *
+ * @param e The MenuEvent.
+ */
+ public void menuCanceled(MenuEvent e)
+ {
+ menuDeselected(e);
+ }
+
+ /**
+ * This method is called when menu is deselected. It clears selected index
+ * in the selectionModel of the menu parent.
+ *
+ * @param e The MenuEvent.
+ */
+ public void menuDeselected(MenuEvent e)
+ {
+ JMenu menu = (JMenu) menuItem;
+ if (menu.getParent() != null)
+ {
+ if (menu.isTopLevelMenu())
+ ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
+ else
+ ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
+ }
+ }
+
+ /**
+ * This method is called when menu is selected. It sets selected index
+ * in the selectionModel of the menu parent.
+ *
+ * @param e The MenuEvent.
+ */
+ public void menuSelected(MenuEvent e)
+ {
+ JMenu menu = (JMenu) menuItem;
+ if (menu.isTopLevelMenu())
+ ((JMenuBar) menu.getParent()).setSelected(menu);
+ else
+ ((JPopupMenu) menu.getParent()).setSelected(menu);
+ }
+ }
+
+ /**
+ * Obsolete as of JDK1.4.
+ */
+ public class ChangeHandler implements ChangeListener
+ {
+ /**
+ * Not used.
+ */
+ public boolean isSelected;
+
+ /**
+ * Not used.
+ */
+ public JMenu menu;
+
+ /**
+ * Not used.
+ */
+ public BasicMenuUI ui;
+
+ /**
+ * Not used.
+ */
+ public Component wasFocused;
+
+ /**
+ * Not used.
+ */
+ public ChangeHandler(JMenu m, BasicMenuUI ui)
+ {
+ menu = m;
+ this.ui = ui;
+ }
+
+ /**
+ * Not used.
+ */
+ public void stateChanged(ChangeEvent e)
+ {
+ // Not used.
+ }
+ }
+
+ /**
+ * This class handles mouse dragged events occuring in the menu.
+ */
+ private class MenuDragMouseHandler implements MenuDragMouseListener
+ {
+ /**
+ * This method is invoked when mouse is dragged over the menu item.
+ *
+ * @param e The MenuDragMouseEvent
+ */
+ public void menuDragMouseDragged(MenuDragMouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(e.getPath());
+ }
+
+ /**
+ * This method is invoked when mouse enters the menu item while it is
+ * being dragged.
+ *
+ * @param e The MenuDragMouseEvent
+ */
+ public void menuDragMouseEntered(MenuDragMouseEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(e.getPath());
+ }
+
+ /**
+ * This method is invoked when mouse exits the menu item while
+ * it is being dragged
+ *
+ * @param e The MenuDragMouseEvent
+ */
+ public void menuDragMouseExited(MenuDragMouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is invoked when mouse was dragged and released
+ * inside the menu item.
+ *
+ * @param e The MenuDragMouseEvent
+ */
+ public void menuDragMouseReleased(MenuDragMouseEvent e)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * This class handles key events occuring when menu item is visible on the
+ * screen.
+ */
+ private class MenuKeyHandler implements MenuKeyListener
+ {
+ /**
+ * This method is invoked when key has been pressed
+ *
+ * @param e A {@link MenuKeyEvent}.
+ */
+ public void menuKeyPressed(MenuKeyEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is invoked when key has been pressed
+ *
+ * @param e A {@link MenuKeyEvent}.
+ */
+ public void menuKeyReleased(MenuKeyEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is invoked when key has been typed
+ * It handles the mnemonic key for the menu item.
+ *
+ * @param e A {@link MenuKeyEvent}.
+ */
+ public void menuKeyTyped(MenuKeyEvent e)
+ throws NotImplementedException
+ {
+ // TODO: What should be done here, if anything?
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1404 @@
+/* BasicOptionPaneUI.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Polygon;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.Icon;
+import javax.swing.InputMap;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.OptionPaneUI;
+
+/**
+ * This class is the UI delegate for JOptionPane in the Basic Look and Feel.
+ */
+public class BasicOptionPaneUI extends OptionPaneUI
+{
+ /**
+ * Implements the "close" keyboard action.
+ */
+ static class OptionPaneCloseAction
+ extends AbstractAction
+ {
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JOptionPane op = (JOptionPane) event.getSource();
+ op.setValue(new Integer(JOptionPane.CLOSED_OPTION));
+ }
+
+ }
+
+ /**
+ * This is a helper class that listens to the buttons located at the bottom
+ * of the JOptionPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class ButtonActionListener implements ActionListener
+ {
+ /** The index of the option this button represents. */
+ protected int buttonIndex;
+
+ /**
+ * Creates a new ButtonActionListener object with the given buttonIndex.
+ *
+ * @param buttonIndex The index of the option this button represents.
+ */
+ public ButtonActionListener(int buttonIndex)
+ {
+ this.buttonIndex = buttonIndex;
+ }
+
+ /**
+ * This method is called when one of the option buttons are pressed.
+ *
+ * @param e The ActionEvent.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Object value = new Integer(JOptionPane.CLOSED_OPTION);
+ Object[] options = optionPane.getOptions();
+ if (options != null)
+ value = new Integer(buttonIndex);
+ else
+ {
+ String text = ((JButton) e.getSource()).getText();
+ if (text.equals(OK_STRING))
+ value = new Integer(JOptionPane.OK_OPTION);
+ if (text.equals(CANCEL_STRING))
+ value = new Integer(JOptionPane.CANCEL_OPTION);
+ if (text.equals(YES_STRING))
+ value = new Integer(JOptionPane.YES_OPTION);
+ if (text.equals(NO_STRING))
+ value = new Integer(JOptionPane.NO_OPTION);
+ }
+ optionPane.setValue(value);
+ resetInputValue();
+
+ Window owner = SwingUtilities.windowForComponent(optionPane);
+
+ if (owner instanceof JDialog)
+ ((JDialog) owner).dispose();
+
+ //else we probably have some kind of internal frame.
+ JInternalFrame inf = (JInternalFrame) SwingUtilities.getAncestorOfClass(
+ JInternalFrame.class, optionPane);
+ if (inf != null)
+ {
+ try
+ {
+ inf.setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if attempt has been vetoed.
+ }
+ }
+ }
+ }
+
+ /**
+ * This helper layout manager is responsible for the layout of the button
+ * area. The button area is the panel that holds the buttons which
+ * represent the options.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public static class ButtonAreaLayout implements LayoutManager
+ {
+ /** Whether this layout will center the buttons. */
+ protected boolean centersChildren = true;
+
+ /** The space between the buttons. */
+ protected int padding;
+
+ /** Whether the buttons will share the same widths. */
+ protected boolean syncAllWidths;
+
+ /** The width of the widest button. */
+ private transient int widthOfWidestButton;
+
+ /** The height of the tallest button. */
+ private transient int tallestButton;
+
+ /**
+ * Creates a new ButtonAreaLayout object with the given sync widths
+ * property and padding.
+ *
+ * @param syncAllWidths Whether the buttons will share the same widths.
+ * @param padding The padding between the buttons.
+ */
+ public ButtonAreaLayout(boolean syncAllWidths, int padding)
+ {
+ this.syncAllWidths = syncAllWidths;
+ this.padding = padding;
+ }
+
+ /**
+ * This method is called when a component is added to the container.
+ *
+ * @param string The constraints string.
+ * @param comp The component added.
+ */
+ public void addLayoutComponent(String string, Component comp)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method returns whether the children will be centered.
+ *
+ * @return Whether the children will be centered.
+ */
+ public boolean getCentersChildren()
+ {
+ return centersChildren;
+ }
+
+ /**
+ * This method returns the amount of space between components.
+ *
+ * @return The amount of space between components.
+ */
+ public int getPadding()
+ {
+ return padding;
+ }
+
+ /**
+ * This method returns whether all components will share widths (set to
+ * largest width).
+ *
+ * @return Whether all components will share widths.
+ */
+ public boolean getSyncAllWidths()
+ {
+ return syncAllWidths;
+ }
+
+ /**
+ * This method lays out the given container.
+ *
+ * @param container The container to lay out.
+ */
+ public void layoutContainer(Container container)
+ {
+ Component[] buttonList = container.getComponents();
+ int x = container.getInsets().left;
+ if (getCentersChildren())
+ x += (int) ((double) (container.getSize().width) / 2
+ - (double) (buttonRowLength(container)) / 2);
+ for (int i = 0; i < buttonList.length; i++)
+ {
+ Dimension dims = buttonList[i].getPreferredSize();
+ if (syncAllWidths)
+ {
+ buttonList[i].setBounds(x, 0, widthOfWidestButton, dims.height);
+ x += widthOfWidestButton + getPadding();
+ }
+ else
+ {
+ buttonList[i].setBounds(x, 0, dims.width, dims.height);
+ x += dims.width + getPadding();
+ }
+ }
+ }
+
+ /**
+ * This method returns the width of the given container taking into
+ * consideration the padding and syncAllWidths.
+ *
+ * @param c The container to calculate width for.
+ *
+ * @return The width of the given container.
+ */
+ private int buttonRowLength(Container c)
+ {
+ Component[] buttonList = c.getComponents();
+
+ int buttonLength = 0;
+ int widest = 0;
+ int tallest = 0;
+
+ for (int i = 0; i < buttonList.length; i++)
+ {
+ Dimension dims = buttonList[i].getPreferredSize();
+ buttonLength += dims.width + getPadding();
+ widest = Math.max(widest, dims.width);
+ tallest = Math.max(tallest, dims.height);
+ }
+
+ widthOfWidestButton = widest;
+ tallestButton = tallest;
+
+ int width;
+ if (getSyncAllWidths())
+ width = widest * buttonList.length
+ + getPadding() * (buttonList.length - 1);
+ else
+ width = buttonLength;
+
+ Insets insets = c.getInsets();
+ width += insets.left + insets.right;
+
+ return width;
+ }
+
+ /**
+ * This method returns the minimum layout size for the given container.
+ *
+ * @param c The container to measure.
+ *
+ * @return The minimum layout size.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return preferredLayoutSize(c);
+ }
+
+ /**
+ * This method returns the preferred size of the given container.
+ *
+ * @param c The container to measure.
+ *
+ * @return The preferred size.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ int w = buttonRowLength(c);
+
+ return new Dimension(w, tallestButton);
+ }
+
+ /**
+ * This method removes the given component from the layout manager's
+ * knowledge.
+ *
+ * @param c The component to remove.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method sets whether the children will be centered.
+ *
+ * @param newValue Whether the children will be centered.
+ */
+ public void setCentersChildren(boolean newValue)
+ {
+ centersChildren = newValue;
+ }
+
+ /**
+ * This method sets the amount of space between each component.
+ *
+ * @param newPadding The padding between components.
+ */
+ public void setPadding(int newPadding)
+ {
+ padding = newPadding;
+ }
+
+ /**
+ * This method sets whether the widths will be synced.
+ *
+ * @param newValue Whether the widths will be synced.
+ */
+ public void setSyncAllWidths(boolean newValue)
+ {
+ syncAllWidths = newValue;
+ }
+ }
+
+ /**
+ * This helper class handles property change events from the JOptionPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * This method is called when one of the properties of the JOptionPane
+ * changes.
+ *
+ * @param e The PropertyChangeEvent.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ String property = e.getPropertyName();
+ if (property.equals(JOptionPane.ICON_PROPERTY)
+ || property.equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY)
+ || property.equals(JOptionPane.INITIAL_VALUE_PROPERTY)
+ || property.equals(JOptionPane.MESSAGE_PROPERTY)
+ || property.equals(JOptionPane.MESSAGE_TYPE_PROPERTY)
+ || property.equals(JOptionPane.OPTION_TYPE_PROPERTY)
+ || property.equals(JOptionPane.OPTIONS_PROPERTY)
+ || property.equals(JOptionPane.WANTS_INPUT_PROPERTY))
+ {
+ uninstallComponents();
+ installComponents();
+ optionPane.validate();
+ }
+ }
+ }
+
+ /**
+ * The minimum width for JOptionPanes.
+ */
+ public static final int MinimumWidth = 262;
+
+ /**
+ * The minimum height for JOptionPanes.
+ */
+ public static final int MinimumHeight = 90;
+
+ /** Whether the JOptionPane contains custom components. */
+ protected boolean hasCustomComponents;
+
+ // The initialFocusComponent seems to always be set to a button (even if
+ // I try to set initialSelectionValue). This is different from what the
+ // javadocs state (which should switch this reference to the input component
+ // if one is present since that is what's going to get focus).
+
+ /**
+ * The button that will receive focus based on initialValue when no input
+ * component is present. If an input component is present, then the input
+ * component will receive focus instead.
+ */
+ protected Component initialFocusComponent;
+
+ /** The component that receives input when the JOptionPane needs it. */
+ protected JComponent inputComponent;
+
+ /** The minimum dimensions of the JOptionPane. */
+ protected Dimension minimumSize;
+
+ /** The propertyChangeListener for the JOptionPane. */
+ protected PropertyChangeListener propertyChangeListener;
+
+ /** The JOptionPane this UI delegate is used for. */
+ protected JOptionPane optionPane;
+
+ /** The size of the icons. */
+ private static final int ICON_SIZE = 36;
+
+ /** The string used to describe OK buttons. */
+ private static final String OK_STRING = "OK";
+
+ /** The string used to describe Yes buttons. */
+ private static final String YES_STRING = "Yes";
+
+ /** The string used to describe No buttons. */
+ private static final String NO_STRING = "No";
+
+ /** The string used to describe Cancel buttons. */
+ private static final String CANCEL_STRING = "Cancel";
+
+ /** The container for the message area.
+ * This is package-private to avoid an accessor method. */
+ transient Container messageAreaContainer;
+
+ /** The container for the buttons.
+ * This is package-private to avoid an accessor method. */
+ transient Container buttonContainer;
+
+ /**
+ * A helper class that implements Icon. This is used temporarily until
+ * ImageIcons are fixed.
+ */
+ private static class MessageIcon implements Icon
+ {
+ /**
+ * This method returns the width of the icon.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ /**
+ * This method returns the height of the icon.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ /**
+ * This method paints the icon as a part of the given component using the
+ * given graphics and the given x and y position.
+ *
+ * @param c The component that owns this icon.
+ * @param g The Graphics object to paint with.
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /** The icon displayed for ERROR_MESSAGE. */
+ private static MessageIcon errorIcon = new MessageIcon()
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Polygon oct = new Polygon(new int[] { 0, 0, 9, 27, 36, 36, 27, 9 },
+ new int[] { 9, 27, 36, 36, 27, 9, 0, 0 }, 8);
+ g.translate(x, y);
+
+ Color saved = g.getColor();
+ g.setColor(Color.RED);
+
+ g.fillPolygon(oct);
+
+ g.setColor(Color.BLACK);
+ g.drawRect(13, 16, 10, 4);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** The icon displayed for INFORMATION_MESSAGE. */
+ private static MessageIcon infoIcon = new MessageIcon()
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+
+ // Should be purple.
+ g.setColor(Color.RED);
+
+ g.fillOval(0, 0, ICON_SIZE, ICON_SIZE);
+
+ g.setColor(Color.BLACK);
+ g.drawOval(16, 6, 4, 4);
+
+ Polygon bottomI = new Polygon(new int[] { 15, 15, 13, 13, 23, 23, 21, 21 },
+ new int[] { 12, 28, 28, 30, 30, 28, 28, 12 },
+ 8);
+ g.drawPolygon(bottomI);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** The icon displayed for WARNING_MESSAGE. */
+ private static MessageIcon warningIcon = new MessageIcon()
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+ g.setColor(Color.YELLOW);
+
+ Polygon triangle = new Polygon(new int[] { 0, 18, 36 },
+ new int[] { 36, 0, 36 }, 3);
+ g.fillPolygon(triangle);
+
+ g.setColor(Color.BLACK);
+
+ Polygon excl = new Polygon(new int[] { 15, 16, 20, 21 },
+ new int[] { 8, 26, 26, 8 }, 4);
+ g.drawPolygon(excl);
+ g.drawOval(16, 30, 4, 4);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** The icon displayed for MESSAGE_ICON. */
+ private static MessageIcon questionIcon = new MessageIcon()
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.translate(x, y);
+ Color saved = g.getColor();
+ g.setColor(Color.GREEN);
+
+ g.fillRect(0, 0, ICON_SIZE, ICON_SIZE);
+
+ g.setColor(Color.BLACK);
+
+ g.drawOval(11, 2, 16, 16);
+ g.drawOval(14, 5, 10, 10);
+
+ g.setColor(Color.GREEN);
+ g.fillRect(0, 10, ICON_SIZE, ICON_SIZE - 10);
+
+ g.setColor(Color.BLACK);
+
+ g.drawLine(11, 10, 14, 10);
+
+ g.drawLine(24, 10, 17, 22);
+ g.drawLine(27, 10, 20, 22);
+ g.drawLine(17, 22, 20, 22);
+
+ g.drawOval(17, 25, 3, 3);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /**
+ * Creates a new BasicOptionPaneUI object.
+ */
+ public BasicOptionPaneUI()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * This method is messaged to add the buttons to the given container.
+ *
+ * @param container The container to add components to.
+ * @param buttons The buttons to add. (If it is an instance of component,
+ * the Object is added directly. If it is an instance of Icon, it is
+ * packed into a label and added. For all other cases, the string
+ * representation of the Object is retreived and packed into a
+ * label.)
+ * @param initialIndex The index of the component that is the initialValue.
+ */
+ protected void addButtonComponents(Container container, Object[] buttons,
+ int initialIndex)
+ {
+ if (buttons == null)
+ return;
+ for (int i = 0; i < buttons.length; i++)
+ {
+ if (buttons[i] != null)
+ {
+ Component toAdd;
+ if (buttons[i] instanceof Component)
+ toAdd = (Component) buttons[i];
+ else
+ {
+ if (buttons[i] instanceof Icon)
+ toAdd = new JButton((Icon) buttons[i]);
+ else
+ toAdd = new JButton(buttons[i].toString());
+ hasCustomComponents = true;
+ }
+ if (toAdd instanceof JButton)
+ ((JButton) toAdd).addActionListener(createButtonActionListener(i));
+ if (i == initialIndex)
+ initialFocusComponent = toAdd;
+ container.add(toAdd);
+ }
+ }
+ selectInitialValue(optionPane);
+ }
+
+ /**
+ * This method adds the appropriate icon the given container.
+ *
+ * @param top The container to add an icon to.
+ */
+ protected void addIcon(Container top)
+ {
+ JLabel iconLabel = null;
+ Icon icon = getIcon();
+ if (icon != null)
+ {
+ iconLabel = new JLabel(icon);
+ configureLabel(iconLabel);
+ top.add(iconLabel, BorderLayout.WEST);
+ }
+ }
+
+ /**
+ * A helper method that returns an instance of GridBagConstraints to be used
+ * for creating the message area.
+ *
+ * @return An instance of GridBagConstraints.
+ */
+ private static GridBagConstraints createConstraints()
+ {
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.gridx = GridBagConstraints.REMAINDER;
+ constraints.gridy = GridBagConstraints.REMAINDER;
+ constraints.gridwidth = 0;
+ constraints.anchor = GridBagConstraints.LINE_START;
+ constraints.fill = GridBagConstraints.NONE;
+ constraints.insets = new Insets(0, 0, 3, 0);
+
+ return constraints;
+ }
+
+ /**
+ * This method creates the proper object (if necessary) to represent msg.
+ * (If msg is an instance of Component, it will add it directly. If it is
+ * an icon, then it will pack it in a label and add it. Otherwise, it gets
+ * treated as a string. If the string is longer than maxll, a box is
+ * created and the burstStringInto is called with the box as the container.
+ * The box is then added to the given container. Otherwise, the string is
+ * packed in a label and placed in the given container.) This method is
+ * also used for adding the inputComponent to the container.
+ *
+ * @param container The container to add to.
+ * @param cons The constraints when adding.
+ * @param msg The message to add.
+ * @param maxll The max line length.
+ * @param internallyCreated Whether the msg is internally created.
+ */
+ protected void addMessageComponents(Container container,
+ GridBagConstraints cons, Object msg,
+ int maxll, boolean internallyCreated)
+ {
+ if (msg == null)
+ return;
+ hasCustomComponents = internallyCreated;
+ if (msg instanceof Object[])
+ {
+ Object[] arr = (Object[]) msg;
+ for (int i = 0; i < arr.length; i++)
+ addMessageComponents(container, cons, arr[i], maxll,
+ internallyCreated);
+ return;
+ }
+ else if (msg instanceof Component)
+ {
+ container.add((Component) msg, cons);
+ cons.gridy++;
+ }
+ else if (msg instanceof Icon)
+ {
+ JLabel label = new JLabel((Icon) msg);
+ configureLabel(label);
+ container.add(label, cons);
+ cons.gridy++;
+ }
+ else
+ {
+ // Undocumented behaviour.
+ // if msg.toString().length greater than maxll
+ // it will create a box and burst the string.
+ // otherwise, it will just create a label and re-call
+ // this method with the label o.O
+ if (msg.toString().length() > maxll || msg.toString().contains("\n"))
+ {
+ Box tmp = new Box(BoxLayout.Y_AXIS);
+ burstStringInto(tmp, msg.toString(), maxll);
+ addMessageComponents(container, cons, tmp, maxll, true);
+ }
+ else
+ {
+ JLabel label = new JLabel(msg.toString());
+ configureLabel(label);
+ addMessageComponents(container, cons, label, maxll, true);
+ }
+ }
+ }
+
+ /**
+ * This method creates instances of d (recursively if necessary based on
+ * maxll) and adds to c.
+ *
+ * @param c The container to add to.
+ * @param d The string to burst.
+ * @param maxll The max line length.
+ */
+ protected void burstStringInto(Container c, String d, int maxll)
+ {
+ if (d == null || c == null)
+ return;
+
+ int newlineIndex = d.indexOf('\n');
+ String line;
+ String remainder;
+ if (newlineIndex >= 0 && newlineIndex < maxll)
+ {
+ line = d.substring(0, newlineIndex);
+ remainder = d.substring(newlineIndex + 1);
+ }
+ else
+ {
+ line = d.substring(0, maxll);
+ remainder = d.substring(maxll);
+ }
+ JLabel label = new JLabel(line);
+ configureLabel(label);
+ c.add(label);
+
+ // If there is nothing left to burst, then we can stop.
+ if (remainder.length() == 0)
+ return;
+
+ // Recursively call ourselves to burst the remainder of the string,
+ if (remainder.length() > maxll || remainder.contains("\n"))
+ burstStringInto(c, remainder, maxll);
+ else
+ {
+ // Add the remainder to the container and be done.
+ JLabel l = new JLabel(remainder);
+ configureLabel(l);
+ c.add(l);
+ }
+ }
+
+ /**
+ * This method returns true if the given JOptionPane contains custom
+ * components.
+ *
+ * @param op The JOptionPane to check.
+ *
+ * @return True if the JOptionPane contains custom components.
+ */
+ public boolean containsCustomComponents(JOptionPane op)
+ {
+ return hasCustomComponents;
+ }
+
+ /**
+ * This method creates a button action listener for the given button index.
+ *
+ * @param buttonIndex The index of the button in components.
+ *
+ * @return A new ButtonActionListener.
+ */
+ protected ActionListener createButtonActionListener(int buttonIndex)
+ {
+ return new ButtonActionListener(buttonIndex);
+ }
+
+ /**
+ * This method creates the button area.
+ *
+ * @return A new Button Area.
+ */
+ protected Container createButtonArea()
+ {
+ JPanel buttonPanel = new JPanel();
+ Border b = UIManager.getBorder("OptionPane.buttonAreaBorder");
+ if (b != null)
+ buttonPanel.setBorder(b);
+
+ buttonPanel.setLayout(createLayoutManager());
+ addButtonComponents(buttonPanel, getButtons(), getInitialValueIndex());
+
+ return buttonPanel;
+ }
+
+ /**
+ * This method creates a new LayoutManager for the button area.
+ *
+ * @return A new LayoutManager for the button area.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return new ButtonAreaLayout(getSizeButtonsToSameWidth(), 6);
+ }
+
+ /**
+ * This method creates the message area.
+ *
+ * @return A new message area.
+ */
+ protected Container createMessageArea()
+ {
+ JPanel messageArea = new JPanel();
+ Border messageBorder = UIManager.getBorder("OptionPane.messageAreaBorder");
+ if (messageBorder != null)
+ messageArea.setBorder(messageBorder);
+
+ messageArea.setLayout(new BorderLayout());
+ addIcon(messageArea);
+
+ JPanel rightSide = new JPanel();
+ rightSide.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ rightSide.setLayout(new GridBagLayout());
+ GridBagConstraints con = createConstraints();
+
+ addMessageComponents(rightSide, con, getMessage(),
+ getMaxCharactersPerLineCount(), false);
+
+ if (optionPane.getWantsInput())
+ {
+ Object[] selection = optionPane.getSelectionValues();
+
+ if (selection == null)
+ inputComponent = new JTextField(15);
+ else if (selection.length < 20)
+ inputComponent = new JComboBox(selection);
+ else
+ inputComponent = new JList(selection);
+ if (inputComponent != null)
+ {
+ addMessageComponents(rightSide, con, inputComponent,
+ getMaxCharactersPerLineCount(), false);
+ resetSelectedValue();
+ selectInitialValue(optionPane);
+ }
+ }
+
+ messageArea.add(rightSide, BorderLayout.CENTER);
+
+ return messageArea;
+ }
+
+ /**
+ * This method creates a new PropertyChangeListener for listening to the
+ * JOptionPane.
+ *
+ * @return A new PropertyChangeListener.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * This method creates a Container that will separate the message and button
+ * areas.
+ *
+ * @return A Container that will separate the message and button areas.
+ */
+ protected Container createSeparator()
+ {
+ // The reference implementation returns null here. When overriding
+ // to return something non-null, the component gets added between
+ // the message area and the button area. See installComponents().
+ return null;
+ }
+
+ /**
+ * This method creates a new BasicOptionPaneUI for the given component.
+ *
+ * @param x The component to create a UI for.
+ *
+ * @return A new BasicOptionPaneUI.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicOptionPaneUI();
+ }
+
+ /**
+ * This method returns the buttons for the JOptionPane. If no options are
+ * set, a set of options will be created based upon the optionType.
+ *
+ * @return The buttons that will be added.
+ */
+ protected Object[] getButtons()
+ {
+ if (optionPane.getOptions() != null)
+ return optionPane.getOptions();
+ switch (optionPane.getOptionType())
+ {
+ case JOptionPane.YES_NO_OPTION:
+ return new Object[] { YES_STRING, NO_STRING };
+ case JOptionPane.YES_NO_CANCEL_OPTION:
+ return new Object[] { YES_STRING, NO_STRING, CANCEL_STRING };
+ case JOptionPane.OK_CANCEL_OPTION:
+ return new Object[] { OK_STRING, CANCEL_STRING };
+ case JOptionPane.DEFAULT_OPTION:
+ return (optionPane.getWantsInput()) ?
+ new Object[] { OK_STRING, CANCEL_STRING } :
+ (optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE) ?
+ new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } :
+ // ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, PLAIN_MESSAGE
+ new Object[] { OK_STRING };
+ }
+ return null;
+ }
+
+ /**
+ * This method will return the icon the user has set or the icon that will
+ * be used based on message type.
+ *
+ * @return The icon to use in the JOptionPane.
+ */
+ protected Icon getIcon()
+ {
+ if (optionPane.getIcon() != null)
+ return optionPane.getIcon();
+ else
+ return getIconForType(optionPane.getMessageType());
+ }
+
+ /**
+ * This method returns the icon for the given messageType.
+ *
+ * @param messageType The type of message.
+ *
+ * @return The icon for the given messageType.
+ */
+ protected Icon getIconForType(int messageType)
+ {
+ Icon tmp = null;
+ switch (messageType)
+ {
+ case JOptionPane.ERROR_MESSAGE:
+ tmp = errorIcon;
+ break;
+ case JOptionPane.INFORMATION_MESSAGE:
+ tmp = infoIcon;
+ break;
+ case JOptionPane.WARNING_MESSAGE:
+ tmp = warningIcon;
+ break;
+ case JOptionPane.QUESTION_MESSAGE:
+ tmp = questionIcon;
+ break;
+ }
+ return tmp;
+ // FIXME: Don't cast till the default icons are in.
+ // return new IconUIResource(tmp);
+ }
+
+ /**
+ * This method returns the index of the initialValue in the options array.
+ *
+ * @return The index of the initalValue.
+ */
+ protected int getInitialValueIndex()
+ {
+ Object[] buttons = getButtons();
+
+ if (buttons == null)
+ return -1;
+
+ Object select = optionPane.getInitialValue();
+
+ for (int i = 0; i < buttons.length; i++)
+ {
+ if (select == buttons[i])
+ return i;
+ }
+ return 0;
+ }
+
+ /**
+ * This method returns the maximum number of characters that should be
+ * placed on a line.
+ *
+ * @return The maximum number of characteres that should be placed on a
+ * line.
+ */
+ protected int getMaxCharactersPerLineCount()
+ {
+ return optionPane.getMaxCharactersPerLineCount();
+ }
+
+ /**
+ * This method returns the maximum size.
+ *
+ * @param c The JComponent to measure.
+ *
+ * @return The maximum size.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the message of the JOptionPane.
+ *
+ * @return The message.
+ */
+ protected Object getMessage()
+ {
+ return optionPane.getMessage();
+ }
+
+ /**
+ * This method returns the minimum size of the JOptionPane.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumOptionPaneSize()
+ {
+ return minimumSize;
+ }
+
+ /**
+ * This method returns the minimum size.
+ *
+ * @param c The JComponent to measure.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ /**
+ * This method returns the preferred size of the JOptionPane. The preferred
+ * size is the maximum of the size desired by the layout and the minimum
+ * size.
+ *
+ * @param c The JComponent to measure.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension d = optionPane.getLayout().preferredLayoutSize(optionPane);
+ Dimension d2 = getMinimumOptionPaneSize();
+
+ int w = Math.max(d.width, d2.width);
+ int h = Math.max(d.height, d2.height);
+ return new Dimension(w, h);
+ }
+
+ /**
+ * This method returns whether all buttons should have the same width.
+ *
+ * @return Whether all buttons should have the same width.
+ */
+ protected boolean getSizeButtonsToSameWidth()
+ {
+ return true;
+ }
+
+ /**
+ * This method installs components for the JOptionPane.
+ */
+ protected void installComponents()
+ {
+ // First thing is the message area.
+ optionPane.add(createMessageArea());
+
+ // Add separator when createSeparator() is overridden to return
+ // something other than null.
+ Container sep = createSeparator();
+ if (sep != null)
+ optionPane.add(sep);
+
+ // Last thing is the button area.
+ optionPane.add(createButtonArea());
+ }
+
+ /**
+ * This method installs defaults for the JOptionPane.
+ */
+ protected void installDefaults()
+ {
+ LookAndFeel.installColorsAndFont(optionPane, "OptionPane.background",
+ "OptionPane.foreground",
+ "OptionPane.font");
+ LookAndFeel.installBorder(optionPane, "OptionPane.border");
+ optionPane.setOpaque(true);
+
+ minimumSize = UIManager.getDimension("OptionPane.minimumSize");
+
+ // FIXME: Image icons don't seem to work properly right now.
+ // Once they do, replace the synthetic icons with these ones.
+
+ /*
+ warningIcon = (IconUIResource) defaults.getIcon("OptionPane.warningIcon");
+ infoIcon = (IconUIResource) defaults.getIcon("OptionPane.informationIcon");
+ errorIcon = (IconUIResource) defaults.getIcon("OptionPane.errorIcon");
+ questionIcon = (IconUIResource) defaults.getIcon("OptionPane.questionIcon");
+ */
+ }
+
+ /**
+ * This method installs keyboard actions for the JOptionpane.
+ */
+ protected void installKeyboardActions()
+ {
+ // Install the input map.
+ Object[] bindings =
+ (Object[]) SharedUIDefaults.get("OptionPane.windowBindings");
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(optionPane,
+ bindings);
+ SwingUtilities.replaceUIInputMap(optionPane,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ SwingUtilities.replaceUIActionMap(optionPane, getActionMap());
+ }
+
+ /**
+ * Fetches the action map from the UI defaults, or create a new one
+ * if the action map hasn't been initialized.
+ *
+ * @return the action map
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("OptionPane.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("OptionPane.actionMap", am);
+ }
+ return am;
+ }
+
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new OptionPaneCloseAction();
+
+ am.put("close", action);
+ return am;
+ }
+
+ /**
+ * This method installs listeners for the JOptionPane.
+ */
+ protected void installListeners()
+ {
+ propertyChangeListener = createPropertyChangeListener();
+
+ optionPane.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * This method installs the UI for the JOptionPane.
+ *
+ * @param c The JComponent to install the UI for.
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JOptionPane)
+ {
+ optionPane = (JOptionPane) c;
+
+ installDefaults();
+ installComponents();
+ installListeners();
+ installKeyboardActions();
+ }
+ }
+
+ /**
+ * Changes the inputValue property in the JOptionPane based on the current
+ * value of the inputComponent.
+ */
+ protected void resetInputValue()
+ {
+ if (optionPane.getWantsInput() && inputComponent != null)
+ {
+ Object output = null;
+ if (inputComponent instanceof JTextField)
+ output = ((JTextField) inputComponent).getText();
+ else if (inputComponent instanceof JComboBox)
+ output = ((JComboBox) inputComponent).getSelectedItem();
+ else if (inputComponent instanceof JList)
+ output = ((JList) inputComponent).getSelectedValue();
+
+ if (output != null)
+ optionPane.setInputValue(output);
+ }
+ }
+
+ /**
+ * This method requests focus to the inputComponent (if one is present) and
+ * the initialFocusComponent otherwise.
+ *
+ * @param op The JOptionPane.
+ */
+ public void selectInitialValue(JOptionPane op)
+ {
+ if (inputComponent != null)
+ {
+ inputComponent.requestFocus();
+ return;
+ }
+ if (initialFocusComponent != null)
+ initialFocusComponent.requestFocus();
+ }
+
+ /**
+ * This method resets the value in the inputComponent to the
+ * initialSelectionValue property.
+ * This is package-private to avoid an accessor method.
+ */
+ void resetSelectedValue()
+ {
+ if (inputComponent != null)
+ {
+ Object init = optionPane.getInitialSelectionValue();
+ if (init == null)
+ return;
+ if (inputComponent instanceof JTextField)
+ ((JTextField) inputComponent).setText((String) init);
+ else if (inputComponent instanceof JComboBox)
+ ((JComboBox) inputComponent).setSelectedItem(init);
+ else if (inputComponent instanceof JList)
+ {
+ // ((JList) inputComponent).setSelectedValue(init, true);
+ }
+ }
+ }
+
+ /**
+ * This method uninstalls all the components in the JOptionPane.
+ */
+ protected void uninstallComponents()
+ {
+ optionPane.removeAll();
+ buttonContainer = null;
+ messageAreaContainer = null;
+ }
+
+ /**
+ * This method uninstalls the defaults for the JOptionPane.
+ */
+ protected void uninstallDefaults()
+ {
+ optionPane.setFont(null);
+ optionPane.setForeground(null);
+ optionPane.setBackground(null);
+
+ minimumSize = null;
+
+ // FIXME: ImageIcons don't seem to work properly
+
+ /*
+ warningIcon = null;
+ errorIcon = null;
+ questionIcon = null;
+ infoIcon = null;
+ */
+ }
+
+ /**
+ * This method uninstalls keyboard actions for the JOptionPane.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ SwingUtilities.replaceUIInputMap(optionPane, JComponent.
+ WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ SwingUtilities.replaceUIActionMap(optionPane, null);
+ }
+
+ /**
+ * This method uninstalls listeners for the JOptionPane.
+ */
+ protected void uninstallListeners()
+ {
+ optionPane.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+
+ /**
+ * This method uninstalls the UI for the given JComponent.
+ *
+ * @param c The JComponent to uninstall for.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallKeyboardActions();
+ uninstallListeners();
+ uninstallComponents();
+ uninstallDefaults();
+
+ optionPane = null;
+ }
+
+ /**
+ * Applies the proper UI configuration to labels that are added to
+ * the OptionPane.
+ *
+ * @param l the label to configure
+ */
+ private void configureLabel(JLabel l)
+ {
+ Color c = UIManager.getColor("OptionPane.messageForeground");
+ if (c != null)
+ l.setForeground(c);
+ Font f = UIManager.getFont("OptionPane.messageFont");
+ if (f != null)
+ l.setFont(f);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,132 @@
+/* BasicPanelUI.java
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.LookAndFeel;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PanelUI;
+
+/**
+ * A UI delegate for the {@link JPanel} component.
+ */
+public class BasicPanelUI extends PanelUI
+{
+ /**
+ * A UI delegate that can be shared by all panels (because the delegate is
+ * stateless).
+ */
+ static BasicPanelUI sharedUI;
+
+ /**
+ * Returns a UI delegate for the specified component.
+ *
+ * @param panel the panel.
+ */
+ public static ComponentUI createUI(JComponent panel)
+ {
+ if (sharedUI == null)
+ sharedUI = new BasicPanelUI();
+ return sharedUI;
+ }
+
+ /**
+ * Installs this UI delegate in the specified component.
+ *
+ * @param c the component (should be a {@link JPanel}, <code>null</code> not
+ * permitted).
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof JPanel)
+ {
+ JPanel p = (JPanel) c;
+ installDefaults(p);
+ }
+ }
+
+ /**
+ * Installs the defaults for this UI delegate in the specified panel.
+ *
+ * @param p the panel (<code>null</code> not permitted).
+ */
+ protected void installDefaults(JPanel p)
+ {
+ LookAndFeel.installColorsAndFont(p, "Panel.background", "Panel.foreground",
+ "Panel.font");
+
+ // A test against the reference implementation shows that this method will
+ // install a border if one is defined in the UIDefaults table (even though
+ // the BasicLookAndFeel doesn't actually define a "Panel.border"). This
+ // test was written after discovering that a null argument to
+ // uninstallDefaults throws a NullPointerException in
+ // LookAndFeel.uninstallBorder()...
+ LookAndFeel.installBorder(p, "Panel.border");
+ }
+
+ /**
+ * Uninstalls this UI delegate from the specified component.
+ *
+ * @param c the component (<code>null</code> not permitted).
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults((JPanel) c);
+ }
+
+ /**
+ * Uninstalls the UI defaults for the specified panel.
+ *
+ * @param p the panel (<code>null</code> not permitted).
+ */
+ protected void uninstallDefaults(JPanel p)
+ {
+ // Tests on the reference implementation showed this method:
+ // (1) doesn't actually remove the installed colors and font installed
+ // by installDefaults(), it isn't necessary;
+ // (2) throws a NullPointerException in LookAndFeel.uninstallBorder() if
+ // p is null. Strangely, no border is installed by the
+ // BasicLookAndFeel - perhaps this is needed by another LAF?
+
+ LookAndFeel.uninstallBorder(p);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPasswordFieldUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPasswordFieldUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPasswordFieldUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPasswordFieldUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* BasicPasswordFieldUI.java
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.text.Element;
+import javax.swing.text.PasswordView;
+import javax.swing.text.View;
+
+public class BasicPasswordFieldUI extends BasicTextFieldUI
+{
+ public BasicPasswordFieldUI()
+ {
+ // Nothing to do here.
+ }
+
+ public View create(Element elem)
+ {
+ return new PasswordView(elem);
+ }
+
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicPasswordFieldUI();
+ }
+
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "PasswordField"
+ */
+ protected String getPropertyPrefix()
+ {
+ return "PasswordField";
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,114 @@
+/* BasicPopupMenuSeparatorUI.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * The Basic Look and Feel UI delegate for JPopupMenu.Separator.
+ */
+public class BasicPopupMenuSeparatorUI extends BasicSeparatorUI
+{
+ /**
+ * Creates a new BasicPopupMenuSeparatorUI object.
+ */
+ public BasicPopupMenuSeparatorUI()
+ {
+ super();
+ }
+
+ /**
+ * Creates a new UI delegate for the given JComponent.
+ *
+ * @param c The JComponent to create a delegate for.
+ *
+ * @return A new BasicPopupMenuSeparatorUI
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicPopupMenuSeparatorUI();
+ }
+
+ /**
+ * The Popup Menu Separator has two lines. The top line will be
+ * painted using highlight color and the bottom using shadow color.
+ *
+ * @param g The Graphics object to paint with
+ * @param c The JComponent to paint.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ if (! (c instanceof JPopupMenu.Separator))
+ return;
+
+ Rectangle r = new Rectangle();
+ SwingUtilities.calculateInnerArea(c, r);
+ Color saved = g.getColor();
+
+ int midAB = r.width / 2 + r.x;
+ int midAD = r.height / 2 + r.y;
+
+ g.setColor(highlight);
+ g.drawLine(r.x, midAD, r.x + r.width, midAD);
+
+ g.setColor(shadow);
+ g.drawLine(r.x, midAD + 1, r.x + r.width, midAD + 1);
+ }
+
+ /**
+ * This method returns the preferred size of the
+ * JComponent.
+ *
+ * @param c The JComponent to measure.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return super.getPreferredSize(c);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1019 @@
+/* BasicPopupMenuUI.java
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.KeyboardFocusManager;
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.MouseEvent;
+import java.util.EventListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.BoxLayout;
+import javax.swing.InputMap;
+import javax.swing.JApplet;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JRootPane;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PopupMenuUI;
+
+/**
+ * UI Delegate for JPopupMenu
+ */
+public class BasicPopupMenuUI extends PopupMenuUI
+{
+ /**
+ * Handles keyboard navigation through menus.
+ */
+ private static class NavigateAction
+ extends AbstractAction
+ {
+
+ /**
+ * Creates a new NavigateAction instance.
+ *
+ * @param name the name of the action
+ */
+ NavigateAction(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Actually performs the action.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ String name = (String) getValue(Action.NAME);
+ if (name.equals("selectNext"))
+ navigateNextPrevious(true);
+ else if (name.equals("selectPrevious"))
+ navigateNextPrevious(false);
+ else if (name.equals("selectChild"))
+ navigateParentChild(true);
+ else if (name.equals("selectParent"))
+ navigateParentChild(false);
+ else if (name.equals("cancel"))
+ cancel();
+ else if (name.equals("return"))
+ doReturn();
+ else
+ assert false : "Must not reach here";
+ }
+
+ /**
+ * Navigates to the next or previous menu item.
+ *
+ * @param dir <code>true</code>: navigate to next, <code>false</code>:
+ * navigate to previous
+ */
+ private void navigateNextPrevious(boolean dir)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ int len = path.length;
+ if (len >= 2)
+ {
+
+ if (path[0] instanceof JMenuBar &&
+ path[1] instanceof JMenu && len == 2)
+ {
+
+ // A toplevel menu is selected, but its popup not yet shown.
+ // Show the popup and select the first item
+ JPopupMenu popup = ((JMenu)path[1]).getPopupMenu();
+ MenuElement next =
+ findEnabledChild(popup.getSubElements(), -1, true);
+ MenuElement[] newPath;
+
+ if (next != null)
+ {
+ newPath = new MenuElement[4];
+ newPath[3] = next;
+ }
+ else
+ {
+ // Menu has no enabled items, show the popup anyway.
+ newPath = new MenuElement[3];
+ }
+ System.arraycopy(path, 0, newPath, 0, 2);
+ newPath[2] = popup;
+ msm.setSelectedPath(newPath);
+ }
+ else if (path[len - 1] instanceof JPopupMenu &&
+ path[len - 2] instanceof JMenu)
+ {
+ // Select next item in already shown popup menu.
+ JMenu menu = (JMenu) path[len - 2];
+ JPopupMenu popup = menu.getPopupMenu();
+ MenuElement next =
+ findEnabledChild(popup.getSubElements(), -1, dir);
+
+ if (next != null)
+ {
+ MenuElement[] newPath = new MenuElement[len + 1];
+ System.arraycopy(path, 0, newPath, 0, len);
+ newPath[len] = next;
+ msm.setSelectedPath(newPath);
+ }
+ else
+ {
+ // All items in the popup are disabled.
+ // Find the parent popup menu and select
+ // its next item. If there's no parent popup menu , do nothing.
+ if (len > 2 && path[len - 3] instanceof JPopupMenu)
+ {
+ popup = ((JPopupMenu) path[len - 3]);
+ next = findEnabledChild(popup.getSubElements(),
+ menu, dir);
+ if (next != null && next != menu)
+ {
+ MenuElement[] newPath = new MenuElement[len - 1];
+ System.arraycopy(path, 0, newPath, 0, len - 2);
+ newPath[len - 2] = next;
+ msm.setSelectedPath(newPath);
+ }
+ }
+ }
+ }
+ else
+ {
+ // Only select the next item.
+ MenuElement subs[] = path[len - 2].getSubElements();
+ MenuElement nextChild =
+ findEnabledChild(subs, path[len - 1], dir);
+ if (nextChild == null)
+ {
+ nextChild = findEnabledChild(subs, -1, dir);
+ }
+ if (nextChild != null)
+ {
+ path[len-1] = nextChild;
+ msm.setSelectedPath(path);
+ }
+ }
+ }
+ }
+
+ private MenuElement findEnabledChild(MenuElement[] children,
+ MenuElement start, boolean dir)
+ {
+ MenuElement found = null;
+ for (int i = 0; i < children.length && found == null; i++)
+ {
+ if (children[i] == start)
+ {
+ found = findEnabledChild(children, i, dir);
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Searches the next or previous enabled child menu element.
+ *
+ * @param children the children to search through
+ * @param start the index at which to start
+ * @param dir the direction (true == forward, false == backward)
+ *
+ * @return the found element or null
+ */
+ private MenuElement findEnabledChild(MenuElement[] children,
+ int start, boolean dir)
+ {
+ MenuElement result = null;
+ if (dir)
+ {
+ result = findNextEnabledChild(children, start + 1, children.length-1);
+ if (result == null)
+ result = findNextEnabledChild(children, 0, start - 1);
+ }
+ else
+ {
+ result = findPreviousEnabledChild(children, start - 1, 0);
+ if (result == null)
+ result = findPreviousEnabledChild(children, children.length-1,
+ start + 1);
+ }
+ return result;
+ }
+
+ /**
+ * Finds the next child element that is enabled and visible.
+ *
+ * @param children the children to search through
+ * @param start the start index
+ * @param end the end index
+ *
+ * @return the found child, or null
+ */
+ private MenuElement findNextEnabledChild(MenuElement[] children, int start,
+ int end)
+ {
+ MenuElement found = null;
+ for (int i = start; i <= end && found == null; i++)
+ {
+ if (children[i] != null)
+ {
+ Component comp = children[i].getComponent();
+ if (comp != null && comp.isEnabled() && comp.isVisible())
+ {
+ found = children[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Finds the previous child element that is enabled and visible.
+ *
+ * @param children the children to search through
+ * @param start the start index
+ * @param end the end index
+ *
+ * @return the found child, or null
+ */
+ private MenuElement findPreviousEnabledChild(MenuElement[] children,
+ int start, int end)
+ {
+ MenuElement found = null;
+ for (int i = start; i >= end && found == null; i--)
+ {
+ if (children[i] != null)
+ {
+ Component comp = children[i].getComponent();
+ if (comp != null && comp.isEnabled() && comp.isVisible())
+ {
+ found = children[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Navigates to the parent or child menu item.
+ *
+ * @param selectChild <code>true</code>: navigate to child,
+ * <code>false</code>: navigate to parent
+ */
+ private void navigateParentChild(boolean selectChild)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ int len = path.length;
+
+ if (selectChild)
+ {
+ if (len > 0 && path[len - 1] instanceof JMenu
+ && ! ((JMenu) path[len-1]).isTopLevelMenu())
+ {
+ // We have a submenu, open it.
+ JMenu menu = (JMenu) path[len - 1];
+ JPopupMenu popup = menu.getPopupMenu();
+ MenuElement[] subs = popup.getSubElements();
+ MenuElement item = findEnabledChild(subs, -1, true);
+ MenuElement[] newPath;
+
+ if (item == null)
+ {
+ newPath = new MenuElement[len + 1];
+ }
+ else
+ {
+ newPath = new MenuElement[len + 2];
+ newPath[len + 1] = item;
+ }
+ System.arraycopy(path, 0, newPath, 0, len);
+ newPath[len] = popup;
+ msm.setSelectedPath(newPath);
+ return;
+ }
+ }
+ else
+ {
+ int popupIndex = len-1;
+ if (len > 2
+ && (path[popupIndex] instanceof JPopupMenu
+ || path[--popupIndex] instanceof JPopupMenu)
+ && ! ((JMenu) path[popupIndex - 1]).isTopLevelMenu())
+ {
+ // We have a submenu, close it.
+ MenuElement newPath[] = new MenuElement[popupIndex];
+ System.arraycopy(path, 0, newPath, 0, popupIndex);
+ msm.setSelectedPath(newPath);
+ return;
+ }
+ }
+
+ // If we got here, we have not selected a child or parent.
+ // Check if we have a toplevel menu selected. If so, then select
+ // another one.
+ if (len > 1 && path[0] instanceof JMenuBar)
+ {
+ MenuElement currentMenu = path[1];
+ MenuElement nextMenu = findEnabledChild(path[0].getSubElements(),
+ currentMenu, selectChild);
+
+ if (nextMenu != null && nextMenu != currentMenu)
+ {
+ MenuElement newSelection[];
+ if (len == 2)
+ {
+ // Menu is selected but its popup not shown.
+ newSelection = new MenuElement[2];
+ newSelection[0] = path[0];
+ newSelection[1] = nextMenu;
+ }
+ else
+ {
+ // Menu is selected and its popup is shown.
+ newSelection = new MenuElement[3];
+ newSelection[0] = path[0];
+ newSelection[1] = nextMenu;
+ newSelection[2] = ((JMenu) nextMenu).getPopupMenu();
+ }
+ msm.setSelectedPath(newSelection);
+ }
+ }
+ }
+
+ /**
+ * Handles cancel requests (ESC key).
+ */
+ private void cancel()
+ {
+ // Fire popup menu cancelled event. Unfortunately the
+ // firePopupMenuCancelled() is protected in JPopupMenu so we work
+ // around this limitation by fetching the listeners and notifying them
+ // directly.
+ JPopupMenu lastPopup = (JPopupMenu) getLastPopup();
+ EventListener[] ll = lastPopup.getListeners(PopupMenuListener.class);
+ for (int i = 0; i < ll.length; i++)
+ {
+ PopupMenuEvent ev = new PopupMenuEvent(lastPopup);
+ ((PopupMenuListener) ll[i]).popupMenuCanceled(ev);
+ }
+
+ // Close the last popup or the whole selection if there's only one
+ // popup left.
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ if(path.length > 4)
+ {
+ MenuElement newPath[] = new MenuElement[path.length - 2];
+ System.arraycopy(path,0,newPath,0,path.length-2);
+ MenuSelectionManager.defaultManager().setSelectedPath(newPath);
+ }
+ else
+ msm.clearSelectedPath();
+ }
+
+ /**
+ * Returns the last popup menu in the current selection or null.
+ *
+ * @return the last popup menu in the current selection or null
+ */
+ private JPopupMenu getLastPopup()
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement[] p = msm.getSelectedPath();
+ JPopupMenu popup = null;
+ for(int i = p.length - 1; popup == null && i >= 0; i--)
+ {
+ if (p[i] instanceof JPopupMenu)
+ popup = (JPopupMenu) p[i];
+ }
+ return popup;
+ }
+
+ /**
+ * Handles ENTER key requests. This normally opens submenus on JMenu
+ * items, or activates the menu item as if it's been clicked on it.
+ */
+ private void doReturn()
+ {
+ KeyboardFocusManager fmgr =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ Component focusOwner = fmgr.getFocusOwner();
+ if((focusOwner == null || (focusOwner instanceof JRootPane)))
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ MenuElement lastElement;
+ if(path.length > 0)
+ {
+ lastElement = path[path.length - 1];
+ if(lastElement instanceof JMenu)
+ {
+ MenuElement newPath[] = new MenuElement[path.length + 1];
+ System.arraycopy(path,0,newPath,0,path.length);
+ newPath[path.length] = ((JMenu) lastElement).getPopupMenu();
+ msm.setSelectedPath(newPath);
+ }
+ else if(lastElement instanceof JMenuItem)
+ {
+ JMenuItem mi = (JMenuItem)lastElement;
+ if (mi.getUI() instanceof BasicMenuItemUI)
+ {
+ ((BasicMenuItemUI)mi.getUI()).doClick(msm);
+ }
+ else
+ {
+ msm.clearSelectedPath();
+ mi.doClick(0);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Installs keyboard actions when a popup is opened, and uninstalls the
+ * keyboard actions when closed. This listens on the default
+ * MenuSelectionManager.
+ */
+ private class KeyboardHelper
+ implements ChangeListener
+ {
+ private MenuElement[] lastSelectedPath = new MenuElement[0];
+ private Component lastFocused;
+ private JRootPane invokerRootPane;
+
+ public void stateChanged(ChangeEvent event)
+ {
+ MenuSelectionManager msm = (MenuSelectionManager) event.getSource();
+ MenuElement[] p = msm.getSelectedPath();
+ JPopupMenu popup = getActivePopup(p);
+ if (popup == null || popup.isFocusable())
+ {
+ if (lastSelectedPath.length != 0 && p.length != 0 )
+ {
+ if (! invokerEquals(p[0], lastSelectedPath[0]))
+ {
+ uninstallKeyboardActionsImpl();
+ lastSelectedPath = new MenuElement[0];
+ }
+ }
+
+ if (lastSelectedPath.length == 0 && p.length > 0)
+ {
+ JComponent invoker;
+ if (popup == null)
+ {
+ if (p.length == 2 && p[0] instanceof JMenuBar
+ && p[1] instanceof JMenu)
+ {
+ // A menu has been selected but not opened.
+ invoker = (JComponent)p[1];
+ popup = ((JMenu)invoker).getPopupMenu();
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ Component c = popup.getInvoker();
+ if(c instanceof JFrame)
+ {
+ invoker = ((JFrame) c).getRootPane();
+ }
+ else if(c instanceof JApplet)
+ {
+ invoker = ((JApplet) c).getRootPane();
+ }
+ else
+ {
+ while (!(c instanceof JComponent))
+ {
+ if (c == null)
+ {
+ return;
+ }
+ c = c.getParent();
+ }
+ invoker = (JComponent)c;
+ }
+ }
+
+ // Remember current focus owner.
+ lastFocused = KeyboardFocusManager.
+ getCurrentKeyboardFocusManager().getFocusOwner();
+
+ // Install keybindings used for menu navigation.
+ invokerRootPane = SwingUtilities.getRootPane(invoker);
+ if (invokerRootPane != null)
+ {
+ invokerRootPane.requestFocus(true);
+ installKeyboardActionsImpl();
+ }
+ }
+ else if (lastSelectedPath.length != 0 && p.length == 0)
+ {
+ // menu hidden -- return focus to where it had been before
+ // and uninstall menu keybindings
+ uninstallKeyboardActionsImpl();
+ }
+ }
+
+ // Remember the last path selected
+ lastSelectedPath = p;
+ }
+
+ private JPopupMenu getActivePopup(MenuElement[] path)
+ {
+ JPopupMenu active = null;
+ for (int i = path.length - 1; i >= 0 && active == null; i--)
+ {
+ MenuElement elem = path[i];
+ if (elem instanceof JPopupMenu)
+ {
+ active = (JPopupMenu) elem;
+ }
+ }
+ return active;
+ }
+
+ private boolean invokerEquals(MenuElement el1, MenuElement el2)
+ {
+ Component invoker1 = el1.getComponent();
+ Component invoker2 = el2.getComponent();
+ if (invoker1 instanceof JPopupMenu)
+ invoker1 = ((JPopupMenu) invoker1).getInvoker();
+ if (invoker2 instanceof JPopupMenu)
+ invoker2 = ((JPopupMenu) invoker2).getInvoker();
+ return invoker1 == invoker2;
+ }
+ }
+
+ /* popupMenu for which this UI delegate is for*/
+ protected JPopupMenu popupMenu;
+
+ /* PopupMenuListener listens to popup menu events fired by JPopupMenu*/
+ private transient PopupMenuListener popupMenuListener;
+
+ /* ComponentListener listening to popupMenu's invoker.
+ * This is package-private to avoid an accessor method. */
+ TopWindowListener topWindowListener;
+
+ /**
+ * Counts how many popup menus are handled by this UI or a subclass.
+ * This is used to install a KeyboardHelper on the MenuSelectionManager
+ * for the first popup, and uninstall this same KeyboardHelper when the
+ * last popup is uninstalled.
+ */
+ private static int numPopups;
+
+ /**
+ * This is the KeyboardHelper that listens on the MenuSelectionManager.
+ */
+ private static KeyboardHelper keyboardHelper;
+
+ /**
+ * Creates a new BasicPopupMenuUI object.
+ */
+ public BasicPopupMenuUI()
+ {
+ popupMenuListener = new PopupMenuHandler();
+ topWindowListener = new TopWindowListener();
+ }
+
+ /**
+ * Factory method to create a BasicPopupMenuUI for the given {@link
+ * JComponent}, which should be a {@link JMenuItem}.
+ *
+ * @param x The {@link JComponent} a UI is being created for.
+ *
+ * @return A BasicPopupMenuUI for the {@link JComponent}.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicPopupMenuUI();
+ }
+
+ /**
+ * Installs and initializes all fields for this UI delegate. Any properties
+ * of the UI that need to be initialized and/or set to defaults will be
+ * done now. It will also install any listeners necessary.
+ *
+ * @param c The {@link JComponent} that is having this UI installed.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+
+ // Install KeyboardHelper when the first popup is initialized.
+ if (numPopups == 0)
+ {
+ keyboardHelper = new KeyboardHelper();
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ msm.addChangeListener(keyboardHelper);
+ }
+ numPopups++;
+
+ popupMenu = (JPopupMenu) c;
+ popupMenu.setLayout(new DefaultMenuLayout(popupMenu, BoxLayout.Y_AXIS));
+ popupMenu.setBorderPainted(true);
+ JPopupMenu.setDefaultLightWeightPopupEnabled(true);
+
+ installDefaults();
+ installListeners();
+ installKeyboardActions();
+ }
+
+ /**
+ * This method installs the defaults that are defined in the Basic look
+ * and feel for this {@link JPopupMenu}.
+ */
+ public void installDefaults()
+ {
+ LookAndFeel.installColorsAndFont(popupMenu, "PopupMenu.background",
+ "PopupMenu.foreground", "PopupMenu.font");
+ LookAndFeel.installBorder(popupMenu, "PopupMenu.border");
+ popupMenu.setOpaque(true);
+ }
+
+ /**
+ * This method installs the listeners for the {@link JMenuItem}.
+ */
+ protected void installListeners()
+ {
+ popupMenu.addPopupMenuListener(popupMenuListener);
+ }
+
+ /**
+ * This method installs the keyboard actions for this {@link JPopupMenu}.
+ */
+ protected void installKeyboardActions()
+ {
+ // We can't install the keyboard actions here, because then all
+ // popup menus would have their actions registered in the KeyboardManager.
+ // So we install it when the popup menu is opened, and uninstall it
+ // when it's closed. This is done in the KeyboardHelper class.
+ // Install InputMap.
+ }
+
+ /**
+ * Called by the KeyboardHandler when a popup is made visible.
+ */
+ void installKeyboardActionsImpl()
+ {
+ Object[] bindings;
+ if (popupMenu.getComponentOrientation().isLeftToRight())
+ {
+ bindings = (Object[])
+ SharedUIDefaults.get("PopupMenu.selectedWindowInputMapBindings");
+ }
+ else
+ {
+ bindings = (Object[]) SharedUIDefaults.get
+ ("PopupMenu.selectedWindowInputMapBindings.RightToLeft");
+ }
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(popupMenu, bindings);
+ SwingUtilities.replaceUIInputMap(popupMenu,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // Install ActionMap.
+ SwingUtilities.replaceUIActionMap(popupMenu, getActionMap());
+ }
+
+ /**
+ * Creates and returns the shared action map for JTrees.
+ *
+ * @return the shared action map for JTrees
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("PopupMenu.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("PopupMenu.actionMap", am);
+ }
+ return am;
+ }
+
+ /**
+ * Creates the default actions when there are none specified by the L&F.
+ *
+ * @return the default actions
+ */
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new NavigateAction("selectNext");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectPrevious");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectParent");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectChild");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("return");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("cancel");
+ am.put(action.getValue(Action.NAME), action);
+
+ return am;
+ }
+
+ /**
+ * Performs the opposite of installUI. Any properties or resources that need
+ * to be cleaned up will be done now. It will also uninstall any listeners
+ * it has. In addition, any properties of this UI will be nulled.
+ *
+ * @param c The {@link JComponent} that is having this UI uninstalled.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallListeners();
+ uninstallDefaults();
+ uninstallKeyboardActions();
+ popupMenu = null;
+
+ // Install KeyboardHelper when the first popup is initialized.
+ numPopups--;
+ if (numPopups == 0)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ msm.removeChangeListener(keyboardHelper);
+ }
+
+ }
+
+ /**
+ * This method uninstalls the defaults and sets any objects created during
+ * install to null
+ */
+ protected void uninstallDefaults()
+ {
+ popupMenu.setBackground(null);
+ popupMenu.setBorder(null);
+ popupMenu.setFont(null);
+ popupMenu.setForeground(null);
+ }
+
+ /**
+ * Unregisters all the listeners that this UI delegate was using.
+ */
+ protected void uninstallListeners()
+ {
+ popupMenu.removePopupMenuListener(popupMenuListener);
+ }
+
+ /**
+ * Uninstalls any keyboard actions.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ // We can't install the keyboard actions here, because then all
+ // popup menus would have their actions registered in the KeyboardManager.
+ // So we install it when the popup menu is opened, and uninstall it
+ // when it's closed. This is done in the KeyboardHelper class.
+ // Install InputMap.
+ }
+
+ /**
+ * Called by the KeyboardHandler when a popup is made invisible.
+ */
+ void uninstallKeyboardActionsImpl()
+ {
+ SwingUtilities.replaceUIInputMap(popupMenu,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, null);
+ SwingUtilities.replaceUIActionMap(popupMenu, null);
+ }
+
+ /**
+ * This method returns the minimum size of the JPopupMenu.
+ *
+ * @param c The JComponent to find a size for.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ return null;
+ }
+
+ /**
+ * This method returns the preferred size of the JPopupMenu.
+ *
+ * @param c The JComponent to find a size for.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return null;
+ }
+
+ /**
+ * This method returns the minimum size of the JPopupMenu.
+ *
+ * @param c The JComponent to find a size for.
+ *
+ * @return The minimum size.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ return null;
+ }
+
+ /**
+ * Return true if given mouse event is a platform popup trigger, and false
+ * otherwise
+ *
+ * @param e MouseEvent that is to be checked for popup trigger event
+ *
+ * @return true if given mouse event is a platform popup trigger, and false
+ * otherwise
+ */
+ public boolean isPopupTrigger(MouseEvent e)
+ {
+ return false;
+ }
+
+ /**
+ * This listener handles PopupMenuEvents fired by JPopupMenu
+ */
+ private class PopupMenuHandler implements PopupMenuListener
+ {
+ /**
+ * This method is invoked when JPopupMenu is cancelled.
+ *
+ * @param event the PopupMenuEvent
+ */
+ public void popupMenuCanceled(PopupMenuEvent event)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+
+ /**
+ * This method is invoked when JPopupMenu becomes invisible
+ *
+ * @param event the PopupMenuEvent
+ */
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
+ {
+ // remove listener that listens to component events fired
+ // by the top - level window that this popup belongs to.
+ Component invoker = popupMenu.getInvoker();
+ Component rootContainer = SwingUtilities.getRoot(invoker);
+ if (rootContainer != null)
+ rootContainer.removeComponentListener(topWindowListener);
+ }
+
+ /**
+ * This method is invoked when JPopupMenu becomes visible
+ *
+ * @param event the PopupMenuEvent
+ */
+ public void popupMenuWillBecomeVisible(PopupMenuEvent event)
+ {
+ // Adds topWindowListener to top-level window to listener to
+ // ComponentEvents fired by it. We need to cancel this popup menu
+ // if topWindow to which this popup belongs was resized or moved.
+ Component invoker = popupMenu.getInvoker();
+ Component rootContainer = SwingUtilities.getRoot(invoker);
+ if (rootContainer != null)
+ rootContainer.addComponentListener(topWindowListener);
+
+ // if this popup menu is a free floating popup menu,
+ // then by default its first element should be always selected when
+ // this popup menu becomes visible.
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+
+ if (manager.getSelectedPath().length == 0)
+ {
+ // Set selected path to point to the first item in the popup menu
+ MenuElement[] path = new MenuElement[2];
+ path[0] = popupMenu;
+ Component[] comps = popupMenu.getComponents();
+ if (comps.length != 0 && comps[0] instanceof MenuElement)
+ {
+ path[1] = (MenuElement) comps[0];
+ manager.setSelectedPath(path);
+ }
+ }
+ }
+ }
+
+ /**
+ * ComponentListener that listens to Component Events fired by the top -
+ * level window to which popup menu belongs. If top-level window was
+ * resized, moved or hidded then popup menu will be hidded and selected
+ * path of current menu hierarchy will be set to null.
+ */
+ private class TopWindowListener implements ComponentListener
+ {
+ /**
+ * This method is invoked when top-level window is resized. This method
+ * closes current menu hierarchy.
+ *
+ * @param e The ComponentEvent
+ */
+ public void componentResized(ComponentEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+
+ /**
+ * This method is invoked when top-level window is moved. This method
+ * closes current menu hierarchy.
+ *
+ * @param e The ComponentEvent
+ */
+ public void componentMoved(ComponentEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+
+ /**
+ * This method is invoked when top-level window is shown This method
+ * does nothing by default.
+ *
+ * @param e The ComponentEvent
+ */
+ public void componentShown(ComponentEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+
+ /**
+ * This method is invoked when top-level window is hidden This method
+ * closes current menu hierarchy.
+ *
+ * @param e The ComponentEvent
+ */
+ public void componentHidden(ComponentEvent e)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ }
+ }
+
+}
More information about the llvm-commits
mailing list