public final class UtilGUI
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.awt.image.BufferedImage |
EMPTY_IMAGE
Empty image
|
private static java.awt.GraphicsDevice[] |
GRAPHICS_DEVICES
List of graphics devices
|
static java.awt.GraphicsEnvironment |
GRAPHICS_ENVIRONMENT
Current graphics environment
|
private static java.awt.Cursor |
INVISIBLE_CURSOR
Invisible cursor
|
private static java.awt.Robot |
ROBOT
Robot for simulate keyboard and mouse events
|
static java.awt.Toolkit |
TOOLKIT
Current toolkit
|
Modifier | Constructor and Description |
---|---|
private |
UtilGUI()
For avoid instance
|
Modifier and Type | Method and Description |
---|---|
static void |
centerOnScreen(java.awt.Window window)
Center a window on its screen
|
static void |
changeScreen(java.awt.Window window,
int screenIndex)
Change a window of screen
|
private static void |
checkScreenIndex(int screenIndex)
Check if a screen index is valid
|
static int |
computeIntresectedArea(java.awt.Rectangle rectangle1,
java.awt.Rectangle rectangle2)
Compute intersection area between two rectangles
|
static java.awt.Dimension |
computeMaximumDimension(java.awt.Component component)
Compute the maximum dimension of a component
|
static java.awt.Dimension |
computeMinimumDimension(java.awt.Component component)
Compute the minimum dimension of a component
|
static java.awt.Dimension |
computePreferredDimension(java.awt.Component component)
Compute the preferred dimension of a component
|
static java.awt.Rectangle |
computeScreenRectangle(java.awt.Window window)
Compute the rectangle of the screen where is a window
|
static javax.swing.JFrame |
getFrameParent(java.awt.Container container)
Obtain frame parent of a container
|
static java.awt.Point |
getLocationOn(java.awt.Component component,
java.awt.Component parent)
Give the relative of a component for an other one
|
static java.awt.Rectangle |
getScreenBounds(int screen)
Give bounds of a screen
|
static java.lang.String |
getScreenIdentifier(int screenIndex)
Screen identifier
|
static void |
initializeGUI()
Initialize GUI with operating system skin, call it before create any frame
|
static void |
locateMouseAt(int x,
int y)
Place the mouse on a location on the screen
|
static void |
locateMouseOver(java.awt.Component component)
Place the mouse over the middle of a component
|
static void |
locateMouseOver(java.awt.Component component,
int x,
int y)
Place the mouse over a component
|
static int |
numberOfScreen()
Number of screen
|
static java.awt.Cursor |
obtainInvisbleCursor()
Invisible cursor
|
static int |
obtainNumberOffScreen()
Number of screen
|
static int |
obtainScreenIndex(java.awt.Window window)
Obtain index of the screen where is the window
|
static void |
packedSize(java.awt.Window window)
Put a window in it's pack size
Size is automatic limited to the window's screen |
static java.awt.image.BufferedImage |
screenShot()
Make a screen shot
|
static javax.swing.JFrame |
searchFrameParent(java.awt.Component component)
Search JFrame parent of a component
|
static void |
simulateKeyPress(int keyCode)
Simulate a key press
|
static void |
simulateKeyRelease(int keyCode)
Simulate a key release
|
static void |
simulateMousePress(int button)
Simulate a mouse press
|
static void |
simulateMouseRelease(int button)
Simulate a mouse release
|
static void |
simulateReleasedPressed(int time)
Simulate a release then press mouse button
|
static void |
takeAllScreen(java.awt.Window window)
Make widow take all it's screen
|
private static java.awt.image.BufferedImage EMPTY_IMAGE
private static final java.awt.GraphicsDevice[] GRAPHICS_DEVICES
private static java.awt.Cursor INVISIBLE_CURSOR
private static final java.awt.Robot ROBOT
public static final java.awt.GraphicsEnvironment GRAPHICS_ENVIRONMENT
public static final java.awt.Toolkit TOOLKIT
private static void checkScreenIndex(int screenIndex)
screenIndex
- Screen index to checkpublic static void centerOnScreen(java.awt.Window window)
window
- Widow to centerpublic static void changeScreen(java.awt.Window window, int screenIndex)
window
- Widow to translatescreenIndex
- Destination screenpublic static int computeIntresectedArea(java.awt.Rectangle rectangle1, java.awt.Rectangle rectangle2)
rectangle1
- First rectanglerectangle2
- Second rectanglepublic static java.awt.Dimension computeMaximumDimension(java.awt.Component component)
component
- Component to compute it's maximum sizepublic static java.awt.Dimension computeMinimumDimension(java.awt.Component component)
component
- Component to compute it's minimum sizepublic static java.awt.Dimension computePreferredDimension(java.awt.Component component)
component
- Component to compute it's preferred sizepublic static java.awt.Rectangle computeScreenRectangle(java.awt.Window window)
window
- Window we looking for its screenpublic static javax.swing.JFrame getFrameParent(java.awt.Container container)
container
- Container to get its parentpublic static java.awt.Point getLocationOn(java.awt.Component component, java.awt.Component parent)
component
- Component to search its positionparent
- A component ancestornull
if parent is not an ancestor of componentpublic static java.awt.Rectangle getScreenBounds(int screen)
screen
- Screen indexpublic static java.lang.String getScreenIdentifier(int screenIndex)
screenIndex
- Screen indexpublic static void initializeGUI()
public static void locateMouseAt(int x, int y)
x
- X screen positiony
- Y screen positionpublic static void locateMouseOver(java.awt.Component component)
component
- Component mouse go overpublic static void locateMouseOver(java.awt.Component component, int x, int y)
component
- Component mouse go overx
- X relative to component up-left cornery
- Y relative to component up-left cornerpublic static int numberOfScreen()
public static java.awt.Cursor obtainInvisbleCursor()
public static int obtainNumberOffScreen()
public static int obtainScreenIndex(java.awt.Window window)
window
- Considered windowpublic static void packedSize(java.awt.Window window)
window
- Window to packpublic static java.awt.image.BufferedImage screenShot()
public static javax.swing.JFrame searchFrameParent(java.awt.Component component)
component
- Component search it's JFram parentnull
if component haven't a JFrame parentpublic static void simulateKeyPress(int keyCode)
keyCode
- Key codepublic static void simulateKeyRelease(int keyCode)
keyCode
- Key codepublic static void simulateMousePress(int button)
button
- Mouse buttonspublic static void simulateMouseRelease(int button)
button
- Mouse buttonspublic static void simulateReleasedPressed(int time)
time
- Time between release and presspublic static void takeAllScreen(java.awt.Window window)
window
- Window to maximize