public class SwingUtils extends Object
Constructor and Description |
---|
SwingUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
centerOnScreen(JInternalFrame internalFrame)
Centers a JInternalFrame on the screen
|
static void |
centerOnScreen(Window window)
Centers a Window on the screen
|
static Window |
createApplicationFrame(GriffonApplication application,
Map<String,Object> attributes)
Creates a Window based on the application's configuration.
|
static Component |
findComponentByName(String name,
Container root)
Searches a component by name in a particular component hierarchy.
|
static float |
getWindowOpacity(Window window)
Returns the window's current opacity value.
|
static void |
setWindowOpacity(Window window,
float opacity)
Sets the value for the window's opacity.
|
static Image |
takeSnapshot(Component component)
Takes a snapshot of the target component.
|
static Image |
takeSnapshot(Component component,
boolean usePrint)
Takes a snapshot of the target component.
|
public static void centerOnScreen(@Nonnull 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 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 Window window)
window
- the window on which the opacity will be queriedpublic static void setWindowOpacity(@Nonnull Window window, float opacity)
window
- the window on which the opacity will be setopacity
- the new opacity value@Nullable public static Component findComponentByName(@Nonnull String name, @Nonnull 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 Image takeSnapshot(@Nonnull Component component)
component
- the component to draw@Nonnull public static Image takeSnapshot(@Nonnull Component component, boolean usePrint)
component
- the component to drawusePrint
- whether print() or paint() is used to grab the snapshot@Nonnull public static Window createApplicationFrame(@Nonnull GriffonApplication application, @Nonnull Map<String,Object> attributes)
Class lookup order is
application
- the current running applicationattributes
- window attributes