use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class CPlatformLWWindow method getGraphicsDevice.
@Override
public GraphicsDevice getGraphicsDevice() {
CGraphicsEnvironment ge = (CGraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment();
LWLightweightFramePeer peer = (LWLightweightFramePeer) getPeer();
int scale = ((LightweightFrame) peer.getTarget()).getScaleFactor();
Rectangle bounds = ((LightweightFrame) peer.getTarget()).getHostBounds();
for (GraphicsDevice d : ge.getScreenDevices()) {
if (d.getDefaultConfiguration().getBounds().intersects(bounds) && ((CGraphicsDevice) d).getScaleFactor() == scale) {
return d;
}
}
// We shouldn't be here...
return ge.getDefaultScreenDevice();
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class CGLSurfaceData method getGC.
public static CGLGraphicsConfig getGC(CPlatformView pView) {
if (pView != null) {
return (CGLGraphicsConfig) pView.getGraphicsConfiguration();
} else {
// REMIND: this should rarely (never?) happen, but what if
// default config is not CGL?
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (CGLGraphicsConfig) gd.getDefaultConfiguration();
}
}
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.");
}
Aggregations