public class SwingUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
centerOnScreen(javax.swing.JInternalFrame internalFrame)
Centers a JInternalFrame on the screen
|
static void |
centerOnScreen(java.awt.Window window)
Centers a Window on the screen
|
static java.awt.Window |
createApplicationFrame(GriffonApplication application,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Creates a Window based on the application's configuration.
|
static java.awt.Component |
findComponentByName(java.lang.String name,
java.awt.Container root)
Searches a component by name in a particular component hierarchy.
|
static float |
getWindowOpacity(java.awt.Window window)
Returns the window's current opacity value.
|
static void |
setWindowOpacity(java.awt.Window window,
float opacity)
Sets the value for the window's opacity.
|
static java.awt.Image |
takeSnapshot(java.awt.Component component)
Takes a snapshot of the target component.
|
static java.awt.Image |
takeSnapshot(java.awt.Component component,
boolean usePrint)
Takes a snapshot of the target component.
|
public static void centerOnScreen(@Nonnull java.awt.Window window)
Sets the window on the top left corner if the window's dimensions are bigger than the screen's.
window
- a Window objectpublic static void centerOnScreen(@Nonnull javax.swing.JInternalFrame internalFrame)
Sets the internal frame on the top left corner if the frame's dimensions are bigger than the desktop's.
internalFrame
- a JInternalFrame objectpublic static float getWindowOpacity(@Nonnull java.awt.Window window)
window
- the window on which the opacity will be queriedpublic static void setWindowOpacity(@Nonnull java.awt.Window window, float opacity)
window
- the window on which the opacity will be setopacity
- the new opacity value@Nullable public static java.awt.Component findComponentByName(@Nonnull java.lang.String name, @Nonnull java.awt.Container root)
A component must have a value for its name property if it's
to be found with this method.
This method performs a depth-first search.
name
- the value of the component's name propertyroot
- the root of the component hierarchy from where searching
searching should start@Nonnull public static java.awt.Image takeSnapshot(@Nonnull java.awt.Component component)
component
- the component to draw@Nonnull public static java.awt.Image takeSnapshot(@Nonnull java.awt.Component component, boolean usePrint)
component
- the component to drawusePrint
- whether print() or paint() is used to grab the snapshot@Nonnull public static java.awt.Window createApplicationFrame(@Nonnull GriffonApplication application, @Nonnull java.util.Map<java.lang.String,java.lang.Object> attributes)
Class lookup order is
application
- the current running applicationattributes
- window attributes