abbot.util
Class AWT

java.lang.Object
  extended byabbot.util.AWT

public class AWT
extends Object

Various AWT utilities.


Field Summary
static int POPUP_TIMEOUT
           
 
Method Summary
static List disableHierarchy(Component root)
          Disable a component hierarchy starting at the given component.
static void dismissAWTPopup()
           
static boolean eventTypeEnabled(Component c, int id)
          WARNING: This uses 1.3/1.4 implementation details.
static JPopupMenu findActivePopupMenu()
          Find the currently active Swing popup menu, if any, waiting up to POPUP_TIMEOUT ms.
static Applet findAppletDescendent(Container c)
          Returns the Applet descendent of the given Container, if any.
static MenuItem[] findAWTMenuItems(Frame frame, String path)
          Returns all MenuItems matching the given label or path which are found in the given Frame's MenuBar.
static MenuItem[] findAWTPopupMenuItems(Component parent, String path)
          Returns all MenuItems matching the given label or path which are on PopupMenus on the given Component.
static JPopupMenu getActivePopupMenu()
          Returns the currently active popup menu, if any.
static sun.awt.AppContext getAppContext(Component c)
          For debugging purposes only.
static Component getFocusOwner()
          Return the focus owner under the given Window.
static Component getInvoker(Component comp)
          Returns the invoker, if any, of the given component.
static Component getInvoker(MenuComponent mc)
          Returns the invoker, if any, of the given AWT menu component.
static Point getLocationOnScreen(Component c)
          Returns the location of the given components in screen coordinates.
static String getPath(MenuItem item)
          Returns a unique path to the given MenuItem.
static int getPopupMask()
          Returns the InputEvent mask for the popup trigger button.
static PopupMenu[] getPopupMenus(Component c)
          Return all AWT popup menus associated with the given component.
static boolean getPopupOnPress()
          Returns whether the platform registers a popup on mouse press.
static int getTertiaryMask()
          Returns the InputEvent mask for the tertiary button.
static Window getWindow(Component comp)
          Similar to SwingUtilities.getWindowAncestor(), but returns the component itself if it is a Window, or the invoker's window if on a popup.
static boolean hasDefaultName(Component c)
          Return whether the given Component has only its default name set.
static void invokeAction(Runnable action)
          Ensure the given action happens on the event dispatch thread.
static void invokeAndWait(Runnable action)
          Ensure the given action happens on the event dispatch thread.
static boolean isAWTPopupMenuBlocking()
          Returns whether there is an AWT popup menu currently showing.
static boolean isAWTTreeLockHeld()
          Returns whether the AWT Tree Lock is currently held.
static boolean isContentPane(Component c)
          Returns whether the given Component is the content pane for a RootPaneContainer.
static boolean isEventQueueBlocked()
           
static boolean isGlassPane(Component c)
          Returns whether the given Component is the Glass Pane for a JRootPane.
static boolean isHeavyweightPopup(Component c)
          Returns whether the given component is a heavyweight popup, that is, a container for a JPopupMenu that is implemented with a heavyweight component (usually a Window).
static boolean isInternalFrameDecoration(Component c)
          Return whether the given component is part of an internal frame's LAF decoration.
static boolean isLightweightPopup(Component c)
          Returns whether the given component is a lightweight popup, that is, a container for a JPopupMenu that is implemented with a lightweight component (usually JPanel).
static boolean isOnMenuBar(MenuComponent mc)
          Returns whether the menu component is on a MenuBar.
static boolean isOnPopup(Component comp)
          Returns whether the given component is on a top-level popup.
static boolean isOnPopup(MenuComponent mc)
          Returns whether the given MenuComponent is on a top-level AWT popup (that is, not under a MenuBar.
static boolean isSharedInvisibleFrame(Component c)
          Is the given component the default Swing hidden frame?
static boolean isToolTip(Component c)
          Return whether the given component is part of the transient wrapper around a tooltip.
static boolean isTransientDialog(Component c)
          Return whether the given component is part of a transient dialog.
static boolean isTransientPopup(Component c)
          Return whether the given component is part of the transient wrapper around a popup.
static void reenableHierarchy(List enabled)
          Restore the enabled state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POPUP_TIMEOUT

public static int POPUP_TIMEOUT
Method Detail

hasDefaultName

public static boolean hasDefaultName(Component c)
Return whether the given Component has only its default name set.


invokeAndWait

public static void invokeAndWait(Runnable action)
Ensure the given action happens on the event dispatch thread. Any component modifications must be invoked this way.


invokeAction

public static void invokeAction(Runnable action)
Ensure the given action happens on the event dispatch thread. Any component modifications must be invoked this way. Note that this is not the same as EventQueue.invokeLater, since if the current thread is the dispatch thread, the action is invoked immediately.


reenableHierarchy

public static void reenableHierarchy(List enabled)
Restore the enabled state.


disableHierarchy

public static List disableHierarchy(Component root)
Disable a component hierarchy starting at the given component. Returns a list of all components which used to be enabled, for use with reenableHierarchy.


isOnMenuBar

public static boolean isOnMenuBar(MenuComponent mc)
Returns whether the menu component is on a MenuBar.


getInvoker

public static Component getInvoker(MenuComponent mc)
Returns the invoker, if any, of the given AWT menu component. Returns null if the menu component is not attached to anything, or if it is within a MenuBar hierarchy.


getInvoker

public static Component getInvoker(Component comp)
Returns the invoker, if any, of the given component. Returns null if the component is not on a popup of any sort.


getWindow

public static Window getWindow(Component comp)
Similar to SwingUtilities.getWindowAncestor(), but returns the component itself if it is a Window, or the invoker's window if on a popup.


isAWTPopupMenuBlocking

public static boolean isAWTPopupMenuBlocking()
Returns whether there is an AWT popup menu currently showing.


isEventQueueBlocked

public static boolean isEventQueueBlocked()

isAWTTreeLockHeld

public static boolean isAWTTreeLockHeld()
Returns whether the AWT Tree Lock is currently held.


dismissAWTPopup

public static void dismissAWTPopup()

isOnPopup

public static boolean isOnPopup(MenuComponent mc)
Returns whether the given MenuComponent is on a top-level AWT popup (that is, not under a MenuBar.


isOnPopup

public static boolean isOnPopup(Component comp)
Returns whether the given component is on a top-level popup. A top-level popup is one generated by a popup trigger, which means popups generated from a JMenu are not included.


isHeavyweightPopup

public static boolean isHeavyweightPopup(Component c)
Returns whether the given component is a heavyweight popup, that is, a container for a JPopupMenu that is implemented with a heavyweight component (usually a Window).


isLightweightPopup

public static boolean isLightweightPopup(Component c)
Returns whether the given component is a lightweight popup, that is, a container for a JPopupMenu that is implemented with a lightweight component (usually JPanel).


isContentPane

public static boolean isContentPane(Component c)
Returns whether the given Component is the content pane for a RootPaneContainer.

See Also:
RootPaneContainer.getContentPane()

isGlassPane

public static boolean isGlassPane(Component c)
Returns whether the given Component is the Glass Pane for a JRootPane.

See Also:
JRootPane.getGlassPane()

isTransientPopup

public static boolean isTransientPopup(Component c)
Return whether the given component is part of the transient wrapper around a popup.


isToolTip

public static boolean isToolTip(Component c)
Return whether the given component is part of the transient wrapper around a tooltip.


isInternalFrameDecoration

public static boolean isInternalFrameDecoration(Component c)
Return whether the given component is part of an internal frame's LAF decoration.


getPopupMask

public static int getPopupMask()
Returns the InputEvent mask for the popup trigger button.


getTertiaryMask

public static int getTertiaryMask()
Returns the InputEvent mask for the tertiary button.


getPopupOnPress

public static boolean getPopupOnPress()
Returns whether the platform registers a popup on mouse press.


getPopupMenus

public static PopupMenu[] getPopupMenus(Component c)
Return all AWT popup menus associated with the given component.


findAWTPopupMenuItems

public static MenuItem[] findAWTPopupMenuItems(Component parent,
                                               String path)
Returns all MenuItems matching the given label or path which are on PopupMenus on the given Component.


findAWTMenuItems

public static MenuItem[] findAWTMenuItems(Frame frame,
                                          String path)
Returns all MenuItems matching the given label or path which are found in the given Frame's MenuBar.


getPath

public static String getPath(MenuItem item)
Returns a unique path to the given MenuItem.


getFocusOwner

public static Component getFocusOwner()
Return the focus owner under the given Window. As of 1.4.x, components will report that they do not have focus if asked from a different AppContext than their own. Account for that here.


getAppContext

public static sun.awt.AppContext getAppContext(Component c)
For debugging purposes only.


eventTypeEnabled

public static boolean eventTypeEnabled(Component c,
                                       int id)
WARNING: This uses 1.3/1.4 implementation details.


isSharedInvisibleFrame

public static boolean isSharedInvisibleFrame(Component c)
Is the given component the default Swing hidden frame?


getActivePopupMenu

public static JPopupMenu getActivePopupMenu()
Returns the currently active popup menu, if any. If no popup is currently showing, returns null.


findActivePopupMenu

public static JPopupMenu findActivePopupMenu()
Find the currently active Swing popup menu, if any, waiting up to POPUP_TIMEOUT ms. Returns null if no popup found.


getLocationOnScreen

public static Point getLocationOnScreen(Component c)
Returns the location of the given components in screen coordinates. Avoids lockup if an AWT popup menu is showing, which means it holds the AWT tree lock, which Component.getLocationOnScreen requires.


isTransientDialog

public static boolean isTransientDialog(Component c)
Return whether the given component is part of a transient dialog. This includes dialogs generated by JFileChooser, JOptionPane, JColorChooser, and ProgressMonitor.

Note that it is possible to use JOptionPane.createDialog to create a reusable dialog, so just because it's transient doesn't mean it will be disposed of when it is hidden.

Note that this won't detect transient Dialogs after their components have been reassigned to a new transient Dialog.


findAppletDescendent

public static Applet findAppletDescendent(Container c)
Returns the Applet descendent of the given Container, if any.



Copyright © 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge