List of utility methods to do Screen Size
Point | adjustPopupLocationToFitScreen(Component invoker, Dimension preferredSize, int xposition, int yposition) adjust Popup Location To Fit Screen Point p = new Point(xposition, yposition); if (GraphicsEnvironment.isHeadless()) return p; Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds; Insets screenInsets; GraphicsConfiguration gc = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ... |
String | formatScreenSize(Dimension screenSize) format Screen Size if (screenSize != null) { return String.format("%dx%d", screenSize.width, screenSize.height); } else return "0x0"; |
int | getComponentWidthForResolution(int screenWidth, int desiredSize) Returns a proportional width according to screenWidth and desiredSize for the current screen resolution int currentScreenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; int result = desiredSize * currentScreenWidth / screenWidth; return result; |
Dimension | getDefaultAppSize() get Default App Size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); return new Dimension(4 * screenSize.width / 5, 4 * screenSize.height / 5); |
Dimension | getDefaultDeviceScreenSize() get Default Device Screen Size GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getScreenDevices()[0];
Dimension screenSize = gs.getDefaultConfiguration().getBounds().getSize();
return screenSize;
|
Dimension | getDefaultMainFrameSize() get Default Main Frame Size Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
size.width = size.width * 8 / 10;
size.height = size.height * 8 / 10;
return size;
|
Rectangle | getDefaultScreenBounds() get Default Screen Bounds return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()
.getBounds();
|
GraphicsDevice | getDefaultScreenDevice() Return the default screen device. try { return getLocalGraphicsEnvironment().getDefaultScreenDevice(); } catch (HeadlessException e) { return null; |
Dimension | getDefaultScreenSize() get Default Screen Size Rectangle dimension = getDefaultScreenSizeWithoutAdjustment(); int noOfScreens = (int) Math.floor((double) dimension.width / (double) dimension.height); if (noOfScreens < 1) { noOfScreens = 1; if (dimension.width < 100 || dimension.height < 100) { dimension.width = DEFAULT_SIZE.width; dimension.height = DEFAULT_SIZE.height; ... |
Rectangle | getDefaultScreenSizeWithoutAdjustment() get Default Screen Size Without Adjustment return getDefaultScreenSizeWithoutAdjustment(false);
|