public class FocusUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
disableFocusComponents(java.awt.Container contObj,
java.awt.Component keepFocusObj)
Disables focusability on all components held by the given container
or any subcontainers of it, except for any component matching the
'keepFocusObj' component or that is any type of menu item.
|
static java.awt.Component |
findFirstFocusableComponent(java.awt.Container contObj,
java.lang.Class preferredType)
Finds the first component of the preferred class-type among all the
components held by the given container or any subcontainers of it.
|
static java.awt.Component |
findFocusedComponent(java.awt.Container contObj)
Finds the first focused component held by the given container
or any subcontainers of it
|
static boolean |
requestDefaultFocus(javax.swing.JComponent jCompObj)
Non-deprecated version of JComponent 'requestDefaultFocus()' method.
|
static void |
restoreTabFocusTraversal(java.awt.Container containerObj)
Restores the focus-traversal function of the "Tab" key.
|
static void |
setComponentFocusDisabled(java.awt.Component compObj)
Disables focusability on the given component.
|
public static void setComponentFocusDisabled(java.awt.Component compObj)
compObj
- the component to use.public static void disableFocusComponents(java.awt.Container contObj, java.awt.Component keepFocusObj)
contObj
- the container to use.keepFocusObj
- the component that should retain focusability,
or null for none.public static java.awt.Component findFirstFocusableComponent(java.awt.Container contObj, java.lang.Class preferredType)
contObj
- the container to use.preferredType
- the preferred class-type to be found.public static java.awt.Component findFocusedComponent(java.awt.Container contObj)
contObj
- the container to use.public static void restoreTabFocusTraversal(java.awt.Container containerObj)
containerObj
- the component to use.public static boolean requestDefaultFocus(javax.swing.JComponent jCompObj)
JComponent
's
FocusTraversalPolicy
's default Component
.
If the JComponent
is a focus cycle root, then its
FocusTraversalPolicy
is used. Otherwise, the
FocusTraversalPolicy
of the JComponent
's
focus-cycle-root ancestor is used.jCompObj
- JComponent object to use.