public void setFullscreen(boolean fullscreen) { // get a reference to the device. GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); DisplayMode dispMode = device.getDisplayMode(); // save the old display mode before changing it. dispModeOld = device.getDisplayMode(); if (this.fullscreen != fullscreen) { // are we actually changing modes. // change modes. this.fullscreen = fullscreen; // toggle fullscreen mode if (!fullscreen) { // change to windowed mode. // set the display mode back to the what it was when // the program was launched. device.setDisplayMode(dispModeOld); // hide the frame so we can change it. setVisible(false); // remove the frame from being displayable. dispose(); // put the borders back on the frame. setUndecorated(false); // needed to unset this window as the fullscreen window. device.setFullScreenWindow(null); // recenter window setLocationRelativeTo(null); setResizable(true); // reset the display mode to what it was before // we changed it. setVisible(true); } else { // change to fullscreen. // hide everything setVisible(false); // remove the frame from being displayable. dispose(); // remove borders around the frame setUndecorated(true); // make the window fullscreen. device.setFullScreenWindow(this); // attempt to change the screen resolution. device.setDisplayMode(dispMode); setResizable(false); setAlwaysOnTop(false); // show the frame setVisible(true); } // make sure that the screen is refreshed. repaint(); } }
/** * Esta funcion recibe un modo y lo pone si es posible. * * @param dm Modo nuevo. */ public void cambiarModo(DisplayMode dm) { try { if (device.isDisplayChangeSupported()) { device.setFullScreenWindow(getFullScreenWindow()); device.setDisplayMode(dm); } else System.out.println("No se permite el cambio de resolucion"); } catch (IllegalArgumentException ex) { System.out.println("Error de argumentos... No se ha podido poner a pantalla completa. "); } }
/** Enters full screen mode and changes the display mode. */ public void setFullScreen(DisplayMode displayMode, JFrame window) { window.setUndecorated(true); window.setResizable(false); cmdemo bgd = new cmdemo(); JList mission = new JList(string); mission.setVisibleRowCount(4); JScrollPane pane = new JScrollPane(mission); pane.setBounds(400, 400, 225, 70); window.getContentPane().add(pane); muButton.setBounds(764 - 120, 625 - 10, 225, 49); textField1.setBounds(630 - 120, 328 - 10, 225, 25); window.getContentPane().add(muButton); window.getContentPane().add(textField1); // window.add(bgd); muButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); muButton.setToolTipText("start"); muButton.setBorder(null); muButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/start1.jpg")); muButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startActionPerformed(evt); } }); aButton.setBounds(284 - 120, 625 - 10, 225, 49); window.getContentPane().add(aButton); window.add(bgd); aButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); aButton.setToolTipText("back"); aButton.setBorder(null); aButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/back1.jpg")); aButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backActionPerformed(evt); } }); device.setFullScreenWindow(window); if (displayMode != null && device.isDisplayChangeSupported()) { try { device.setDisplayMode(displayMode); } catch (IllegalArgumentException ex) { // ignore - illegal mode for this device } } }
/** Pasa a modo grafico en pantalla completa. */ private void initFullScreen(int width, int height, int depth, int refresh) { this.width = width; this.height = height; window.setUndecorated(true); window.setIgnoreRepaint(true); try { graphicsDevice.setFullScreenWindow(window); graphicsDevice.setDisplayMode(new DisplayMode(width, height, depth, refresh)); timer = new N3Timer(1, this); } catch (Exception e) { shutdown(); } }
public void setwnd() { GraphicsDevice dev = getGraphicsConfiguration().getDevice(); if (prefs == null) return; try { dev.setDisplayMode(prefs); dev.setFullScreenWindow(null); setVisible(false); dispose(); setUndecorated(false); setVisible(true); } catch (Exception e) { throw (new RuntimeException(e)); } prefs = null; }
// make frame full screen public void setFullScreen(DisplayMode dm) { JFrame f = new JFrame(); f.setUndecorated(true); f.setIgnoreRepaint(true); f.setResizable(false); vc.setFullScreenWindow(f); if (dm != null && vc.isDisplayChangeSupported()) { try { vc.setDisplayMode(dm); } catch (Exception ex) { } } f.createBufferStrategy(2); }
public void setfs() { GraphicsDevice dev = getGraphicsConfiguration().getDevice(); if (prefs != null) return; prefs = dev.getDisplayMode(); try { setVisible(false); dispose(); setUndecorated(true); setVisible(true); dev.setFullScreenWindow(this); dev.setDisplayMode(fsmode); pack(); } catch (Exception e) { throw (new RuntimeException(e)); } }
private void enterFullscreen() { GraphicsDevice device = m_renderTarget.getGraphicsConfiguration().getDevice(); if (!device.isFullScreenSupported()) m_logger.error("Cannot enter full-screen. Device does not support full-screen mode"); else { device.setFullScreenWindow(m_renderTarget); DisplayMode best = device.getDisplayMode(); if (!device.isDisplayChangeSupported()) m_logger.error( "Device does not support change of display modes. Using default display mode."); else { for (DisplayMode d : device.getDisplayModes()) { int dDeltaWidth = d.getWidth() - m_canvasRenderWidth; int dDeltaHeight = d.getHeight() - m_canvasRenderHeight; int dDeltaBitDepth = d.getBitDepth() - PREFERRED_BIT_DEPTH; int bestDeltaWidth = best.getWidth() - m_canvasRenderWidth; int bestDeltaHeight = best.getHeight() - m_canvasRenderHeight; int bestDeltaBitDepth = best.getBitDepth() - PREFERRED_BIT_DEPTH; if (dDeltaWidth == bestDeltaWidth && dDeltaHeight == bestDeltaHeight) { if (d.getBitDepth() > MIN_BIT_DEPTH && (Math.abs(dDeltaBitDepth) < Math.abs(bestDeltaBitDepth))) best = d; } else if (dDeltaWidth == 0 || (dDeltaWidth > 0 && dDeltaWidth < bestDeltaWidth) && dDeltaHeight == 0 || (dDeltaHeight > 0 && dDeltaHeight < bestDeltaWidth)) { best = d; } } device.setDisplayMode(best); } m_renderTarget.setBounds( new Rectangle( m_renderTarget.getLocation(), new Dimension(best.getWidth(), best.getHeight()))); } }
/** * Esta funcion simplemente pondra la aplicacion a pantalla completa. * * @param dm */ protected void setFullScreen(DisplayMode dm) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setFont(new Font("Dialog", Font.PLAIN, 13)); frame.setBackground(Color.BLACK); frame.setForeground(Color.white); frame.setUndecorated(true); frame.setIgnoreRepaint(true); frame.setResizable(false); frame.setVisible(true); frame.setFocusTraversalKeysEnabled(false); device.setFullScreenWindow(frame); if (dm != null && device.isDisplayChangeSupported()) { try { device.setDisplayMode(dm); } catch (IllegalArgumentException ex) { System.out.println("No se ha podido poner a pantalla completa."); } } frame.createBufferStrategy(2); }
/** Permite volver al modo grafico antiguo. */ protected void shutdown() { graphicsDevice.setDisplayMode(oldDisplayMode); graphicsDevice.setFullScreenWindow(null); }
public static void chooseBestDisplayMode(GraphicsDevice device) { DisplayMode best = getBestDisplayMode(device); if (best != null) { device.setDisplayMode(best); } }