List of usage examples for java.awt GraphicsDevice isDisplayChangeSupported
public boolean isDisplayChangeSupported()
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); boolean canChg = gs.isDisplayChangeSupported(); if (canChg) { DisplayMode displayMode = gs.getDisplayMode(); int screenWidth = 640; int screenHeight = 480; int bitDepth = 8; displayMode = new DisplayMode(screenWidth, screenHeight, bitDepth, displayMode.getRefreshRate()); try {//from www . j a v a 2s . c o m gs.setDisplayMode(displayMode); } catch (Throwable e) { gs.setFullScreenWindow(null); } } }
From source file:FullScreen.java
public static void main(String args[]) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice(); DisplayMode originalDisplayMode = graphicsDevice.getDisplayMode(); try {//from w ww . j a v a2 s. c o m Frame frame = new Frame(); frame.setUndecorated(true); frame.setIgnoreRepaint(true); graphicsDevice.setFullScreenWindow(frame); if (graphicsDevice.isDisplayChangeSupported()) { graphicsDevice.setDisplayMode(getBestDisplayMode(graphicsDevice)); } frame.createBufferStrategy(2); // 2 buffers Rectangle bounds = frame.getBounds(); BufferStrategy bufferStrategy = frame.getBufferStrategy(); while (!done()) { Graphics g = null; try { g = bufferStrategy.getDrawGraphics(); if ((counter <= 2)) { // 2 buffers g.setColor(Color.CYAN); g.fillRect(0, 0, bounds.width, bounds.height); } g.setColor(Color.RED); // redraw prior line, too, since 2 buffers if (counter != 1) { g.drawLine(counter - 1, (counter - 1) * 5, bounds.width, bounds.height); } g.drawLine(counter, counter * 5, bounds.width, bounds.height); bufferStrategy.show(); } finally { if (g != null) { g.dispose(); } } try { Thread.sleep(250); } catch (InterruptedException ignored) { } } } finally { graphicsDevice.setDisplayMode(originalDisplayMode); graphicsDevice.setFullScreenWindow(null); } System.exit(0); }
From source file:MultiBufferTest.java
public MultiBufferTest(int numBuffers, GraphicsDevice device) { try {//from w w w . ja v a 2 s . co m GraphicsConfiguration gc = device.getDefaultConfiguration(); mainFrame = new Frame(gc); mainFrame.setUndecorated(true); mainFrame.setIgnoreRepaint(true); device.setFullScreenWindow(mainFrame); if (device.isDisplayChangeSupported()) { chooseBestDisplayMode(device); } Rectangle bounds = mainFrame.getBounds(); mainFrame.createBufferStrategy(numBuffers); BufferStrategy bufferStrategy = mainFrame.getBufferStrategy(); for (float lag = 2000.0f; lag > 0.00000006f; lag = lag / 1.33f) { for (int i = 0; i < numBuffers; i++) { Graphics g = bufferStrategy.getDrawGraphics(); if (!bufferStrategy.contentsLost()) { g.setColor(COLORS[i]); g.fillRect(0, 0, bounds.width, bounds.height); bufferStrategy.show(); g.dispose(); } try { Thread.sleep((int) lag); } catch (InterruptedException e) { } } } } catch (Exception e) { e.printStackTrace(); } finally { device.setFullScreenWindow(null); } }
From source file:DisplayModeModel.java
public DisplayModeTest(GraphicsDevice device) { super(device.getDefaultConfiguration()); this.device = device; setTitle("Display Mode Test"); originalDM = device.getDisplayMode(); setDMLabel(originalDM);/*from w w w .jav a 2s . c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); // Make sure a DM is always selected in the list exit.addActionListener(this); changeDM.addActionListener(this); changeDM.setEnabled(device.isDisplayChangeSupported()); }