SwingUtilities.java revision 2362
2362N/A * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A collection of utility methods for Swing. 0N/A // These states are system-wide, rather than AppContext wide. 0N/A * Indicates if we should change the drop target when a 0N/A * {@code TransferHandler} is set. 0N/A * Indiciates if we've checked the system property for suppressing 0N/A * Returns true if <code>setTransferHandler</code> should change the 0N/A * <code>DropTarget</code>. 0N/A * Installs a {@code DropTarget} on the component as necessary for a 0N/A * {@code TransferHandler} change. 0N/A * Return true if <code>a</code> contains <code>b</code> 0N/A * Return the rectangle (0,0,bounds.width,bounds.height) for the component <code>aComponent</code> 0N/A * Returns the first <code>Window </code> ancestor of <code>c</code>, or 0N/A * {@code null} if <code>c</code> is not contained inside a <code>Window</code>. 0N/A * @param c <code>Component</code> to get <code>Window</code> ancestor 0N/A * @return the first <code>Window </code> ancestor of <code>c</code>, or 0N/A * {@code null} if <code>c</code> is not contained inside a 0N/A * <code>Window</code>. 0N/A * Converts the location <code>x</code> <code>y</code> to the 0N/A * parents coordinate system, returning the location. 0N/A throw new Error(
"convertScreenLocationToParent: no window ancestor");
0N/A * Convert a <code>aPoint</code> in <code>source</code> coordinate system to 0N/A * <code>destination</code> coordinate system. 0N/A * If <code>source</code> is {@code null}, <code>aPoint</code> is assumed to be in <code>destination</code>'s 0N/A * root component coordinate system. 0N/A * If <code>destination</code> is {@code null}, <code>aPoint</code> will be converted to <code>source</code>'s 0N/A * root component coordinate system. 0N/A * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>aPoint</code> 0N/A * without any conversion. 0N/A throw new Error(
"Source component not connected to component tree hierarchy");
0N/A throw new Error(
"Destination component not connected to component tree hierarchy");
0N/A * Convert the point <code>(x,y)</code> in <code>source</code> coordinate system to 0N/A * <code>destination</code> coordinate system. 0N/A * If <code>source</code> is {@code null}, <code>(x,y)</code> is assumed to be in <code>destination</code>'s 0N/A * root component coordinate system. 0N/A * If <code>destination</code> is {@code null}, <code>(x,y)</code> will be converted to <code>source</code>'s 0N/A * root component coordinate system. 0N/A * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>(x,y)</code> 0N/A * without any conversion. 0N/A * Convert the rectangle <code>aRectangle</code> in <code>source</code> coordinate system to 0N/A * <code>destination</code> coordinate system. 0N/A * If <code>source</code> is {@code null}, <code>aRectangle</code> is assumed to be in <code>destination</code>'s 0N/A * root component coordinate system. 0N/A * If <code>destination</code> is {@code null}, <code>aRectangle</code> will be converted to <code>source</code>'s 0N/A * root component coordinate system. 0N/A * If both <code>source</code> and <code>destination</code> are {@code null}, return <code>aRectangle</code> 0N/A * without any conversion. 0N/A * Convenience method for searching above <code>comp</code> in the 0N/A * component hierarchy and returns the first object of class <code>c</code> it 0N/A * finds. Can return {@code null}, if a class <code>c</code> cannot be found. 0N/A * Convenience method for searching above <code>comp</code> in the 0N/A * component hierarchy and returns the first object of <code>name</code> it 0N/A * finds. Can return {@code null}, if <code>name</code> cannot be found. 0N/A * Returns the deepest visible descendent Component of <code>parent</code> 0N/A * that contains the location <code>x</code>, <code>y</code>. 0N/A * If <code>parent</code> does not contain the specified location, 0N/A * then <code>null</code> is returned. If <code>parent</code> is not a 0N/A * container, or none of <code>parent</code>'s visible descendents 0N/A * contain the specified location, <code>parent</code> is returned. 0N/A * @param parent the root component to begin the search 0N/A * @param x the x target location 0N/A * @param y the y target location 0N/A * Returns a MouseEvent similar to <code>sourceEvent</code> except that its x 0N/A * and y members have been converted to <code>destination</code>'s coordinate 0N/A * system. If <code>source</code> is {@code null}, <code>sourceEvent</code> x and y members 0N/A * are assumed to be into <code>destination</code>'s root component coordinate system. 0N/A * If <code>destination</code> is <code>null</code>, the 0N/A * returned MouseEvent will be in <code>source</code>'s coordinate system. 0N/A * <code>sourceEvent</code> will not be changed. A new event is returned. 0N/A * the <code>source</code> field of the returned event will be set 0N/A * to <code>destination</code> if destination is non-{@code null} 0N/A * use the translateMouseEvent() method to translate a mouse event from 0N/A * one component to another without changing the source. 0N/A * Convert a point from a component's coordinate system to 0N/A * screen coordinates. 0N/A * @param p a Point object (converted to the new coordinate system) 0N/A * @param c a Component object 0N/A * Convert a point from a screen coordinates to a component's 0N/A * @param p a Point object (converted to the new coordinate system) 0N/A * @param c a Component object 0N/A * Returns the first <code>Window </code> ancestor of <code>c</code>, or 0N/A * {@code null} if <code>c</code> is not contained inside a <code>Window</code>. 0N/A * Note: This method provides the same functionality as 0N/A * <code>getWindowAncestor</code>. 0N/A * @param c <code>Component</code> to get <code>Window</code> ancestor 0N/A * @return the first <code>Window </code> ancestor of <code>c</code>, or 0N/A * {@code null} if <code>c</code> is not contained inside a 0N/A * <code>Window</code>. 0N/A * Return <code>true</code> if a component <code>a</code> descends from a component <code>b</code> 0N/A * Convenience to calculate the intersection of two rectangles 0N/A * without allocating a new rectangle. 0N/A * If the two rectangles don't intersect, 0N/A * then the returned rectangle begins at (0,0) 0N/A * and has zero width and height. 0N/A * @param x the X coordinate of the first rectangle's top-left point 0N/A * @param y the Y coordinate of the first rectangle's top-left point 0N/A * @param width the width of the first rectangle 0N/A * @param height the height of the first rectangle 0N/A * @param dest the second rectangle 0N/A * @return <code>dest</code>, modified to specify the intersection 0N/A // If rectangles don't intersect, return zero'd intersection. 0N/A * Convenience method that calculates the union of two rectangles 0N/A * without allocating a new rectangle. 0N/A * @param x the x-coordinate of the first rectangle 0N/A * @param y the y-coordinate of the first rectangle 0N/A * @param width the width of the first rectangle 0N/A * @param height the height of the first rectangle 0N/A * @param dest the coordinates of the second rectangle; the union 0N/A * of the two rectangles is returned in this rectangle 0N/A * @return the <code>dest</code> <code>Rectangle</code> 0N/A * Convenience returning an array of rect representing the regions within 0N/A * <code>rectA</code> that do not overlap with <code>rectB</code>. If the 0N/A * two Rects do not overlap, returns an empty array 0N/A /* rectA contains rectB */ 0N/A * Returns true if the mouse event specifies the left mouse button. 0N/A * @param anEvent a MouseEvent object 0N/A * @return true if the left mouse button was active 0N/A * Returns true if the mouse event specifies the middle mouse button. 0N/A * @param anEvent a MouseEvent object 0N/A * @return true if the middle mouse button was active 0N/A * Returns true if the mouse event specifies the right mouse button. 0N/A * @param anEvent a MouseEvent object 0N/A * @return true if the right mouse button was active 0N/A * Compute the width of the string using a font with the specified 0N/A * "metrics" (sizes). 0N/A * @param fm a FontMetrics object to compute with 0N/A * @param str the String to compute 0N/A * @return an int containing the string width 0N/A // You can't assume that a string's width is the sum of its 0N/A // characters' widths in Java2D -- it may be smaller due to 0N/A * Compute and return the location of the icons origin, the 0N/A * location of origin of the text baseline, and a possibly clipped 0N/A * version of the compound labels string. Locations are computed 0N/A * relative to the viewR rectangle. 0N/A * into account and translated into LEFT/RIGHT values accordingly. 0N/A // to LEFT/RIGHT values depending on the components orientation 0N/A // to LEFT/RIGHT values depending on the components orientation 0N/A * Compute and return the location of the icons origin, the 0N/A * location of origin of the text baseline, and a possibly clipped 0N/A * version of the compound labels string. Locations are computed 0N/A * relative to the viewR rectangle. 0N/A * values in horizontalTextPosition (they will default to RIGHT) and in 0N/A * horizontalAlignment (they will default to CENTER). 0N/A * Use the other version of layoutCompoundLabel() instead. 0N/A * Compute and return the location of the icons origin, the 0N/A * location of origin of the text baseline, and a possibly clipped 0N/A * version of the compound labels string. Locations are computed 0N/A * relative to the viewR rectangle. 0N/A * values in horizontalTextPosition (they will default to RIGHT) and in 0N/A * horizontalAlignment (they will default to CENTER). 0N/A * Use the other version of layoutCompoundLabel() instead. 0N/A /* Initialize the icon bounds rectangle iconR. 0N/A /* Initialize the text bounds rectangle textR. If a null 0N/A * or and empty String was specified we substitute "" here 0N/A * and use 0,0,0,0 for textR. 0N/A /* Unless both text and icon are non-null, we effectively ignore 0N/A * the value of textIconGap. 1637N/A // If lsb is negative, add it to the width and later 1637N/A // adjust the x location. This gives more space than is 1637N/A // This is done like this for two reasons: 1637N/A // 1. If we set the width to the actual bounds all 1637N/A // callers would have to account for negative lsb 1637N/A // (pref size calculations ONLY look at width of 1637N/A // 2. You can do a drawString at the returned location 1637N/A // and the text won't be clipped. 0N/A /* Compute textR.x,y given the verticalTextPosition and 0N/A * horizontalTextPosition properties 0N/A else {
// (verticalTextPosition == BOTTOM) 0N/A else {
// (horizontalTextPosition == RIGHT) 0N/A // WARNING: DefaultTreeCellEditor uses a shortened version of 0N/A // this algorithm to position it's Icon. If you change how this 0N/A // is calculated, be sure and update DefaultTreeCellEditor too. 0N/A /* labelR is the rectangle that contains iconR and textR. 0N/A * Move it to its proper position given the labelAlignment 0N/A * To avoid actually allocating a Rectangle, Rectangle.union 0N/A * has been inlined below. 0N/A else {
// (verticalAlignment == BOTTOM) 0N/A else {
// (horizontalAlignment == CENTER) 0N/A /* Translate textR and glypyR by dx,dy. 0N/A // lsb is negative. Shift the x location so that the text is 0N/A // visually drawn at the right location. 0N/A * Paints a component to the specified <code>Graphics</code>. 0N/A * This method is primarily useful to render 0N/A * <code>Component</code>s that don't exist as part of the visible 0N/A * containment hierarchy, but are used for rendering. For 0N/A * example, if you are doing your own rendering and want to render 0N/A * some text (or even HTML), you could make use of 0N/A * <code>JLabel</code>'s text rendering support and have it paint 0N/A * directly by way of this method, without adding the label to the 0N/A * visible containment hierarchy. 0N/A * This method makes use of <code>CellRendererPane</code> to handle 0N/A * the actual painting, and is only recommended if you use one 0N/A * component for rendering. If you make use of multiple components 0N/A * to handle the rendering, as <code>JTable</code> does, use 0N/A * <code>CellRendererPane</code> directly. Otherwise, as described 0N/A * below, you could end up with a <code>CellRendererPane</code> 0N/A * per <code>Component</code>. 0N/A * If <code>c</code>'s parent is not a <code>CellRendererPane</code>, 0N/A * a new <code>CellRendererPane</code> is created, <code>c</code> is 0N/A * added to it, and the <code>CellRendererPane</code> is added to 0N/A * <code>p</code>. If <code>c</code>'s parent is a 0N/A * <code>CellRendererPane</code> and the <code>CellRendererPane</code>s 0N/A * parent is not <code>p</code>, it is added to <code>p</code>. 0N/A * The component should either descend from <code>JComponent</code> 0N/A * or be another kind of lightweight component. 0N/A * A lightweight component is one whose "lightweight" property 0N/A * (returned by the <code>Component</code> 0N/A * <code>isLightweight</code> method) 0N/A * is true. If the Component is not lightweight, bad things map happen: 0N/A * crashes, exceptions, painting problems... 0N/A * @param g the <code>Graphics</code> object to draw on 0N/A * @param c the <code>Component</code> to draw 0N/A * @param p the intermediate <code>Container</code> 0N/A * @param x an int specifying the left side of the area draw in, in pixels, 0N/A * measured from the left edge of the graphics context 0N/A * @param y an int specifying the top of the area to draw in, in pixels 0N/A * measured down from the top edge of the graphics context 0N/A * @param w an int specifying the width of the area draw in, in pixels 0N/A * @param h an int specifying the height of the area draw in, in pixels 0N/A * @see CellRendererPane 0N/A * @see java.awt.Component#isLightweight 0N/A * Paints a component to the specified <code>Graphics</code>. This 0N/A * is a cover method for 0N/A * {@link #paintComponent(Graphics,Component,Container,int,int,int,int)}. 0N/A * Refer to it for more information. 0N/A * @param g the <code>Graphics</code> object to draw on 0N/A * @param c the <code>Component</code> to draw 0N/A * @param p the intermediate <code>Container</code> 0N/A * @param r the <code>Rectangle</code> to draw in 0N/A * @see #paintComponent(Graphics,Component,Container,int,int,int,int) 0N/A * @see CellRendererPane 0N/A * Ensures that cell renderer <code>c</code> has a 0N/A * <code>ComponentShell</code> parent and that 0N/A * the shell's parent is p. 0N/A * A simple minded look and feel change: ask each node in the tree 0N/A * to <code>updateUI()</code> -- that is, to initialize its UI property 0N/A * with the current look and feel. 0N/A * Causes <i>doRun.run()</i> to be executed asynchronously on the 0N/A * AWT event dispatching thread. This will happen after all 0N/A * pending AWT events have been processed. This method should 0N/A * be used when an application thread needs to update the GUI. 0N/A * In the following example the <code>invokeLater</code> call queues 0N/A * the <code>Runnable</code> object <code>doHelloWorld</code> 0N/A * on the event dispatching thread and 0N/A * then prints a message. 0N/A * Runnable doHelloWorld = new Runnable() { 0N/A * public void run() { 0N/A * System.out.println("Hello World on " + Thread.currentThread()); 0N/A * SwingUtilities.invokeLater(doHelloWorld); 0N/A * System.out.println("This might well be displayed before the other message."); 0N/A * If invokeLater is called from the event dispatching thread -- 0N/A * for example, from a JButton's ActionListener -- the <i>doRun.run()</i> will 0N/A * still be deferred until all pending events have been processed. 0N/A * Note that if the <i>doRun.run()</i> throws an uncaught exception 0N/A * the event dispatching thread will unwind (not the current thread). 0N/A * Additional documentation and examples for this method can be 0N/A * in <em>The Java Tutorial</em>. 0N/A * As of 1.3 this method is just a cover for <code>java.awt.EventQueue.invokeLater()</code>. 0N/A * Unlike the rest of Swing, this method can be invoked from any thread. 0N/A * @see #invokeAndWait 0N/A * Causes <code>doRun.run()</code> to be executed synchronously on the 0N/A * AWT event dispatching thread. This call blocks until 0N/A * all pending AWT events have been processed and (then) 0N/A * <code>doRun.run()</code> returns. This method should 0N/A * be used when an application thread needs to update the GUI. 0N/A * It shouldn't be called from the event dispatching thread. 0N/A * Here's an example that creates a new application thread 0N/A * that uses <code>invokeAndWait</code> to print a string from the event 0N/A * dispatching thread and then, when that's finished, print 0N/A * a string from the application thread. 0N/A * final Runnable doHelloWorld = new Runnable() { 0N/A * public void run() { 0N/A * System.out.println("Hello World on " + Thread.currentThread()); 0N/A * Thread appThread = new Thread() { 0N/A * public void run() { 0N/A * SwingUtilities.invokeAndWait(doHelloWorld); 0N/A * catch (Exception e) { 0N/A * e.printStackTrace(); 0N/A * System.out.println("Finished on " + Thread.currentThread()); 0N/A * appThread.start(); 0N/A * Note that if the <code>Runnable.run</code> method throws an 0N/A * uncaught exception 0N/A * (on the event dispatching thread) it's caught and rethrown, as 0N/A * an <code>InvocationTargetException</code>, on the caller's thread. 0N/A * Additional documentation and examples for this method can be 0N/A * in <em>The Java Tutorial</em>. 0N/A * As of 1.3 this method is just a cover for 0N/A * <code>java.awt.EventQueue.invokeAndWait()</code>. 0N/A * @exception InterruptedException if we're interrupted while waiting for 0N/A * the event dispatching thread to finish excecuting 0N/A * <code>doRun.run()</code> 0N/A * @exception InvocationTargetException if an exception is thrown 0N/A * while running <code>doRun</code> 0N/A * Returns true if the current thread is an AWT event dispatching thread. 0N/A * As of 1.3 this method is just a cover for 0N/A * <code>java.awt.EventQueue.isDispatchThread()</code>. 0N/A * @return true if the current thread is an AWT event dispatching thread 0N/A * --- Accessibility Support --- 0N/A * Get the index of this object in its accessible parent.<p> 0N/A * Note: as of the Java 2 platform v1.3, it is recommended that developers call 0N/A * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead 0N/A * of using this method. 0N/A * @return -1 of this object does not have an accessible parent. 0N/A * Otherwise, the index of the child in its accessible parent. 0N/A * Returns the <code>Accessible</code> child contained at the 0N/A * local coordinate <code>Point</code>, if one exists. 0N/A * Otherwise returns <code>null</code>. 0N/A * @return the <code>Accessible</code> at the specified location, 0N/A * if it exists; otherwise <code>null</code> 0N/A * Get the state of this object. <p> 0N/A * Note: as of the Java 2 platform v1.3, it is recommended that developers call 0N/A * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead 0N/A * of using this method. 0N/A * @return an instance of AccessibleStateSet containing the current state 0N/A * @see AccessibleState 0N/A * Returns the number of accessible children in the object. If all 0N/A * of the children of this object implement Accessible, than this 0N/A * method should return the number of children of this object. <p> 0N/A * Note: as of the Java 2 platform v1.3, it is recommended that developers call 0N/A * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead 0N/A * of using this method. 0N/A * @return the number of accessible children in the object. 0N/A * Return the nth Accessible child of the object. <p> 0N/A * Note: as of the Java 2 platform v1.3, it is recommended that developers call 0N/A * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead 0N/A * of using this method. 0N/A * @param i zero-based index of child 0N/A * @return the nth Accessible child of the object 0N/A * Return the child <code>Component</code> of the specified 0N/A * <code>Component</code> that is the focus owner, if any. 0N/A * @param c the root of the <code>Component</code> hierarchy to 0N/A * search for the focus owner 0N/A * @return the focus owner, or <code>null</code> if there is no focus 0N/A * owner, or if the focus owner is not <code>comp</code>, or a 0N/A * descendant of <code>comp</code> 0N/A * @see java.awt.KeyboardFocusManager#getFocusOwner 0N/A * @deprecated As of 1.4, replaced by 0N/A * <code>KeyboardFocusManager.getFocusOwner()</code>. 0N/A // verify focusOwner is a descendant of c 0N/A * If c is a JRootPane descendant return its JRootPane ancestor. 0N/A * If c is a RootPaneContainer then return its JRootPane. 0N/A * @return the JRootPane for Component c or {@code null}. 0N/A * Returns the root component for the current component tree. 0N/A * @return the first ancestor of c that's a Window or the last Applet ancestor 0N/A * Process the key bindings for the <code>Component</code> associated with 0N/A * <code>event</code>. This method is only useful if 0N/A * <code>event.getComponent()</code> does not descend from 0N/A * <code>JComponent</code>, or your are not invoking 0N/A * <code>super.processKeyEvent</code> from within your 0N/A * <code>JComponent</code> subclass. <code>JComponent</code> 0N/A * automatically processes bindings from within its 0N/A * <code>processKeyEvent</code> method, hence you rarely need 0N/A * to directly invoke this method. 0N/A * @param event KeyEvent used to identify which bindings to process, as 0N/A * well as which Component has focus. 0N/A * @return true if a binding has found and processed 0N/A // Find the first JComponent in the ancestor hierarchy, and 0N/A // invoke processKeyBindings on it 0N/A // No JComponents, if Window or Applet parent, process 0N/A // WHEN_IN_FOCUSED_WINDOW bindings. 0N/A * Returns true if the <code>e</code> is a valid KeyEvent to use in 0N/A * processing the key bindings associated with JComponents. 0N/A * Invokes <code>actionPerformed</code> on <code>action</code> if 0N/A * <code>action</code> is enabled (and non-{@code null}). The command for the 0N/A * ActionEvent is determined by: 0N/A * <li>If the action was registered via 0N/A * <code>registerKeyboardAction</code>, then the command string 0N/A * passed in ({@code null} will be used if {@code null} was passed in). 0N/A * <li>Action value with name Action.ACTION_COMMAND_KEY, unless {@code null}. 0N/A * <li>String value of the KeyEvent, unless <code>getKeyChar</code> 0N/A * returns KeyEvent.CHAR_UNDEFINED.. 0N/A * This will return true if <code>action</code> is non-{@code null} and 0N/A * actionPerformed is invoked on it. 0N/A // Get the command object. 0N/A // ActionStandin is used for historical reasons to support 0N/A // registerKeyboardAction with a null value. 0N/A // Convert it to a string. 0N/A // Do null for undefined chars, or if registerKeyboardAction 0N/A // was called with a null. 0N/A * Convenience method to change the UI InputMap for <code>component</code> 0N/A * to <code>uiInputMap</code>. If <code>uiInputMap</code> is {@code null}, 0N/A * this removes any previously installed UI InputMap. 0N/A * Convenience method to change the UI ActionMap for <code>component</code> 0N/A * to <code>uiActionMap</code>. If <code>uiActionMap</code> is {@code null}, 0N/A * this removes any previously installed UI ActionMap. 0N/A * Returns the InputMap provided by the UI for condition 0N/A * <code>condition</code> in component <code>component</code>. 0N/A * <p>This will return {@code null} if the UI has not installed a InputMap 0N/A * of the specified type. 0N/A * Returns the ActionMap provided by the UI 0N/A * in component <code>component</code>. 0N/A * <p>This will return {@code null} if the UI has not installed an ActionMap. 0N/A // Don't use String, as it's not guaranteed to be unique in a Hashtable. 0N/A * Install window listeners on owned windows to watch for displayability changes 0N/A * Watches for displayability changes and disposes shared instance if there are no 0N/A * displayable children left. 0N/A // This frame can never be shown 0N/A // untrusted code not allowed to dispose 0N/A * Returns a toolkit-private, shared, invisible Frame 0N/A * to be the owner for JDialogs and JWindows created with 0N/A * {@code null} owners. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * Returns a SharedOwnerFrame's shutdown listener to dispose the SharedOwnerFrame 0N/A * if it has no more displayable children. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A /* Don't make these AppContext accessors public or protected -- 0N/A * since AppContext is in sun.awt in 1.2, we shouldn't expose it 0N/A * even indirectly with a public API. 0N/A // REMIND(aim): phase out use of 4 methods below since they 0N/A // are just private covers for AWT methods (?) 0N/A * Convenience function for determining ComponentOrientation. Helps us 0N/A * avoid having Munge directives throughout the code. 0N/A throw new Error(
"SwingUtilities is just a container for static methods");
0N/A * Returns true if the Icon <code>icon</code> is an instance of 0N/A * ImageIcon, and the image it contains is the same as <code>image</code>. 0N/A * Returns index of the first occurrence of <code>mnemonic</code> 0N/A * within string <code>text</code>. Matching algorithm is not 0N/A * @param text The text to search through, may be {@code null} 0N/A * @param mnemonic The mnemonic to find the character for. 0N/A * @return index into the string if exists, otherwise -1 0N/A * Stores the position and size of 0N/A * the inner painting area of the specified component 0N/A * in <code>r</code> and returns <code>r</code>. 0N/A * The position and size specify the bounds of the component, 0N/A * adjusted so as not to include the border area (the insets). 0N/A * This method is useful for classes 0N/A * that implement painting code. 0N/A * @param c the JComponent in question; if {@code null}, this method returns {@code null} 0N/A * @param r the Rectangle instance to be modified; 0N/A * may be {@code null} 0N/A * @return {@code null} if the Component is {@code null}; 0N/A * otherwise, returns the passed-in rectangle (if non-{@code null}) 0N/A * or a new rectangle specifying position and size information 2333N/A * Returns the first ancestor of the {@code component} 1912N/A * which is not an instance of {@link JLayer}. 2333N/A * @param component {@code Component} to get 2333N/A * the first ancestor of, which is not a {@link JLayer} instance. 2333N/A * @return the first ancestor of the {@code component} 2333N/A * which is not an instance of {@link JLayer}. 2333N/A * If such an ancestor can not be found, {@code null} is returned. 1912N/A * @throws NullPointerException if {@code component} is {@code null} 1912N/A * Returns the first {@code JViewport}'s descendant 2333N/A * which is not an instance of {@code JLayer}. 2333N/A * If such a descendant can not be found, {@code null} is returned. 1912N/A * If the {@code viewport}'s view component is not a {@code JLayer}, 2333N/A * this method is equivalent to {@link JViewport#getView()} 2333N/A * otherwise {@link JLayer#getView()} will be recursively 2333N/A * called on all descending {@code JLayer}s. 2333N/A * @param viewport {@code JViewport} to get the first descendant of, 2333N/A * which in not a {@code JLayer} instance. 1912N/A * @return the first {@code JViewport}'s descendant 2333N/A * which is not an instance of {@code JLayer}. 2333N/A * If such a descendant can not be found, {@code null} is returned. 1912N/A * @throws NullPointerException if {@code viewport} is {@code null} 1895N/A * Retrieves the validate root of a given container. 1895N/A * If the container is contained within a {@code CellRendererPane}, this 1895N/A * method returns {@code null} due to the synthetic nature of the {@code 1895N/A * The component hierarchy must be displayable up to the toplevel component 1895N/A * (either a {@code Frame} or an {@code Applet} object.) Otherwise this 1895N/A * method returns {@code null}. 1895N/A * If the {@code visibleOnly} argument is {@code true}, the found validate 1895N/A * root and all its parents up to the toplevel component must also be 1895N/A * visible. Otherwise this method returns {@code null}. 1895N/A * @return the validate root of the given container or null 1895N/A * @see java.awt.Component#isDisplayable() 1895N/A * @see java.awt.Component#isVisible()