use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class MaximizedToMaximized method main.
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
final Dimension screenSize = toolkit.getScreenSize();
final Insets screenInsets = toolkit.getScreenInsets(graphicsDevice.getDefaultConfiguration());
final Rectangle availableScreenBounds = new Rectangle(screenSize);
availableScreenBounds.x += screenInsets.left;
availableScreenBounds.y += screenInsets.top;
availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
frame.setBounds(availableScreenBounds.x, availableScreenBounds.y, availableScreenBounds.width, availableScreenBounds.height);
frame.setVisible(true);
Rectangle frameBounds = frame.getBounds();
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
((SunToolkit) toolkit).realSync();
Rectangle maximizedFrameBounds = frame.getBounds();
if (maximizedFrameBounds.width < frameBounds.width || maximizedFrameBounds.height < frameBounds.height) {
throw new RuntimeException("Maximized frame is smaller than non maximized");
}
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class AltTabCrashTest method findDisplayMode.
private DisplayMode findDisplayMode() {
GraphicsDevice gd = getGraphicsConfiguration().getDevice();
DisplayMode[] dms = gd.getDisplayModes();
DisplayMode currentDM = gd.getDisplayMode();
for (DisplayMode dm : dms) {
if (dm.getBitDepth() > 8 && dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && dm.getBitDepth() != currentDM.getBitDepth() && dm.getWidth() == currentDM.getWidth() && dm.getHeight() == currentDM.getHeight()) {
// depth
return dm;
}
if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI && (dm.getWidth() != currentDM.getWidth() || dm.getHeight() != currentDM.getHeight())) {
// dimensions
return dm;
}
}
return null;
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class BufferStrategyExceptionTest method main.
public static void main(String[] args) {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
for (int i = 0; i < TEST_REPS; i++) {
TestFrame f = new TestFrame();
f.pack();
f.setSize(400, 400);
f.setVisible(true);
if (i % 2 == 0) {
gd.setFullScreenWindow(f);
}
// generate a resize event which will invalidate the peer's
// surface data and hopefully cause an exception during
// BufferStrategy creation in TestFrame.render()
Dimension d = f.getSize();
d.width -= 5;
d.height -= 5;
f.setSize(d);
f.render();
gd.setFullScreenWindow(null);
sleep(100);
f.dispose();
}
System.out.println("Test passed.");
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class DisplayChangeVITest method selectDisplayModes.
private void selectDisplayModes() {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
dms = new ArrayList<DisplayMode>();
DisplayMode[] dmArray = gd.getDisplayModes();
boolean found8 = false, found16 = false, found24 = false, found32 = false;
for (DisplayMode dm : dmArray) {
if (!found8 && (dm.getBitDepth() == 8 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && (dm.getWidth() >= 800 && dm.getWidth() < 1024)) {
dms.add(dm);
found8 = true;
continue;
}
if (!found32 && (dm.getBitDepth() == 32 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && dm.getWidth() >= 1280) {
dms.add(dm);
found32 = true;
continue;
}
if (!found16 && dm.getBitDepth() == 16 && (dm.getWidth() >= 1024 && dm.getWidth() < 1280)) {
dms.add(dm);
found16 = true;
continue;
}
if (found8 && found16 && found32) {
break;
}
}
System.err.println("Found display modes:");
for (DisplayMode dm : dms) {
System.err.printf("DisplayMode[%dx%dx%d]\n", dm.getWidth(), dm.getHeight(), dm.getBitDepth());
}
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class DisplayChangeVITest method main.
public static void main(String[] args) throws Exception {
DisplayChangeVITest test = new DisplayChangeVITest();
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (gd.isFullScreenSupported()) {
gd.setFullScreenWindow(test);
Thread t = new Thread(test);
t.run();
synchronized (lock) {
while (!done) {
try {
lock.wait(50);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
System.err.println("Test Passed.");
} else {
System.err.println("Full screen not supported. Test passed.");
}
}
Aggregations