Java Utililty Methods Screen Full Size

List of utility methods to do Screen Full Size

Description

The list of methods to do Screen Full Size are organized into topic(s).

Method

voidfullScreen()
full Screen
Robot robot = null;
try {
    robot = new Robot();
} catch (AWTException e) {
    e.printStackTrace();
robot.setAutoDelay(80);
robot.mouseMove(500, 500);
...
voidfullScreen(Component component)
full Screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = component.getSize();
if (frameSize.height > screenSize.height) {
    frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width) {
    frameSize.width = screenSize.width;
component.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
voidfullScreen(Window window)
full Screen
Dimension dimScreen = window.getToolkit().getScreenSize();
window.setLocation(-4, -4);
window.setSize(dimScreen.width + 8, dimScreen.height + 8);
RectanglegetOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets)
get Opposite Full Screen Bounds For
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
TreeMap<Integer, Rectangle> prioMap = new TreeMap<Integer, Rectangle>();
for (GraphicsDevice dev : ge.getScreenDevices()) {
    Rectangle bounds;
    if ((!includeReservedInsets) && dev == ge.getDefaultScreenDevice()) {
        bounds = ge.getMaximumWindowBounds();
    } else {
        bounds = dev.getDefaultConfiguration().getBounds();
...
voidinitializeScreenArea(int priority)
If you use methods such as #ensureOnScreen(java.awt.Rectangle) , #getContainingScreenBounds(java.awt.Rectangle,boolean) or #getScreenArea() for the first time, it will take up to a couple of seconds to run because it needs to get device information.
final Thread _initializationThread = new Thread() {
    @Override
    public void run() {
        GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
};
_initializationThread.setPriority(priority);
if (INITIALIZE_SCREEN_AREA_USING_THREAD) {
...
voidlocateInScreenCenter(Component c)
locate In Screen Center
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
c.setLocation((screenDim.width - c.getWidth()) / 2, (screenDim.height - c.getHeight()) / 2);
voidlocateOnOpticalScreenCenter(Component component)
Locates the given component on the screen's center.
Dimension paneSize = component.getSize();
Dimension screenSize = component.getToolkit().getScreenSize();
component.setLocation((screenSize.width - paneSize.width) / 2,
        (int) ((screenSize.height - paneSize.height) * 0.45));
voidsetFrameToMiddleOfTheScreen(Window window)
Sets the given Window to the middle of the screen.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenMiddleX = screenSize.width / 2;
int screenMiddleY = screenSize.height / 2;
int x = screenMiddleX - (window.getWidth() / 2);
int y = screenMiddleY - (window.getHeight() / 2);
window.setBounds(x, y, window.getWidth(), window.getHeight());
voidsetWindowCanFullScreen(Window w, boolean flag)
set Window Can Full Screen
voidshowOnSameScreenAsMouseCenter(Container frame)
show On Same Screen As Mouse Center
Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
GraphicsDevice device;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice lstGDs[] = ge.getScreenDevices();
ArrayList<GraphicsDevice> lstDevices = new ArrayList<GraphicsDevice>(lstGDs.length);
for (GraphicsDevice gd : lstGDs) {
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Rectangle screenBounds = gc.getBounds();
...