< prev index next >
src/java.desktop/share/classes/javax/swing/SwingUtilities.java
Print this page
*** 69,80 ****
*/
private static boolean checkedSuppressDropSupport;
/**
! * Returns true if <code>setTransferHandler</code> should change the
! * <code>DropTarget</code>.
*/
private static boolean getSuppressDropTarget() {
if (!checkedSuppressDropSupport) {
suppressDropSupport = Boolean.valueOf(
AccessController.doPrivileged(
--- 69,80 ----
*/
private static boolean checkedSuppressDropSupport;
/**
! * Returns true if {@code setTransferHandler} should change the
! * {@code DropTarget}.
*/
private static boolean getSuppressDropTarget() {
if (!checkedSuppressDropSupport) {
suppressDropSupport = Boolean.valueOf(
AccessController.doPrivileged(
*** 128,145 ****
return b;
}
/**
! * Returns the first <code>Window </code> ancestor of <code>c</code>, or
! * {@code null} if <code>c</code> is not contained inside a <code>Window</code>.
*
! * @param c <code>Component</code> to get <code>Window</code> ancestor
* of.
! * @return the first <code>Window </code> ancestor of <code>c</code>, or
! * {@code null} if <code>c</code> is not contained inside a
! * <code>Window</code>.
* @since 1.3
*/
public static Window getWindowAncestor(Component c) {
for(Container p = c.getParent(); p != null; p = p.getParent()) {
if (p instanceof Window) {
--- 128,145 ----
return b;
}
/**
! * Returns the first {@code Window} ancestor of {@code c}, or
! * {@code null} if {@code c} is not contained inside a {@code Window}.
*
! * @param c {@code Component} to get {@code Window} ancestor
* of.
! * @return the first {@code Window} ancestor of {@code c}, or
! * {@code null} if {@code c} is not contained inside a
! * {@code Window}.
* @since 1.3
*/
public static Window getWindowAncestor(Component c) {
for(Container p = c.getParent(); p != null; p = p.getParent()) {
if (p instanceof Window) {
*** 148,158 ****
}
return null;
}
/**
! * Converts the location <code>x</code> <code>y</code> to the
* parents coordinate system, returning the location.
*/
static Point convertScreenLocationToParent(Container parent,int x, int y) {
for (Container p = parent; p != null; p = p.getParent()) {
if (p instanceof Window) {
--- 148,158 ----
}
return null;
}
/**
! * Converts the location {@code x y} to the
* parents coordinate system, returning the location.
*/
static Point convertScreenLocationToParent(Container parent,int x, int y) {
for (Container p = parent; p != null; p = p.getParent()) {
if (p instanceof Window) {
*** 164,180 ****
}
throw new Error("convertScreenLocationToParent: no window ancestor");
}
/**
! * Convert a <code>aPoint</code> in <code>source</code> coordinate system to
! * <code>destination</code> coordinate system.
! * If <code>source</code> is {@code null}, <code>aPoint</code> is assumed to be in <code>destination</code>'s
* root component coordinate system.
! * If <code>destination</code> is {@code null}, <code>aPoint</code> will be converted to <code>source</code>'s
* root component coordinate system.
! * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>aPoint</code>
* without any conversion.
*
* @param source the source component
* @param aPoint the point
* @param destination the destination component
--- 164,180 ----
}
throw new Error("convertScreenLocationToParent: no window ancestor");
}
/**
! * Convert a {@code aPoint} in {@code source} coordinate system to
! * {@code destination} coordinate system.
! * If {@code source} is {@code null}, {@code aPoint} is assumed to be in {@code destination}'s
* root component coordinate system.
! * If {@code destination} is {@code null}, {@code aPoint} will be converted to {@code source}'s
* root component coordinate system.
! * If both {@code source} and {@code destination} are {@code null}, return {@code aPoint}
* without any conversion.
*
* @param source the source component
* @param aPoint the point
* @param destination the destination component
*** 201,217 ****
convertPointFromScreen(p,destination);
return p;
}
/**
! * Convert the point <code>(x,y)</code> in <code>source</code> coordinate system to
! * <code>destination</code> coordinate system.
! * If <code>source</code> is {@code null}, <code>(x,y)</code> is assumed to be in <code>destination</code>'s
* root component coordinate system.
! * If <code>destination</code> is {@code null}, <code>(x,y)</code> will be converted to <code>source</code>'s
* root component coordinate system.
! * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>(x,y)</code>
* without any conversion.
*
* @param source the source component
* @param x the x-coordinate of the point
* @param y the y-coordinate of the point
--- 201,217 ----
convertPointFromScreen(p,destination);
return p;
}
/**
! * Convert the point {@code (x,y)} in {@code source} coordinate system to
! * {@code destination} coordinate system.
! * If {@code source} is {@code null}, {@code (x,y)} is assumed to be in {@code destination}'s
* root component coordinate system.
! * If {@code destination} is {@code null}, {@code (x,y)} will be converted to {@code source}'s
* root component coordinate system.
! * If both {@code source} and {@code destination} are {@code null}, return {@code (x,y)}
* without any conversion.
*
* @param source the source component
* @param x the x-coordinate of the point
* @param y the y-coordinate of the point
*** 223,239 ****
Point point = new Point(x,y);
return convertPoint(source,point,destination);
}
/**
! * Convert the rectangle <code>aRectangle</code> in <code>source</code> coordinate system to
! * <code>destination</code> coordinate system.
! * If <code>source</code> is {@code null}, <code>aRectangle</code> is assumed to be in <code>destination</code>'s
* root component coordinate system.
! * If <code>destination</code> is {@code null}, <code>aRectangle</code> will be converted to <code>source</code>'s
* root component coordinate system.
! * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>aRectangle</code>
* without any conversion.
*
* @param source the source component
* @param aRectangle a rectangle
* @param destination the destination component
--- 223,239 ----
Point point = new Point(x,y);
return convertPoint(source,point,destination);
}
/**
! * Convert the rectangle {@code aRectangle} in {@code source} coordinate system to
! * {@code destination} coordinate system.
! * If {@code source} is {@code null}, {@code aRectangle} is assumed to be in {@code destination}'s
* root component coordinate system.
! * If {@code destination} is {@code null}, {@code aRectangle} will be converted to {@code source}'s
* root component coordinate system.
! * If both {@code source} and {@code destination} are {@code null}, return {@code aRectangle}
* without any conversion.
*
* @param source the source component
* @param aRectangle a rectangle
* @param destination the destination component
*** 245,257 ****
point = convertPoint(source,point,destination);
return new Rectangle(point.x,point.y,aRectangle.width,aRectangle.height);
}
/**
! * Convenience method for searching above <code>comp</code> in the
! * component hierarchy and returns the first object of class <code>c</code> it
! * finds. Can return {@code null}, if a class <code>c</code> cannot be found.
*
* @param c the class of a component
* @param comp the component
*
* @return the ancestor of the {@code comp},
--- 245,257 ----
point = convertPoint(source,point,destination);
return new Rectangle(point.x,point.y,aRectangle.width,aRectangle.height);
}
/**
! * Convenience method for searching above {@code comp} in the
! * component hierarchy and returns the first object of class {@code c} it
! * finds. Can return {@code null}, if a class {@code c} cannot be found.
*
* @param c the class of a component
* @param comp the component
*
* @return the ancestor of the {@code comp},
*** 267,279 ****
parent = parent.getParent();
return parent;
}
/**
! * Convenience method for searching above <code>comp</code> in the
! * component hierarchy and returns the first object of <code>name</code> it
! * finds. Can return {@code null}, if <code>name</code> cannot be found.
*
* @param name the name of a component
* @param comp the component
*
* @return the ancestor of the {@code comp},
--- 267,279 ----
parent = parent.getParent();
return parent;
}
/**
! * Convenience method for searching above {@code comp} in the
! * component hierarchy and returns the first object of {@code name} it
! * finds. Can return {@code null}, if {@code name} cannot be found.
*
* @param name the name of a component
* @param comp the component
*
* @return the ancestor of the {@code comp},
*** 288,303 ****
parent = parent.getParent();
return parent;
}
/**
! * Returns the deepest visible descendent Component of <code>parent</code>
! * that contains the location <code>x</code>, <code>y</code>.
! * If <code>parent</code> does not contain the specified location,
! * then <code>null</code> is returned. If <code>parent</code> is not a
! * container, or none of <code>parent</code>'s visible descendents
! * contain the specified location, <code>parent</code> is returned.
*
* @param parent the root component to begin the search
* @param x the x target location
* @param y the y target location
*
--- 288,303 ----
parent = parent.getParent();
return parent;
}
/**
! * Returns the deepest visible descendent Component of {@code parent}
! * that contains the location {@code x}, {@code y}.
! * If {@code parent} does not contain the specified location,
! * then {@code null} is returned. If {@code parent} is not a
! * container, or none of {@code parent}'s visible descendents
! * contain the specified location, {@code parent} is returned.
*
* @param parent the root component to begin the search
* @param x the x target location
* @param y the y target location
*
*** 326,344 ****
return parent;
}
/**
! * Returns a MouseEvent similar to <code>sourceEvent</code> except that its x
! * and y members have been converted to <code>destination</code>'s coordinate
! * system. If <code>source</code> is {@code null}, <code>sourceEvent</code> x and y members
! * are assumed to be into <code>destination</code>'s root component coordinate system.
! * If <code>destination</code> is <code>null</code>, the
! * returned MouseEvent will be in <code>source</code>'s coordinate system.
! * <code>sourceEvent</code> will not be changed. A new event is returned.
! * the <code>source</code> field of the returned event will be set
! * to <code>destination</code> if destination is non-{@code null}
* use the translateMouseEvent() method to translate a mouse event from
* one component to another without changing the source.
*
* @param source the source component
* @param sourceEvent the source mouse event
--- 326,344 ----
return parent;
}
/**
! * Returns a MouseEvent similar to {@code sourceEvent} except that its x
! * and y members have been converted to {@code destination}'s coordinate
! * system. If {@code source} is {@code null}, {@code sourceEvent} x and y members
! * are assumed to be into {@code destination}'s root component coordinate system.
! * If {@code destination} is {@code null}, the
! * returned MouseEvent will be in {@code source}'s coordinate system.
! * {@code sourceEvent} will not be changed. A new event is returned.
! * the {@code source} field of the returned event will be set
! * to {@code destination} if destination is non-{@code null}
* use the translateMouseEvent() method to translate a mouse event from
* one component to another without changing the source.
*
* @param source the source component
* @param sourceEvent the source mouse event
*** 486,506 ****
c = c.getParent();
} while(c != null);
}
/**
! * Returns the first <code>Window </code> ancestor of <code>c</code>, or
! * {@code null} if <code>c</code> is not contained inside a <code>Window</code>.
* <p>
* Note: This method provides the same functionality as
! * <code>getWindowAncestor</code>.
*
! * @param c <code>Component</code> to get <code>Window</code> ancestor
* of.
! * @return the first <code>Window </code> ancestor of <code>c</code>, or
! * {@code null} if <code>c</code> is not contained inside a
! * <code>Window</code>.
*/
public static Window windowForComponent(Component c) {
return getWindowAncestor(c);
}
--- 486,506 ----
c = c.getParent();
} while(c != null);
}
/**
! * Returns the first {@code Window} ancestor of {@code c}, or
! * {@code null} if {@code c} is not contained inside a {@code Window}.
* <p>
* Note: This method provides the same functionality as
! * {@code getWindowAncestor}.
*
! * @param c {@code Component} to get {@code Window} ancestor
* of.
! * @return the first {@code Window} ancestor of {@code c}, or
! * {@code null} if {@code c} is not contained inside a
! * {@code Window}.
*/
public static Window windowForComponent(Component c) {
return getWindowAncestor(c);
}
*** 532,542 ****
* @param y the Y coordinate of the first rectangle's top-left point
* @param width the width of the first rectangle
* @param height the height of the first rectangle
* @param dest the second rectangle
*
! * @return <code>dest</code>, modified to specify the intersection
*/
public static Rectangle computeIntersection(int x,int y,int width,int height,Rectangle dest) {
int x1 = (x > dest.x) ? x : dest.x;
int x2 = ((x+width) < (dest.x + dest.width)) ? (x+width) : (dest.x + dest.width);
int y1 = (y > dest.y) ? y : dest.y;
--- 532,542 ----
* @param y the Y coordinate of the first rectangle's top-left point
* @param width the width of the first rectangle
* @param height the height of the first rectangle
* @param dest the second rectangle
*
! * @return {@code dest}, modified to specify the intersection
*/
public static Rectangle computeIntersection(int x,int y,int width,int height,Rectangle dest) {
int x1 = (x > dest.x) ? x : dest.x;
int x2 = ((x+width) < (dest.x + dest.width)) ? (x+width) : (dest.x + dest.width);
int y1 = (y > dest.y) ? y : dest.y;
*** 563,573 ****
* @param y the y-coordinate of the first rectangle
* @param width the width of the first rectangle
* @param height the height of the first rectangle
* @param dest the coordinates of the second rectangle; the union
* of the two rectangles is returned in this rectangle
! * @return the <code>dest</code> <code>Rectangle</code>
*/
public static Rectangle computeUnion(int x,int y,int width,int height,Rectangle dest) {
int x1 = (x < dest.x) ? x : dest.x;
int x2 = ((x+width) > (dest.x + dest.width)) ? (x+width) : (dest.x + dest.width);
int y1 = (y < dest.y) ? y : dest.y;
--- 563,573 ----
* @param y the y-coordinate of the first rectangle
* @param width the width of the first rectangle
* @param height the height of the first rectangle
* @param dest the coordinates of the second rectangle; the union
* of the two rectangles is returned in this rectangle
! * @return the {@code dest Rectangle}
*/
public static Rectangle computeUnion(int x,int y,int width,int height,Rectangle dest) {
int x1 = (x < dest.x) ? x : dest.x;
int x2 = ((x+width) > (dest.x + dest.width)) ? (x+width) : (dest.x + dest.width);
int y1 = (y < dest.y) ? y : dest.y;
*** 580,590 ****
return dest;
}
/**
* Convenience returning an array of rect representing the regions within
! * <code>rectA</code> that do not overlap with <code>rectB</code>. If the
* two Rects do not overlap, returns an empty array
*
* @param rectA the first rectangle
* @param rectB the second rectangle
*
--- 580,590 ----
return dest;
}
/**
* Convenience returning an array of rect representing the regions within
! * {@code rectA} that do not overlap with {@code rectB}. If the
* two Rects do not overlap, returns an empty array
*
* @param rectA the first rectangle
* @param rectB the second rectangle
*
*** 1213,1258 ****
return text;
}
/**
! * Paints a component to the specified <code>Graphics</code>.
* This method is primarily useful to render
! * <code>Component</code>s that don't exist as part of the visible
* containment hierarchy, but are used for rendering. For
* example, if you are doing your own rendering and want to render
* some text (or even HTML), you could make use of
! * <code>JLabel</code>'s text rendering support and have it paint
* directly by way of this method, without adding the label to the
* visible containment hierarchy.
* <p>
! * This method makes use of <code>CellRendererPane</code> to handle
* the actual painting, and is only recommended if you use one
* component for rendering. If you make use of multiple components
! * to handle the rendering, as <code>JTable</code> does, use
! * <code>CellRendererPane</code> directly. Otherwise, as described
! * below, you could end up with a <code>CellRendererPane</code>
! * per <code>Component</code>.
* <p>
! * If <code>c</code>'s parent is not a <code>CellRendererPane</code>,
! * a new <code>CellRendererPane</code> is created, <code>c</code> is
! * added to it, and the <code>CellRendererPane</code> is added to
! * <code>p</code>. If <code>c</code>'s parent is a
! * <code>CellRendererPane</code> and the <code>CellRendererPane</code>s
! * parent is not <code>p</code>, it is added to <code>p</code>.
* <p>
! * The component should either descend from <code>JComponent</code>
* or be another kind of lightweight component.
* A lightweight component is one whose "lightweight" property
! * (returned by the <code>Component</code>
! * <code>isLightweight</code> method)
* is true. If the Component is not lightweight, bad things map happen:
* crashes, exceptions, painting problems...
*
! * @param g the <code>Graphics</code> object to draw on
! * @param c the <code>Component</code> to draw
! * @param p the intermediate <code>Container</code>
* @param x an int specifying the left side of the area draw in, in pixels,
* measured from the left edge of the graphics context
* @param y an int specifying the top of the area to draw in, in pixels
* measured down from the top edge of the graphics context
* @param w an int specifying the width of the area draw in, in pixels
--- 1213,1258 ----
return text;
}
/**
! * Paints a component to the specified {@code Graphics}.
* This method is primarily useful to render
! * {@code Component}s that don't exist as part of the visible
* containment hierarchy, but are used for rendering. For
* example, if you are doing your own rendering and want to render
* some text (or even HTML), you could make use of
! * {@code JLabel}'s text rendering support and have it paint
* directly by way of this method, without adding the label to the
* visible containment hierarchy.
* <p>
! * This method makes use of {@code CellRendererPane} to handle
* the actual painting, and is only recommended if you use one
* component for rendering. If you make use of multiple components
! * to handle the rendering, as {@code JTable} does, use
! * {@code CellRendererPane} directly. Otherwise, as described
! * below, you could end up with a {@code CellRendererPane}
! * per {@code Component}.
* <p>
! * If {@code c}'s parent is not a {@code CellRendererPane},
! * a new {@code CellRendererPane} is created, {@code c} is
! * added to it, and the {@code CellRendererPane} is added to
! * {@code p}. If {@code c}'s parent is a
! * {@code CellRendererPane} and the {@code CellRendererPane}s
! * parent is not {@code p}, it is added to {@code p}.
* <p>
! * The component should either descend from {@code JComponent}
* or be another kind of lightweight component.
* A lightweight component is one whose "lightweight" property
! * (returned by the {@code Component}
! * {@code isLightweight} method)
* is true. If the Component is not lightweight, bad things map happen:
* crashes, exceptions, painting problems...
*
! * @param g the {@code Graphics} object to draw on
! * @param c the {@code Component} to draw
! * @param p the intermediate {@code Container}
* @param x an int specifying the left side of the area draw in, in pixels,
* measured from the left edge of the graphics context
* @param y an int specifying the top of the area to draw in, in pixels
* measured down from the top edge of the graphics context
* @param w an int specifying the width of the area draw in, in pixels
*** 1264,1294 ****
public static void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) {
getCellRendererPane(c, p).paintComponent(g, c, p, x, y, w, h,false);
}
/**
! * Paints a component to the specified <code>Graphics</code>. This
* is a cover method for
* {@link #paintComponent(Graphics,Component,Container,int,int,int,int)}.
* Refer to it for more information.
*
! * @param g the <code>Graphics</code> object to draw on
! * @param c the <code>Component</code> to draw
! * @param p the intermediate <code>Container</code>
! * @param r the <code>Rectangle</code> to draw in
*
* @see #paintComponent(Graphics,Component,Container,int,int,int,int)
* @see CellRendererPane
*/
public static void paintComponent(Graphics g, Component c, Container p, Rectangle r) {
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
}
/*
! * Ensures that cell renderer <code>c</code> has a
! * <code>ComponentShell</code> parent and that
* the shell's parent is p.
*/
private static CellRendererPane getCellRendererPane(Component c, Container p) {
Container shell = c.getParent();
if (shell instanceof CellRendererPane) {
--- 1264,1294 ----
public static void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) {
getCellRendererPane(c, p).paintComponent(g, c, p, x, y, w, h,false);
}
/**
! * Paints a component to the specified {@code Graphics}. This
* is a cover method for
* {@link #paintComponent(Graphics,Component,Container,int,int,int,int)}.
* Refer to it for more information.
*
! * @param g the {@code Graphics} object to draw on
! * @param c the {@code Component} to draw
! * @param p the intermediate {@code Container}
! * @param r the {@code Rectangle} to draw in
*
* @see #paintComponent(Graphics,Component,Container,int,int,int,int)
* @see CellRendererPane
*/
public static void paintComponent(Graphics g, Component c, Container p, Rectangle r) {
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
}
/*
! * Ensures that cell renderer {@code c} has a
! * {@code ComponentShell} parent and that
* the shell's parent is p.
*/
private static CellRendererPane getCellRendererPane(Component c, Container p) {
Container shell = c.getParent();
if (shell instanceof CellRendererPane) {
*** 1303,1313 ****
return (CellRendererPane)shell;
}
/**
* A simple minded look and feel change: ask each node in the tree
! * to <code>updateUI()</code> -- that is, to initialize its UI property
* with the current look and feel.
*
* @param c the component
*/
public static void updateComponentTreeUI(Component c) {
--- 1303,1313 ----
return (CellRendererPane)shell;
}
/**
* A simple minded look and feel change: ask each node in the tree
! * to {@code updateUI()} -- that is, to initialize its UI property
* with the current look and feel.
*
* @param c the component
*/
public static void updateComponentTreeUI(Component c) {
*** 1344,1355 ****
/**
* Causes <i>doRun.run()</i> to be executed asynchronously on the
* AWT event dispatching thread. This will happen after all
* pending AWT events have been processed. This method should
* be used when an application thread needs to update the GUI.
! * In the following example the <code>invokeLater</code> call queues
! * the <code>Runnable</code> object <code>doHelloWorld</code>
* on the event dispatching thread and
* then prints a message.
* <pre>
* Runnable doHelloWorld = new Runnable() {
* public void run() {
--- 1344,1355 ----
/**
* Causes <i>doRun.run()</i> to be executed asynchronously on the
* AWT event dispatching thread. This will happen after all
* pending AWT events have been processed. This method should
* be used when an application thread needs to update the GUI.
! * In the following example the {@code invokeLater} call queues
! * the {@code Runnable} object {@code doHelloWorld}
* on the event dispatching thread and
* then prints a message.
* <pre>
* Runnable doHelloWorld = new Runnable() {
* public void run() {
*** 1368,1378 ****
* <p>
* Additional documentation and examples for this method can be
* found in
* <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
* <p>
! * As of 1.3 this method is just a cover for <code>java.awt.EventQueue.invokeLater()</code>.
* <p>
* Unlike the rest of Swing, this method can be invoked from any thread.
*
* @param doRun the instance of {@code Runnable}
* @see #invokeAndWait
--- 1368,1378 ----
* <p>
* Additional documentation and examples for this method can be
* found in
* <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
* <p>
! * As of 1.3 this method is just a cover for {@code java.awt.EventQueue.invokeLater()}.
* <p>
* Unlike the rest of Swing, this method can be invoked from any thread.
*
* @param doRun the instance of {@code Runnable}
* @see #invokeAndWait
*** 1381,1398 ****
EventQueue.invokeLater(doRun);
}
/**
! * Causes <code>doRun.run()</code> to be executed synchronously on the
* AWT event dispatching thread. This call blocks until
* all pending AWT events have been processed and (then)
! * <code>doRun.run()</code> returns. This method should
* be used when an application thread needs to update the GUI.
* It shouldn't be called from the event dispatching thread.
* Here's an example that creates a new application thread
! * that uses <code>invokeAndWait</code> to print a string from the event
* dispatching thread and then, when that's finished, print
* a string from the application thread.
* <pre>
* final Runnable doHelloWorld = new Runnable() {
* public void run() {
--- 1381,1398 ----
EventQueue.invokeLater(doRun);
}
/**
! * Causes {@code doRun.run()} to be executed synchronously on the
* AWT event dispatching thread. This call blocks until
* all pending AWT events have been processed and (then)
! * {@code doRun.run()} returns. This method should
* be used when an application thread needs to update the GUI.
* It shouldn't be called from the event dispatching thread.
* Here's an example that creates a new application thread
! * that uses {@code invokeAndWait} to print a string from the event
* dispatching thread and then, when that's finished, print
* a string from the application thread.
* <pre>
* final Runnable doHelloWorld = new Runnable() {
* public void run() {
*** 1411,1438 ****
* System.out.println("Finished on " + Thread.currentThread());
* }
* };
* appThread.start();
* </pre>
! * Note that if the <code>Runnable.run</code> method throws an
* uncaught exception
* (on the event dispatching thread) it's caught and rethrown, as
! * an <code>InvocationTargetException</code>, on the caller's thread.
* <p>
* Additional documentation and examples for this method can be
* found in
* <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
* <p>
* As of 1.3 this method is just a cover for
! * <code>java.awt.EventQueue.invokeAndWait()</code>.
*
* @param doRun the instance of {@code Runnable}
* @exception InterruptedException if we're interrupted while waiting for
* the event dispatching thread to finish executing
! * <code>doRun.run()</code>
* @exception InvocationTargetException if an exception is thrown
! * while running <code>doRun</code>
*
* @see #invokeLater
*/
public static void invokeAndWait(final Runnable doRun)
throws InterruptedException, InvocationTargetException
--- 1411,1438 ----
* System.out.println("Finished on " + Thread.currentThread());
* }
* };
* appThread.start();
* </pre>
! * Note that if the {@code Runnable.run} method throws an
* uncaught exception
* (on the event dispatching thread) it's caught and rethrown, as
! * an {@code InvocationTargetException}, on the caller's thread.
* <p>
* Additional documentation and examples for this method can be
* found in
* <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
* <p>
* As of 1.3 this method is just a cover for
! * {@code java.awt.EventQueue.invokeAndWait()}.
*
* @param doRun the instance of {@code Runnable}
* @exception InterruptedException if we're interrupted while waiting for
* the event dispatching thread to finish executing
! * {@code doRun.run()}
* @exception InvocationTargetException if an exception is thrown
! * while running {@code doRun}
*
* @see #invokeLater
*/
public static void invokeAndWait(final Runnable doRun)
throws InterruptedException, InvocationTargetException
*** 1442,1452 ****
/**
* Returns true if the current thread is an AWT event dispatching thread.
* <p>
* As of 1.3 this method is just a cover for
! * <code>java.awt.EventQueue.isDispatchThread()</code>.
*
* @return true if the current thread is an AWT event dispatching thread
*/
public static boolean isEventDispatchThread()
{
--- 1442,1452 ----
/**
* Returns true if the current thread is an AWT event dispatching thread.
* <p>
* As of 1.3 this method is just a cover for
! * {@code java.awt.EventQueue.isDispatchThread()}.
*
* @return true if the current thread is an AWT event dispatching thread
*/
public static boolean isEventDispatchThread()
{
*** 1473,1490 ****
public static int getAccessibleIndexInParent(Component c) {
return c.getAccessibleContext().getAccessibleIndexInParent();
}
/**
! * Returns the <code>Accessible</code> child contained at the
! * local coordinate <code>Point</code>, if one exists.
! * Otherwise returns <code>null</code>.
*
* @param c the component
* @param p the local coordinate
! * @return the <code>Accessible</code> at the specified location,
! * if it exists; otherwise <code>null</code>
*/
public static Accessible getAccessibleAt(Component c, Point p) {
if (c instanceof Container) {
return c.getAccessibleContext().getAccessibleComponent().getAccessibleAt(p);
} else if (c instanceof Accessible) {
--- 1473,1490 ----
public static int getAccessibleIndexInParent(Component c) {
return c.getAccessibleContext().getAccessibleIndexInParent();
}
/**
! * Returns the {@code Accessible} child contained at the
! * local coordinate {@code Point}, if one exists.
! * Otherwise returns {@code null}.
*
* @param c the component
* @param p the local coordinate
! * @return the {@code Accessible} at the specified location,
! * if it exists; otherwise {@code null}
*/
public static Accessible getAccessibleAt(Component c, Point p) {
if (c instanceof Container) {
return c.getAccessibleContext().getAccessibleComponent().getAccessibleAt(p);
} else if (c instanceof Accessible) {
*** 1565,1586 ****
public static Accessible getAccessibleChild(Component c, int i) {
return c.getAccessibleContext().getAccessibleChild(i);
}
/**
! * Return the child <code>Component</code> of the specified
! * <code>Component</code> that is the focus owner, if any.
*
! * @param c the root of the <code>Component</code> hierarchy to
* search for the focus owner
! * @return the focus owner, or <code>null</code> if there is no focus
! * owner, or if the focus owner is not <code>comp</code>, or a
! * descendant of <code>comp</code>
*
* @see java.awt.KeyboardFocusManager#getFocusOwner
* @deprecated As of 1.4, replaced by
! * <code>KeyboardFocusManager.getFocusOwner()</code>.
*/
@Deprecated
public static Component findFocusOwner(Component c) {
Component focusOwner = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getFocusOwner();
--- 1565,1586 ----
public static Accessible getAccessibleChild(Component c, int i) {
return c.getAccessibleContext().getAccessibleChild(i);
}
/**
! * Return the child {@code Component} of the specified
! * {@code Component} that is the focus owner, if any.
*
! * @param c the root of the {@code Component} hierarchy to
* search for the focus owner
! * @return the focus owner, or {@code null} if there is no focus
! * owner, or if the focus owner is not {@code comp}, or a
! * descendant of {@code comp}
*
* @see java.awt.KeyboardFocusManager#getFocusOwner
* @deprecated As of 1.4, replaced by
! * {@code KeyboardFocusManager.getFocusOwner()}.
*/
@Deprecated
public static Component findFocusOwner(Component c) {
Component focusOwner = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getFocusOwner();
*** 1646,1663 ****
}
return null;
}
/**
! * Process the key bindings for the <code>Component</code> associated with
! * <code>event</code>. This method is only useful if
! * <code>event.getComponent()</code> does not descend from
! * <code>JComponent</code>, or your are not invoking
! * <code>super.processKeyEvent</code> from within your
! * <code>JComponent</code> subclass. <code>JComponent</code>
* automatically processes bindings from within its
! * <code>processKeyEvent</code> method, hence you rarely need
* to directly invoke this method.
*
* @param event KeyEvent used to identify which bindings to process, as
* well as which Component has focus.
* @return true if a binding has found and processed
--- 1646,1663 ----
}
return null;
}
/**
! * Process the key bindings for the {@code Component} associated with
! * {@code event}. This method is only useful if
! * {@code event.getComponent()} does not descend from
! * {@code JComponent}, or your are not invoking
! * {@code super.processKeyEvent} from within your
! * {@code JComponent} subclass. {@code JComponent}
* automatically processes bindings from within its
! * {@code processKeyEvent} method, hence you rarely need
* to directly invoke this method.
*
* @param event KeyEvent used to identify which bindings to process, as
* well as which Component has focus.
* @return true if a binding has found and processed
*** 1694,1723 ****
}
return false;
}
/**
! * Returns true if the <code>e</code> is a valid KeyEvent to use in
* processing the key bindings associated with JComponents.
*/
static boolean isValidKeyEventForKeyBindings(KeyEvent e) {
return true;
}
/**
! * Invokes <code>actionPerformed</code> on <code>action</code> if
! * <code>action</code> is enabled (and non-{@code null}). The command for the
* ActionEvent is determined by:
* <ol>
* <li>If the action was registered via
! * <code>registerKeyboardAction</code>, then the command string
* passed in ({@code null} will be used if {@code null} was passed in).
* <li>Action value with name Action.ACTION_COMMAND_KEY, unless {@code null}.
! * <li>String value of the KeyEvent, unless <code>getKeyChar</code>
* returns KeyEvent.CHAR_UNDEFINED..
* </ol>
! * This will return true if <code>action</code> is non-{@code null} and
* actionPerformed is invoked on it.
*
* @param action an action
* @param ks a key stroke
* @param event a key event
--- 1694,1723 ----
}
return false;
}
/**
! * Returns true if the {@code e} is a valid KeyEvent to use in
* processing the key bindings associated with JComponents.
*/
static boolean isValidKeyEventForKeyBindings(KeyEvent e) {
return true;
}
/**
! * Invokes {@code actionPerformed} on {@code action} if
! * {@code action} is enabled (and non-{@code null}). The command for the
* ActionEvent is determined by:
* <ol>
* <li>If the action was registered via
! * {@code registerKeyboardAction}, then the command string
* passed in ({@code null} will be used if {@code null} was passed in).
* <li>Action value with name Action.ACTION_COMMAND_KEY, unless {@code null}.
! * <li>String value of the KeyEvent, unless {@code getKeyChar}
* returns KeyEvent.CHAR_UNDEFINED..
* </ol>
! * This will return true if {@code action} is non-{@code null} and
* actionPerformed is invoked on it.
*
* @param action an action
* @param ks a key stroke
* @param event a key event
*** 1776,1787 ****
return true;
}
/**
! * Convenience method to change the UI InputMap for <code>component</code>
! * to <code>uiInputMap</code>. If <code>uiInputMap</code> is {@code null},
* this removes any previously installed UI InputMap.
*
* @param component a component
* @param type a type
* @param uiInputMap an {@code InputMap}
--- 1776,1787 ----
return true;
}
/**
! * Convenience method to change the UI InputMap for {@code component}
! * to {@code uiInputMap}. If {@code uiInputMap} is {@code null},
* this removes any previously installed UI InputMap.
*
* @param component a component
* @param type a type
* @param uiInputMap an {@code InputMap}
*** 1801,1812 ****
}
}
/**
! * Convenience method to change the UI ActionMap for <code>component</code>
! * to <code>uiActionMap</code>. If <code>uiActionMap</code> is {@code null},
* this removes any previously installed UI ActionMap.
*
* @param component a component
* @param uiActionMap an {@code ActionMap}
* @since 1.3
--- 1801,1812 ----
}
}
/**
! * Convenience method to change the UI ActionMap for {@code component}
! * to {@code uiActionMap}. If {@code uiActionMap} is {@code null},
* this removes any previously installed UI ActionMap.
*
* @param component a component
* @param uiActionMap an {@code ActionMap}
* @since 1.3
*** 1826,1836 ****
}
/**
* Returns the InputMap provided by the UI for condition
! * <code>condition</code> in component <code>component</code>.
* <p>This will return {@code null} if the UI has not installed an InputMap
* of the specified type.
*
* @param component a component
* @param condition a condition
--- 1826,1836 ----
}
/**
* Returns the InputMap provided by the UI for condition
! * {@code condition} in component {@code component}.
* <p>This will return {@code null} if the UI has not installed an InputMap
* of the specified type.
*
* @param component a component
* @param condition a condition
*** 1851,1861 ****
return null;
}
/**
* Returns the ActionMap provided by the UI
! * in component <code>component</code>.
* <p>This will return {@code null} if the UI has not installed an ActionMap.
*
* @param component a component
* @return the {@code ActionMap} provided by the UI in the component,
* or {@code null} if the UI has not installed an ActionMap.
--- 1851,1861 ----
return null;
}
/**
* Returns the ActionMap provided by the UI
! * in component {@code component}.
* <p>This will return {@code null} if the UI has not installed an ActionMap.
*
* @param component a component
* @return the {@code ActionMap} provided by the UI in the component,
* or {@code null} if the UI has not installed an ActionMap.
*** 2011,2032 ****
private SwingUtilities() {
throw new Error("SwingUtilities is just a container for static methods");
}
/**
! * Returns true if the Icon <code>icon</code> is an instance of
! * ImageIcon, and the image it contains is the same as <code>image</code>.
*/
static boolean doesIconReferenceImage(Icon icon, Image image) {
Image iconImage = (icon != null && (icon instanceof ImageIcon)) ?
((ImageIcon)icon).getImage() : null;
return (iconImage == image);
}
/**
! * Returns index of the first occurrence of <code>mnemonic</code>
! * within string <code>text</code>. Matching algorithm is not
* case-sensitive.
*
* @param text The text to search through, may be {@code null}
* @param mnemonic The mnemonic to find the character for.
* @return index into the string if exists, otherwise -1
--- 2011,2032 ----
private SwingUtilities() {
throw new Error("SwingUtilities is just a container for static methods");
}
/**
! * Returns true if the Icon {@code icon} is an instance of
! * ImageIcon, and the image it contains is the same as {@code image}.
*/
static boolean doesIconReferenceImage(Icon icon, Image image) {
Image iconImage = (icon != null && (icon instanceof ImageIcon)) ?
((ImageIcon)icon).getImage() : null;
return (iconImage == image);
}
/**
! * Returns index of the first occurrence of {@code mnemonic}
! * within string {@code text}. Matching algorithm is not
* case-sensitive.
*
* @param text The text to search through, may be {@code null}
* @param mnemonic The mnemonic to find the character for.
* @return index into the string if exists, otherwise -1
*** 2052,2062 ****
}
/**
* Stores the position and size of
* the inner painting area of the specified component
! * in <code>r</code> and returns <code>r</code>.
* The position and size specify the bounds of the component,
* adjusted so as not to include the border area (the insets).
* This method is useful for classes
* that implement painting code.
*
--- 2052,2062 ----
}
/**
* Stores the position and size of
* the inner painting area of the specified component
! * in {@code r} and returns {@code r}.
* The position and size specify the bounds of the component,
* adjusted so as not to include the border area (the insets).
* This method is useful for classes
* that implement painting code.
*
< prev index next >