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 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 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 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 isContentPane(Component c)
          Returns whether the given Component is the content pane for a RootPaneContainer.
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 isOnPopup(Component comp)
          Returns whether the given component is on a top-level popup.
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.


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.


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)
                                 throws IllegalAccessException
Return all AWT popup menus associated with the given component.

Throws:
IllegalAccessException

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.


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.



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

SourceForge