List of utility methods to do Screen Size
Rectangle | getDesktopBounds() Return the entire desktop bounds (take multi screens in account) Rectangle result = new Rectangle(); final GraphicsDevice[] gs = getLocalGraphicsEnvironment().getScreenDevices(); for (int j = 0; j < gs.length; j++) result = result.union(gs[j].getDefaultConfiguration().getBounds()); return result; |
Rectangle | getDesktopBounds() get the bounds of the users desktop... Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle rect = gc.getBounds(); if (rect != null) ... |
Rectangle | getLocalScreenBounds() Gets the local monitor's screen bounds. GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
return e.getMaximumWindowBounds();
|
Rectangle | getLocationFromMouse(Dimension panelPrefSize_) get Location From Mouse GraphicsDevice device = MouseInfo.getPointerInfo().getDevice(); Dimension screensize = new Dimension(device.getDisplayMode().getWidth(), device.getDisplayMode().getHeight()); int x = (screensize.width - panelPrefSize_.width) / 2; int y = (screensize.height - panelPrefSize_.height) / 2; return new Rectangle(x, y, panelPrefSize_.width, panelPrefSize_.height); |
Rectangle | getMaximumWindowBounds() Computes the maximum bounds of the current screen device. try { final GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); return localGraphicsEnvironment.getMaximumWindowBounds(); } catch (Exception e) { final Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); return new Rectangle(0, 0, s.width, s.height); |
Rectangle | getMaximumWindowBounds() get Maximum Window Bounds final GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { final Method method = GraphicsEnvironment.class.getMethod("getMaximumWindowBounds", (Class[]) null); return (Rectangle) method.invoke(localGraphicsEnvironment, (Object[]) null); } catch (Exception e) { final Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); return new Rectangle(0, 0, s.width, s.height); ... |
int | getMaximumWindowWidth() get Maximum Window Width Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dim = toolkit.getScreenSize();
return dim.width;
|
Dimension | getMaxSize(Window frame) get Max Size Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsConfiguration config = frame.getGraphicsConfiguration(); Dimension availableScreenSize = new Dimension(toolkit.getScreenSize()); Insets insets = toolkit.getScreenInsets(config); availableScreenSize.width -= (insets.left + insets.right); availableScreenSize.height -= (insets.top + insets.bottom); return availableScreenSize; |
Dimension | getMaxUsableScreenSize() get Max Usable Screen Size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
screenSize.width = Math.min(screenSize.width, GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDisplayMode().getWidth());
screenSize.height -= 48;
return screenSize;
|
Dimension | getMaxWindowSize() Gets the max window size. final Dimension d = getScreenDimesion(); return new Dimension((int) d.getWidth() - 100, (int) d.getHeight() - 100); |