From: <ls...@us...> - 2008-03-16 20:26:17
|
Revision: 3857 http://jnode.svn.sourceforge.net/jnode/?rev=3857&view=rev Author: lsantha Date: 2008-03-16 13:26:16 -0700 (Sun, 16 Mar 2008) Log Message: ----------- OpenJDK AWT & Swing integration. Removed Paths: ------------- trunk/core/src/classpath/javax/javax/swing/DebugGraphics.java trunk/core/src/classpath/javax/javax/swing/JComponent.java trunk/core/src/classpath/javax/javax/swing/KeyboardManager.java trunk/core/src/classpath/javax/javax/swing/RepaintManager.java trunk/core/src/classpath/javax/javax/swing/SwingUtilities.java Deleted: trunk/core/src/classpath/javax/javax/swing/DebugGraphics.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DebugGraphics.java 2008-03-16 20:25:30 UTC (rev 3856) +++ trunk/core/src/classpath/javax/javax/swing/DebugGraphics.java 2008-03-16 20:26:16 UTC (rev 3857) @@ -1,1125 +0,0 @@ -/* DebugGraphics.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; - -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.image.ImageObserver; -import java.io.PrintStream; -import java.text.AttributedCharacterIterator; - - -/** - * An extension of {@link Graphics} that can be used for debugging - * custom Swing widgets. <code>DebugGraphics</code> has the ability to - * draw slowly and can log drawing actions. - * - * @author Andrew Selkirk - */ -public class DebugGraphics extends Graphics -{ - /** - * LOG_OPTION - */ - public static final int LOG_OPTION = 1; - - /** - * FLASH_OPTION - */ - public static final int FLASH_OPTION = 2; - - /** - * BUFFERED_OPTION - */ - public static final int BUFFERED_OPTION = 4; - - /** - * NONE_OPTION - */ - public static final int NONE_OPTION = -1; - - static Color debugFlashColor = Color.RED; - static int debugFlashCount = 10; - static int debugFlashTime = 1000; - static PrintStream debugLogStream = System.out; - - /** - * Counts the created DebugGraphics objects. This is used by the - * logging facility. - */ - static int counter = 0; - - /** - * graphics - */ - Graphics graphics; - - /** - * buffer - */ - Image buffer; - - /** - * debugOptions - */ - int debugOptions; - - /** - * graphicsID - */ - int graphicsID; - - /** - * xOffset - */ - int xOffset; - - /** - * yOffset - */ - int yOffset; - - /** - * Creates a <code>DebugGraphics</code> object. - */ - public DebugGraphics() - { - counter++; - } - - /** - * Creates a <code>DebugGraphics</code> object. - * - * @param graphics The <code>Graphics</code> object to wrap - * @param component TODO - */ - public DebugGraphics(Graphics graphics, JComponent component) - { - this(graphics); - // FIXME: What shall we do with component ? - } - - /** - * Creates a <code>DebugGraphics</code> object. - * - * @param graphics The <code>Graphics</code> object to wrap - */ - public DebugGraphics(Graphics graphics) - { - this(); - this.graphics = graphics; - } - - /** - * Sets the color to draw stuff with. - * - * @param color The color - */ - public void setColor(Color color) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Setting color: " + color); - - graphics.setColor(color); - } - - /** - * Creates a overrides <code>Graphics.create</code> to create a - * <code>DebugGraphics</code> object. - * - * @return a new <code>DebugGraphics</code> object. - */ - public Graphics create() - { - DebugGraphics copy = new DebugGraphics(graphics.create()); - copy.debugOptions = debugOptions; - return copy; - } - - /** - * Creates a overrides <code>Graphics.create</code> to create a - * <code>DebugGraphics</code> object. - * - * @param x the x coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - * - * @return a new <code>DebugGraphics</code> object. - */ - public Graphics create(int x, int y, int width, int height) - { - DebugGraphics copy = new DebugGraphics(graphics.create(x, y, width, - height)); - copy.debugOptions = debugOptions; - return copy; - } - - /** - * flashColor - * - * @return Color - */ - public static Color flashColor() - { - return debugFlashColor; - } - - /** - * setFlashColor - * - * @param color the color to use for flashing - */ - public static void setFlashColor(Color color) - { - debugFlashColor = color; - } - - /** - * flashTime - * - * @return The time in milliseconds - */ - public static int flashTime() - { - return debugFlashTime; - } - - /** - * setFlashTime - * - * @param time The time in milliseconds - */ - public static void setFlashTime(int time) - { - debugFlashTime = time; - } - - /** - * flashCount - * - * @return The number of flashes - */ - public static int flashCount() - { - return debugFlashCount; - } - - /** - * setFlashCount - * - * @param count The number of flashes - */ - public static void setFlashCount(int count) - { - debugFlashCount = count; - } - - /** - * logStream - * - * @return The <code>PrintStream</code> to write logging messages to - */ - public static PrintStream logStream() - { - return debugLogStream; - } - - /** - * setLogStream - * - * @param stream The currently set <code>PrintStream</code>. - */ - public static void setLogStream(PrintStream stream) - { - debugLogStream = stream; - } - - /** - * getFont - * - * @return The font - */ - public Font getFont() - { - return graphics.getFont(); - } - - /** - * setFont - * - * @param font The font to use for drawing text - */ - public void setFont(Font font) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Setting font: " + font); - - graphics.setFont(font); - } - - /** - * Returns the color used for drawing. - * - * @return The color. - */ - public Color getColor() - { - return graphics.getColor(); - } - - /** - * Returns the font metrics of the current font. - * - * @return a <code>FontMetrics</code> object - */ - public FontMetrics getFontMetrics() - { - return graphics.getFontMetrics(); - } - - /** - * Returns the font metrics for a given font. - * - * @param font the font to get the metrics for - * - * @return a <code>FontMetrics</code> object - */ - public FontMetrics getFontMetrics(Font font) - { - return graphics.getFontMetrics(font); - } - - /** - * translate - * - * @param x the x coordinate - * @param y the y coordinate - */ - public void translate(int x, int y) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Translating by: " + new Point(x, y)); - - graphics.translate(x, y); - } - - /** - * setPaintMode - */ - public void setPaintMode() - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Setting paint mode"); - - graphics.setPaintMode(); - } - - /** - * setXORMode - * - * @param color the color - */ - public void setXORMode(Color color) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Setting XOR mode: " + color); - - graphics.setXORMode(color); - } - - /** - * getClipBounds - * - * @return Rectangle - */ - public Rectangle getClipBounds() - { - return graphics.getClipBounds(); - } - - /** - * Intersects the current clip region with the given region. - * - * @param x The x-position of the region - * @param y The y-position of the region - * @param width The width of the region - * @param height The height of the region - */ - public void clipRect(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().print(prefix() + " Setting clipRect: " - + new Rectangle(x, y, width, height)); - } - - graphics.clipRect(x, y, width, height); - - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(" Netting clipRect: " + graphics.getClipBounds()); - } - - /** - * Sets the clipping region. - * - * @param x The x-position of the region - * @param y The y-position of the region - * @param width The width of the region - * @param height The height of the region - */ - public void setClip(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Setting new clipRect: " - + new Rectangle(x, y, width, height)); - } - - graphics.setClip(x, y, width, height); - } - - /** - * Returns the current clipping region. - * - * @return Shape - */ - public Shape getClip() - { - return graphics.getClip(); - } - - /** - * Sets the current clipping region - * - * @param shape The clippin region - */ - public void setClip(Shape shape) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Setting new clipRect: " + shape); - - graphics.setClip(shape); - } - - private void sleep(int milliseconds) - { - try - { - Thread.sleep(milliseconds); - } - catch (InterruptedException e) - { - // Ignore this. - } - } - - /** - * Draws a rectangle. - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - */ - public void drawRect(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing rect: " - + new Rectangle(x, y, width, height)); - } - - if ((debugOptions & FLASH_OPTION) != 0) - { - Color color = graphics.getColor(); - for (int index = 0; index < (debugFlashCount - 1); ++index) - { - graphics.setColor(color); - graphics.drawRect(x, y, width, height); - sleep(debugFlashTime); - graphics.setColor(debugFlashColor); - graphics.drawRect(x, y, width, height); - sleep(debugFlashTime); - } - graphics.setColor(color); - } - - graphics.drawRect(x, y, width, height); - } - - /** - * Draws a filled rectangle. - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - */ - public void fillRect(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Filling rect: " - + new Rectangle(x, y, width, height)); - } - - if ((debugOptions & FLASH_OPTION) != 0) - { - Color color = graphics.getColor(); - for (int index = 0; index < (debugFlashCount - 1); ++index) - { - graphics.setColor(color); - graphics.fillRect(x, y, width, height); - sleep(debugFlashTime); - graphics.setColor(debugFlashColor); - graphics.fillRect(x, y, width, height); - sleep(debugFlashTime); - } - graphics.setColor(color); - } - - graphics.fillRect(x, y, width, height); - } - - /** - * clearRect - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - */ - public void clearRect(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Clearing rect: " - + new Rectangle(x, y, width, height)); - } - - graphics.clearRect(x, y, width, height); - } - - /** - * drawRoundRect - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - * @param arcWidth TODO - * @param arcHeight TODO - */ - public void drawRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing round rect: " - + new Rectangle(x, y, width, height) - + " arcWidth: " + arcWidth - + " arcHeight: " + arcHeight); - } - - graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight); - } - - /** - * fillRoundRect - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - * @param arcWidth TODO - * @param arcHeight TODO - */ - public void fillRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Filling round rect: " - + new Rectangle(x, y, width, height) - + " arcWidth: " + arcWidth - + " arcHeight: " + arcHeight); - } - - graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight); - } - - /** - * drawLine - * - * @param x1 The x-position of the start - * @param y1 The y-position of the start - * @param x2 The x-position of the end - * @param y2 The y-position of the end - */ - public void drawLine(int x1, int y1, int x2, int y2) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing line: from (" + x1 + ", " - + y1 + ") to (" + x2 + ", " + y2 + ")"); - } - - graphics.drawLine(x1, y1, x2, y2); - } - - /** - * draw3DRect - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - * @param raised TODO - */ - public void draw3DRect(int x, int y, int width, int height, boolean raised) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing 3D rect: " - + new Rectangle(x, y, width, height) - + "Raised bezel: " + raised); - } - - graphics.draw3DRect(x, y, width, height, raised); - } - - /** - * fill3DRect - * - * @param x The x-position of the rectangle - * @param y The y-position of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - * @param raised TODO - */ - public void fill3DRect(int x, int y, int width, int height, boolean raised) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Filling 3D rect: " - + new Rectangle(x, y, width, height) - + "Raised bezel: " + raised); - } - - graphics.fill3DRect(x, y, width, height, raised); - } - - /** - * drawOval - * - * @param x the x coordinate - * @param y the y coordiante - * @param width the width - * @param height the height - */ - public void drawOval(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing oval: " - + new Rectangle(x, y, width, height)); - } - - graphics.drawOval(x, y, width, height); - } - - /** - * fillOval - * - * @param x the x coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - */ - public void fillOval(int x, int y, int width, int height) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Filling oval: " - + new Rectangle(x, y, width, height)); - } - - graphics.fillOval(x, y, width, height); - } - - /** - * drawArc - * - * @param x the x coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - * @param startAngle TODO - * @param arcAngle TODO - */ - public void drawArc(int x, int y, int width, int height, - int startAngle, int arcAngle) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing arc: " - + new Rectangle(x, y, width, height) - + " startAngle: " + startAngle - + " arcAngle: " + arcAngle); - } - - graphics.drawArc(x, y, width, height, startAngle, arcAngle); - } - - /** - * fillArc - * - * @param x the coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - * @param startAngle TODO - * @param arcAngle TODO - */ - public void fillArc(int x, int y, int width, int height, - int startAngle, int arcAngle) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Filling arc: " - + new Rectangle(x, y, width, height) - + " startAngle: " + startAngle - + " arcAngle: " + arcAngle); - } - - graphics.fillArc(x, y, width, height, startAngle, arcAngle); - } - - /** - * drawPolyline - * - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void drawPolyline(int[] xpoints, int[] ypoints, int npoints) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing polyline: nPoints: " + npoints - + " X's: " + xpoints + " Y's: " + ypoints); - } - - graphics.drawPolyline(xpoints, ypoints, npoints); - } - - /** - * drawPolygon - * - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing polygon: nPoints: " + npoints - + " X's: " + xpoints + " Y's: " + ypoints); - } - - graphics.drawPolygon(xpoints, ypoints, npoints); - } - - /** - * fillPolygon - * - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing polygon: nPoints: " + npoints - + " X's: " + xpoints + " Y's: " + ypoints); - } - - graphics.fillPolygon(xpoints, ypoints, npoints); - } - - /** - * drawString - * - * @param string the string - * @param x the x coordinate - * @param y the y coordinate - */ - public void drawString(String string, int x, int y) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing string: \"" + string - + "\" at: " + new Point(x, y)); - } - - graphics.drawString(string, x, y); - } - - /** - * drawString - * - * @param iterator TODO - * @param x the x coordinate - * @param y the y coordinate - */ - public void drawString(AttributedCharacterIterator iterator, - int x, int y) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing string: \"" + iterator - + "\" at: " + new Point(x, y)); - } - - graphics.drawString(iterator, x, y); - } - - /** - * drawBytes - * - * @param data TODO - * @param offset TODO - * @param length TODO - * @param x the x coordinate - * @param y the y coordinate - */ - public void drawBytes(byte[] data, int offset, int length, - int x, int y) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Drawing bytes at: " + new Point(x, y)); - - graphics.drawBytes(data, offset, length, x, y); - } - - /** - * drawChars - * - * @param data array of characters to draw - * @param offset offset in array - * @param length number of characters in array to draw - * @param x x-position - * @param y y-position - */ - public void drawChars(char[] data, int offset, int length, - int x, int y) - { - if ((debugOptions & LOG_OPTION) != 0) - logStream().println(prefix() + " Drawing chars at: " + new Point(x, y)); - - if ((debugOptions & FLASH_OPTION) != 0) - { - Color color = graphics.getColor(); - for (int index = 0; index < (debugFlashCount - 1); ++index) - { - graphics.setColor(color); - graphics.drawChars(data, offset, length, x, y); - sleep(debugFlashTime); - graphics.setColor(debugFlashColor); - graphics.drawChars(data, offset, length, x, y); - sleep(debugFlashTime); - } - graphics.setColor(color); - } - - graphics.drawChars(data, offset, length, x, y); - } - - /** - * drawImage - * - * @param image The image to draw - * @param x The x position - * @param y The y position - * @param observer The image observer - * @return boolean - */ - public boolean drawImage(Image image, int x, int y, - ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image + " at: " - + new Point(x, y)); - } - - return graphics.drawImage(image, x, y, observer); - } - - /** - * drawImage - * - * @param image The image to draw - * @param x The x position - * @param y The y position - * @param width The width of the area to draw the image - * @param height The height of the area to draw the image - * @param observer The image observer - * - * @return boolean - */ - public boolean drawImage(Image image, int x, int y, int width, - int height, ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image - + " at: " + new Rectangle(x, y, width, height)); - } - - return graphics.drawImage(image, x, y, width, height, observer); - } - - /** - * drawImage - * - * @param image The image to draw - * @param x The x position - * @param y The y position - * @param background The color for the background in the opaque regions - * of the image - * @param observer The image observer - * - * @return boolean - */ - public boolean drawImage(Image image, int x, int y, - Color background, ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image - + " at: " + new Point(x, y) - + ", bgcolor: " + background); - } - - return graphics.drawImage(image, x, y, background, observer); - } - - /** - * drawImage - * - * @param image The image to draw - * @param x The x position - * @param y The y position - * @param width The width of the area to draw the image - * @param height The height of the area to draw the image - * @param background The color for the background in the opaque regions - * of the image - * @param observer The image observer - * - * @return boolean - */ - public boolean drawImage(Image image, int x, int y, int width, int height, - Color background, ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image - + " at: " + new Rectangle(x, y, width, height) - + ", bgcolor: " + background); - } - - return graphics.drawImage(image, x, y, width, height, background, observer); - } - - /** - * drawImage - * - * @param image The image to draw - * @param dx1 TODO - * @param dy1 TODO - * @param dx2 TODO - * @param dy2 TODO - * @param sx1 TODO - * @param sy1 TODO - * @param sx2 TODO - * @param sy2 TODO - * @param observer The image observer - * - * @return boolean - */ - public boolean drawImage(Image image, int dx1, int dy1, - int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image - + " destination: " + new Rectangle(dx1, dy1, dx2, dy2) - + " source: " + new Rectangle(sx1, sy1, sx2, sy2)); - } - - return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer); - } - - /** - * drawImage - * - * @param image The image to draw - * @param dx1 TODO - * @param dy1 TODO - * @param dx2 TODO - * @param dy2 TODO - * @param sx1 TODO - * @param sy1 TODO - * @param sx2 TODO - * @param sy2 TODO - * @param background The color for the background in the opaque regions - * of the image - * @param observer The image observer - * - * @return boolean - */ - public boolean drawImage(Image image, int dx1, int dy1, - int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - Color background, ImageObserver observer) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Drawing image: " + image - + " destination: " + new Rectangle(dx1, dy1, dx2, dy2) - + " source: " + new Rectangle(sx1, sy1, sx2, sy2) - + ", bgcolor: " + background); - } - - return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, background, observer); - } - - /** - * copyArea - * - * @param x The x position of the source area - * @param y The y position of the source area - * @param width The width of the area - * @param height The height of the area - * @param destx The x position of the destination area - * @param desty The y posiiton of the destination area - */ - public void copyArea(int x, int y, int width, int height, - int destx, int desty) - { - if ((debugOptions & LOG_OPTION) != 0) - { - logStream().println(prefix() + " Copying area from: " - + new Rectangle(x, y, width, height) - + " to: " + new Point(destx, desty)); - } - - graphics.copyArea(x, y, width, height, destx, desty); - } - - /** - * Releases all system resources that this <code>Graphics</code> is using. - */ - public void dispose() - { - graphics.dispose(); - graphics = null; - } - - /** - * isDrawingBuffer - * - * @return boolean - */ - public boolean isDrawingBuffer() - { - return false; // TODO - } - - /** - * setDebugOptions - * - * @param options the debug options - */ - public void setDebugOptions(int options) - { - debugOptions = options; - if ((debugOptions & LOG_OPTION) != 0) - if (options == NONE_OPTION) - logStream().println(prefix() + "Disabling debug"); - else - logStream().println(prefix() + "Enabling debug"); - } - - /** - * getDebugOptions - * - * @return the debug options - */ - public int getDebugOptions() - { - return debugOptions; - } - - /** - * Creates and returns the prefix that should be prepended to all logging - * messages. The prefix is made up like this: - * - * <code>Graphics(<counter>-1)</code> where counter is an integer number - * saying how many DebugGraphics objects have been created so far. The second - * number always seem to be 1 on Sun's JDK, this has to be investigated a - * little more. - * - * @return the prefix that should be prepended to all logging - * messages - */ - private String prefix() - { - return "Graphics(" + counter + "-1)"; - } -} Deleted: trunk/core/src/classpath/javax/javax/swing/JComponent.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JComponent.java 2008-03-16 20:25:30 UTC (rev 3856) +++ trunk/core/src/classpath/javax/javax/swing/JComponent.java 2008-03-16 20:26:16 UTC (rev 3857) @@ -1,4085 +0,0 @@ -/* JComponent.java -- Every component in swing inherits from this class. - 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; - -import java.applet.Applet; -import java.awt.AWTEvent; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.FocusTraversalPolicy; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Window; -import java.awt.dnd.DropTarget; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ContainerEvent; -import java.awt.event.ContainerListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.peer.LightweightPeer; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.beans.VetoableChangeSupport; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.EventListener; -import java.util.Hashtable; -import java.util.Locale; -import java.util.Set; - -import javax.accessibility.Accessible; -import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleExtendedComponent; -import javax.accessibility.AccessibleKeyBinding; -import javax.accessibility.AccessibleRole; -import javax.accessibility.AccessibleState; -import javax.accessibility.AccessibleStateSet; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.event.EventListenerList; -import javax.swing.plaf.ComponentUI; - -/** - * The base class of all Swing components. - * It contains generic methods to manage events, properties and sizes. Actual - * drawing of the component is channeled to a look-and-feel class that is - * implemented elsewhere. - * - * @author Ronald Veldema (rveldema&064;cs.vu.nl) - * @author Graydon Hoare (graydon&064;redhat.com) - */ -public abstract class JComponent extends Container implements Serializable -{ - private static final long serialVersionUID = -7908749299918704233L; - - /** - * The accessible context of this <code>JComponent</code>. - */ - protected AccessibleContext accessibleContext; - - /** - * Basic accessibility support for <code>JComponent</code> derived - * widgets. - */ - public abstract class AccessibleJComponent - extends AccessibleAWTContainer - implements AccessibleExtendedComponent - { - /** - * Receives notification if the focus on the JComponent changes and - * fires appropriate PropertyChangeEvents to listeners registered with - * the AccessibleJComponent. - */ - protected class AccessibleFocusHandler - implements FocusListener - { - /** - * Creates a new AccessibleFocusHandler. - */ - protected AccessibleFocusHandler() - { - // Nothing to do here. - } - - /** - * Receives notification when the JComponent gained focus and fires - * a PropertyChangeEvent to listeners registered on the - * AccessibleJComponent with a property name of - * {@link AccessibleContext#ACCESSIBLE_STATE_PROPERTY} and a new value - * of {@link AccessibleState#FOCUSED}. - */ - public void focusGained(FocusEvent event) - { - AccessibleJComponent.this.firePropertyChange - (AccessibleContext.ACCESSIBLE_STATE_PROPERTY, null, - AccessibleState.FOCUSED); - } - - /** - * Receives notification when the JComponent lost focus and fires - * a PropertyChangeEvent to listeners registered on the - * AccessibleJComponent with a property name of - * {@link AccessibleContext#ACCESSIBLE_STATE_PROPERTY} and an old value - * of {@link AccessibleState#FOCUSED}. - */ - public void focusLost(FocusEvent valevent) - { - AccessibleJComponent.this.firePropertyChange - (AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.FOCUSED, null); - } - } - - /** - * Receives notification if there are child components are added or removed - * from the JComponent and fires appropriate PropertyChangeEvents to - * interested listeners on the AccessibleJComponent. - */ - protected class AccessibleContainerHandler - implements ContainerListener - { - /** - * Creates a new AccessibleContainerHandler. - */ - protected AccessibleContainerHandler() - { - // Nothing to do here. - } - - /** - * Receives notification when a child component is added to the - * JComponent and fires a PropertyChangeEvent on listeners registered - * with the AccessibleJComponent with a property name of - * {@link AccessibleContext#ACCESSIBLE_CHILD_PROPERTY}. - * - * @param event the container event - */ - public void componentAdded(ContainerEvent event) - { - Component c = event.getChild(); - if (c != null && c instanceof Accessible) - { - AccessibleContext childCtx = c.getAccessibleContext(); - AccessibleJComponent.this.firePropertyChange - (AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, childCtx); - } - } - - /** - * Receives notification when a child component is removed from the - * JComponent and fires a PropertyChangeEvent on listeners registered - * with the AccessibleJComponent with a property name of - * {@link AccessibleContext#ACCESSIBLE_CHILD_PROPERTY}. - * - * @param event the container event - */ - public void componentRemoved(ContainerEvent event) - { - Component c = event.getChild(); - if (c != null && c instanceof Accessible) - { - AccessibleContext childCtx = c.getAccessibleContext(); - AccessibleJComponent.this.firePropertyChange - (AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, childCtx, null); - } - } - } - - private static final long serialVersionUID = -7047089700479897799L; - - /** - * Receives notification when a child component is added to the - * JComponent and fires a PropertyChangeEvent on listeners registered - * with the AccessibleJComponent. - * - * @specnote AccessibleAWTContainer has a protected field with the same - * name. Looks like a bug or nasty misdesign to me. - */ - protected ContainerListener accessibleContainerHandler; - - /** - * Receives notification if the focus on the JComponent changes and - * fires appropriate PropertyChangeEvents to listeners registered with - * the AccessibleJComponent. - * - * @specnote AccessibleAWTComponent has a protected field - * accessibleAWTFocusHandler. Looks like a bug or nasty misdesign - * to me. - */ - protected FocusListener accessibleFocusHandler; - - /** - * Creates a new AccessibleJComponent. - */ - protected AccessibleJComponent() - { - // Nothing to do here. - } - - /** - * Adds a property change listener to the list of registered listeners. - * - * This sets up the {@link #accessibleContainerHandler} and - * {@link #accessibleFocusHandler} fields and calls - * <code>super.addPropertyChangeListener(listener)</code>. - * - * @param listener the listener to add - */ - public void addPropertyChangeListener(PropertyChangeListener listener) - { - // Tests seem to indicate that this method also sets up the other two - // handlers. - if (accessibleContainerHandler == null) - { - accessibleContainerHandler = new AccessibleContainerHandler(); - addContainerListener(accessibleContainerHandler); - } - if (accessibleFocusHandler == null) - { - accessibleFocusHandler = new AccessibleFocusHandler(); - addFocusListener(accessibleFocusHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Removes a property change listener from the list of registered listeners. - * - * This uninstalls the {@link #accessibleContainerHandler} and - * {@link #accessibleFocusHandler} fields and calls - * <code>super.removePropertyChangeListener(listener)</code>. - * - * @param listener the listener to remove - */ - public void removePropertyChangeListener(PropertyChangeListener listener) - { - // Tests seem to indicate that this method also resets the other two - // handlers. - if (accessibleContainerHandler != null) - { - removeContainerListener(accessibleContainerHandler); - accessibleContainerHandler = null; - } - if (accessibleFocusHandler != null) - { - removeFocusListener(accessibleFocusHandler); - accessibleFocusHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /** - * Returns the number of accessible children of this object. - * - * @return the number of accessible children of this object - */ - public int getAccessibleChildrenCount() - { - // TODO: The functionality should be performed in the superclass. - // Find out why this is overridden. However, it is very well possible - // that this is left over from times when there was no such superclass - // method. - return super.getAccessibleChildrenCount(); - } - - /** - * Returns the accessible child component at index <code>i</code>. - * - * @param i the index of the accessible child to return - * - * @return the accessible child component at index <code>i</code> - */ - public Accessible getAccessibleChild(int i) - { - // TODO: The functionality should be performed in the superclass. - // Find out why this is overridden. However, it is very well possible - // that this is left over from times when there was no such superclass - // method. - return super.getAccessibleChild(i); - } - - /** - * Returns the accessible state set of this component. - * - * @return the accessible state set of this component - */ - public AccessibleStateSet getAccessibleStateSet() - { - // Note: While the java.awt.Component has an 'opaque' property, it - // seems that it is not added to the accessible state set there, even - // if this property is true. However, it is handled for JComponent, so - // we add it here. - AccessibleStateSet state = super.getAccessibleStateSet(); - if (isOpaque()) - state.add(AccessibleState.OPAQUE); - return state; - } - - /** - * Returns the localized name for this object. Generally this should - * almost never return {@link Component#getName()} since that is not - * a localized name. If the object is some kind of text component (like - * a menu item), then the value of the object may be returned. Also, if - * the object has a tooltip, the value of the tooltip may also be - * appropriate. - * - * @return the localized name for this object or <code>null</code> if this - * object has no name - */ - public String getAccessibleName() - { - String name = super.getAccessibleName(); - - // There are two fallbacks provided by the JComponent in the case the - // superclass returns null: - // - If the component is inside a titled border, then it inherits the - // name from the border title. - // - If the component is not inside a titled border but has a label - // (via JLabel.setLabelFor()), then it gets the name from the label's - // accessible context. - - if (name == null) - { - name = getTitledBorderText(); - } - - if (name == null) - { - Object l = getClientProperty(JLabel.LABEL_PROPERTY); - if (l instanceof Accessible) - { - AccessibleContext labelCtx = - ((Accessible) l).getAccessibleContext(); - name = labelCtx.getAccessibleName(); - } - } - - return name; - } - - /** - * Returns the localized description of this object. - * - * @return the localized description of this object or <code>null</code> - * if this object has no description - */ - public String getAccessibleDescription() - { - // There are two fallbacks provided by the JComponent in the case the - // superclass returns null: - // - If the component has a tooltip, then inherit the description from - // the tooltip. - // - If the component is not inside a titled border but has a label - // (via JLabel.setLabelFor()), then it gets the name from the label's - // accessible context. - String descr = super.getAccessibleDescription(); - - if (descr == null) - { - descr = getToolTipText(); - } - - if (descr == null) - { - Object l = getClientProperty(JLabel.LABEL_PROPERTY); - if (l instanceof Accessible) - { - AccessibleContext labelCtx = - ((Accessible) l).getAccessibleContext(); - descr = labelCtx.getAccessibleName(); - } - } - - return descr; - } - - /** - * Returns the accessible role of this component. - * - * @return the accessible role of this component - * - * @see AccessibleRole - */ - public AccessibleRole getAccessibleRole() - { - return AccessibleRole.SWING_COMPONENT; - } - - /** - * Recursivly searches a border hierarchy (starting at <code>border) for - * a titled border and returns the title if one is found, <code>null</code> - * otherwise. - * - * @param border the border to start search from - * - * @return the border title of a possibly found titled border - */ - protected String getBorderTitle(Border border) - { - String title = null; - if (border instanceof CompoundBorder) - { - CompoundBorder compound = (CompoundBorder) border; - Border inner = compound.getInsideBorder(); - title = getBorderTitle(inner); - if (title == null) - { - Border outer = compound.getOutsideBorder(); - title = getBorderTitle(outer); - } - } - else if (border instanceof TitledBorder) - { - TitledBorder titled = (TitledBorder) border; - title = titled.getTitle(); - } - return title; - } - - /** - * Returns the tooltip text for this accessible component. - * - * @return the tooltip text for this accessible component - */ - public String getToolTipText() - { - return JComponent.this.getToolTipText(); - } - - /** - * Returns the title of the border of this accessible component if - * this component has a titled border, otherwise returns <code>null</code>. - * - * @return the title of the border of this accessible component if - * this component has a titled border, otherwise returns - * <code>null</code> - */ - public String getTitledBorderText() - { - return getBorderTitle(getBorder()); - } - - /** - * Returns the keybindings associated with this accessible component or - * <code>null</code> if the component does not support key bindings. - * - * @return the keybindings associated with this accessible component - */ - public AccessibleKeyBinding getAccessibleKeyBinding() - { - // The reference implementation seems to always return null here, - // independent of the key bindings of the JComponent. So do we. - return null; - } - } - - /** - * A value between 0.0 and 1.0 indicating the preferred horizontal - * alignment of the component, relative to its siblings. The values - * {@link #LEFT_ALIGNMENT}, {@link #CENTER_ALIGNMENT}, and {@link - * #RIGHT_ALIGNMENT} can also be used, as synonyms for <code>0.0</code>, - * <code>0.5</code>, and <code>1.0</code>, respectively. Not all layout - * managers use this property. - * - * @see #getAlignmentX - * @see #setAlignmentX - * @see javax.swing.OverlayLayout - * @see javax.swing.BoxLayout - */ - float alignmentX = -1.0F; - - /** - * A value between 0.0 and 1.0 indicating the preferred vertical - * alignment of the component, relative to its siblings. The values - * {@link #TOP_ALIGNMENT}, {@link #CENTER_ALIGNMENT}, and {@link - * #BOTTOM_ALIGNMENT} can also be used, as synonyms for <code>0.0</code>, - * <code>0.5</code>, and <code>1.0</code>, respectively. Not all layout - * managers use this property. - * - * @see #getAlignmentY - * @see #setAlignmentY - * @see javax.swing.OverlayLayout - * @see javax.swing.BoxLayout - */ - float alignmentY = -1.0F; - - /** - * The border painted around this component. - * - * @see #paintBorder - */ - Border border; - - /** - * The popup menu for the component. - * - * @see #getComponentPopupMenu() - * @see #setComponentPopupMenu(JPopupMenu) - */ - JPopupMenu componentPopupMenu; - - /** - * A flag that controls whether the {@link #getComponentPopupMenu()} method - * looks to the component's parent when the <code>componentPopupMenu</code> - * field is <code>null</code>. - */ - boolean inheritsPopupMenu; - - /** - * <p>Whether to double buffer this component when painting. This flag - * should generally be <code>true</code>, to ensure good painting - * performance.</p> - * - * <p>All children of a double buffered component are painted into the - * double buffer automatically, so only the top widget in a window needs - * to be double buffered.</p> - * - * @see #setDoubleBuffered - * @see #isDoubleBuffered - * @see #paint - */ - boolean doubleBuffered = true; - - /** - * A set of flags indicating which debugging graphics facilities should - * be enabled on this component. The values should be a combination of - * {@link DebugGraphics#NONE_OPTION}, {@link DebugGraphics#LOG_OPTION}, - * {@link DebugGraphics#FLASH_OPTION}, or {@link - * DebugGraphics#BUFFERED_OPTION}. - * - * @see #setDebugGraphicsOptions - * @see #getDebugGraphicsOptions - * @see DebugGraphics - * @see #getComponentGraphics - */ - int debugGraphicsOptions; - - /** - * <p>This property controls two independent behaviors simultaneously.</p> - * - * <p>First, it controls whether to fill the background of this widget - * when painting its body. This affects calls to {@link - * JComponent#paintComponent}, which in turn calls {@link - * ComponentUI#update} on the component's {@link #ui} property. If the - * component is opaque during this call, the background will be filled - * before calling {@link ComponentUI#paint}. This happens merely as a - * convenience; you may fill the component's background yourself too, - * but there is no need to do so if you will be filling with the same - * color.</p> - * - * <p>Second, it the opaque property informs swing's repaint system - * whether it will be necessary to paint the components "underneath" this - * component, in Z-order. If the component is opaque, it is considered to - * completely occlude components "underneath" it, so they will not be - * repainted along with the opaque component.</p> - * - * <p>The default value for this property is <code>false</code>, but most - * components will want to set it to <code>true</code> when installing UI - * defaults in {@link ComponentUI#installUI}.</p> - * - * @see #setOpaque - * @see #isOpaque - * @see #paintComponent - */ - boolean opaque = false; - - /** - * The user interface delegate for this component. Event delivery and - * repainting of the component are usually delegated to this object. - * - * @see #setUI - * @see #getUIClassID - * @see #updateUI - */ - protected ComponentUI ui; - - /** - * A hint to the focus system that this component should or should not - * get focus. If this is <code>false</code>, swing will not try to - * request focus on this component; if <code>true</code>, swing might - * try to request focus, but the request might fail. Thus it is only - * a hint guiding swing's behavior. - * - * @see #requestFocus() - * @see #isRequestFocusEnabled - * @see #setRequestFocusEnabled - */ - boolean requestFocusEnabled; - - /** - * Flag indicating behavior of this component when the mouse is dragged - * outside the component and the mouse <em>stops moving</em>. If - * <code>true</code>, synthetic mouse events will be delivered on regular - * timed intervals, continuing off in the direction the mouse exited the - * component, until the mouse is released or re-enters the component. - * - * @see #setAutoscrolls - * @see #getAutoscrolls - */ - boolean autoscrolls = false; - - /** - * Indicates whether the current paint call is already double buffered or - * not. - */ - static boolean paintingDoubleBuffered = false; - - /** - * Indicates whether we are calling paintDoubleBuffered() from - * paintImmadiately (RepaintManager) or from paint() (AWT refresh). - */ - static boolean isRepainting = false; - - /** - * Listeners for events other than {@link PropertyChangeEvent} are - * handled by this listener list. PropertyChangeEvents are handled in - * {@link #changeSupport}. - */ - protected EventListenerList listenerList = new EventListenerList(); - - /** - * Handles VetoableChangeEvents. - */ - private VetoableChangeSupport vetoableChangeSupport; - - /** - * Storage for "client properties", which are key/value pairs associated - * with this component by a "client", such as a user application or a - * layout manager. This is lazily constructed when the component gets its - * first client property. - */ - private Hashtable clientProperties; - - private InputMap focusInputMap; - private InputMap ancestorInputMap; - private ComponentInputMap windowInputMap; - private ActionMap actionMap; - /** @since 1.3 */ - private boolean verifyInputWhenFocusTarget = true; - private InputVerifier inputVerifier; - - private TransferHandler transferHandler; - - /** - * Indicates if this component is currently painting a tile or not. - */ - private boolean paintingTile; - - /** - * A temporary buffer used for fast dragging of components. - */ - private Image dragBuffer; - - /** - * Indicates if the dragBuffer is already initialized. - */ - private boolean dragBufferInitialized; - - /** - * A cached Rectangle object to be reused. Be careful when you use that, - * so that it doesn't get modified in another context within the same - * method call chain. - */ - private static transient Rectangle rectCache; - - /** - * The default locale of the component. - * - * @see #getDefaultLocale - * @see #setDefaultLocale - */ - private static Locale defaultLocale; - - public static final String TOOL_TIP_TEXT_KEY = "ToolTipText"; - - /** - * Constant used to indicate that no condition has been assigned to a - * particular action. - * - * @see #registerKeyboardAction(ActionListener, KeyStroke, int) - */ - public static final int UNDEFINED_CONDITION = -1; - - /** - * Constant used to indicate that an action should be performed only when - * the component has focus. - * - * @see #registerKeyboardAction(ActionListener, KeyStroke, int) - */ - public static final int WHEN_FOCUSED = 0; - - /** - * Constant used to indicate that an action should be performed only when - * the component is an ancestor of the component which has focus. - * - * @see #registerKeyboardAction(ActionListener, KeyStroke, int) - */ - public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1; - - /** - * Constant used to indicate that an action should be performed only when - * the component is in the window which has focus. - * - * @see #registerKeyboardAction(ActionListener, KeyStroke, int) - */ - public static final int WHEN_IN_FOCUSED_WINDOW = 2; - - - /** - * Used to optimize painting. This is set in paintImmediately2() to specify - * the exact component path to be painted by paintChildren. - */ - Component paintChild; - - /** - * Indicates if the opaque property has been set by a client program or by - * the UI. - * - * @see #setUIProperty(String, Object) - * @see LookAndFeel#installProperty(JComponent, String, Object) - */ - private boolean clientOpaqueSet = false; - - /** - * Indicates if the autoscrolls property has been set by a client program or - * by the UI. - * - * @see #setUIProperty(String, Object) - * @see LookAndFeel#installProperty(JComponent, String, Object) - */ - private boolean clientAutoscrollsSet = false; - - /** - * Creates a new <code>JComponent</code> instance. - */ - public JComponent() - { - super(); - setDropTarget(new DropTarget()); - setLocale(getDefaultLocale()); - debugGraphicsOptions = DebugGraphics.NONE_OPTION; - setRequestFocusEnabled(true); - } - - /** - * Helper to lazily construct and return the client properties table. - * - * @return The current client properties table - * - * @see #clientProperties - * @see #getClientProperty - * @see #putClientProperty - */ - private Hashtable getClientProperties() - { - if (clientProperties == null) - clientProperties = new Hashtable(); - return clientProperties; - } - - /** - * Get a client property associated with this component and a particular - * key. - * - * @param key The key with which to look up the client property - * - * @return A client property associated with this object and key - * - * @see #clientProperties - * @see #getClientProperties - * @see #putClientProperty - */ - public final Object getClientProperty(Object key) - { - return getClientProperties().get(key); - } - - /** - * Add a client property <code>value</code> to this component, associated - * with <code>key</code>. If there is an existing client property - * associated with <code>key</code>, it will be replaced. A - * {@link PropertyChangeEvent} is sent to registered listeners (with the - * name of the property being <code>key.toString()</code>). - * - * @param key The key of the client property association to add - * @param value The value of the client property association to add - * - * @see #clientProperties - * @see #getClientProperties - * @see #getClientProperty - */ - public final void putClientProperty(Object key, Object value) - { - Hashtable t = getClientProperties(); - Object old = t.get(key); - if (value != null) - t.put(key, value); - else - t.remove(key); - - // When both old and new value are null, no event is fired. This is - // different from what firePropertyChange() normally does, so we add this - // check here. - if (old != null || value != null) - firePropertyChange(key.toString(), old, value); - } - - /** - * Unregister an <code>AncestorListener</code>. - * - * @param listener The listener to unregister - * - * @see #addAncestorListener - */ - public void removeAncestorListener(AncestorListener listener) - { - listenerList.remove(AncestorListener.class, listener); - } - - /** - * Unregister a <code>VetoableChangeChangeListener</code>. - * - * @param listener The listener to unregister - * - * @see #addVetoableChangeListener - */ - public void removeVetoableChangeListener(VetoableChangeListener listener) - { - if (vetoableChangeSupport != null) - vetoableChangeSupport.removeVetoableChangeListener(listener); - } - - /** - * Register an <code>AncestorListener</code>. - * - * @param listener The listener to register - * - * @see #removeVetoableChangeListener - */ - public void addAncestorListener(AncestorListener listener) - { - listenerList.add(AncestorListener.class, listener); - } - - /** - * Register a <code>VetoableChangeListener</code>.... [truncated message content] |