I'll be brief. How to get the screen size (On Windows) user (If at all possible). You can object, so even better. Or do you need to do some assembly inserts? Thanks in advance!
|
1 answer
I suppose that by dimensions you mean screen resolution.
The easiest way is to use the java.awt.Toolkit
class:
Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); int width = screenSize.width; int height = screenSize.height;
If you need more information about graphics devices, or it’s about a system with multiple displays, you need GraphicsEnvironment
and GraphicsDevice
from the same package. For the main device:
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int width = device.getDisplayMode().getWidth(); int height = device.getDisplayMode().getHeight();
To select a specific device from among those available, call getScreenDevices()
:
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
and contact index:
devices[0].getDisplayMode() devices[1].getDisplayMode() ...
|