public synchronized void toggleFullScreen() { if (inFullScreen) { this.dispose(); gd.setFullScreenWindow(null); canvas.setSize(NES_HEIGHT * screenScaleFactor, NES_WIDTH * screenScaleFactor); this.setUndecorated(false); this.setVisible(true); inFullScreen = false; buildMenus(); // nes.resume(); } else { setJMenuBar(null); gd = getGraphicsConfiguration().getDevice(); if (!gd.isFullScreenSupported()) { // then fullscreen will give a window the size of the screen instead messageBox("Fullscreen is not supported by your OS or version of Java."); } this.dispose(); this.setUndecorated(true); gd.setFullScreenWindow(this); this.setVisible(true); inFullScreen = true; } }
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(); } }
/** Recupera el modo de pantalla no completa */ public void recuperarPantalla() { Window window = device.getFullScreenWindow(); if (window != null) { window.dispose(); } device.setFullScreenWindow(null); }
public PlateauGraphique(/*int largeur, int hauteur,*/ Monopoly m) { this.m = m; cases = new ArrayList<CaseGraphique>(); setExtendedState(JFrame.MAXIMIZED_BOTH); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device.setFullScreenWindow(this); this.largeur = getContentPane().getWidth(); this.hauteur = getContentPane().getHeight(); if (largeur > hauteur) largeur = hauteur; else hauteur = largeur; initialiser(); addComponents(getContentPane()); for (Joueur j : m.getJoueurs()) { ((JoueurDefaut) j).addObserver(this); } pack(); setVisible(true); }
public MafiaMainClass() { setLayout(card); // BorderLayout // add("WR",wr); add("LOG", login); // window창 위에 penal을 올린다 setTitle("MAFIA GAME - LOGIN"); setSize(1280, 985); // window 크기 /* // 창을 중앙에 띄운다. Dimension screen=Toolkit.getDefaultToolkit().getScreenSize(); Dimension ex_size = this.getSize(); int xpos=(int)(screen.getWidth()/2 - this.getWidth()/2); int ypos=(int)(screen.getHeight()/2 - this.getHeight()/2); this.setLocation(xpos,ypos); */ // 전체화면 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); setUndecorated(true); gd.setFullScreenWindow(this); setVisible(true); // window 보이기 setResizable(false); // 화면크기 고정 addMouseListener(this); // mouse움직임 }
public void beginExecution() { if (cam == null) { int numBuffers = 2; env = GraphicsEnvironment.getLocalGraphicsEnvironment(); device = env.getDefaultScreenDevice(); // MultiBufferTest test = new MultiBufferTest(numBuffers, device); try { GraphicsConfiguration gc = device.getDefaultConfiguration(); mainFrame = new Frame(gc); mainFrame.setUndecorated(true); mainFrame.setIgnoreRepaint(true); device.setFullScreenWindow(mainFrame); if (device.isDisplayChangeSupported()) { chooseBestDisplayMode(device); } mainFrame.createBufferStrategy(numBuffers); bufferStrategy = mainFrame.getBufferStrategy(); } catch (Exception e) { e.printStackTrace(); } } }
// get out of full screen public void restoreScreen() { Window w = vc.getFullScreenWindow(); if (w != null) { w.dispose(); } vc.setFullScreenWindow(null); }
private boolean enterFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) { log.info("Switching to full screen mode."); frame.setVisible(false); try { device.setFullScreenWindow(frame); } catch (InternalError e) { log.error("Failed to switch to full screen exclusive mode."); e.printStackTrace(); frame.setVisible(true); return false; } frame.dispose(); frame.setUndecorated(true); frame.setVisible(true); frame.requestFocusInWindow(); return true; } } log.warn("No screens available or full screen exclusive mode is unsupported on your platform."); postError("Full screen mode is not supported on your platform."); return false; }
/** Restores the screen's display mode. */ public void restoreScreen() { Window window = device.getFullScreenWindow(); if (window != null) { window.dispose(); } device.setFullScreenWindow(null); }
/** * ZombieFrame's constructor. * * @param contents Optional JPanel(s) to add to content pane. Arguments > 0 are ignored. */ public ZombieFrame(JPanel... contents) { super("ZombieHouse"); // Request keyboard focus for the frame. setFocusable(true); requestFocusInWindow(); requestFocus(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setUndecorated(true); setResizable(false); setBackground(Color.BLACK); // The content pane. An optional JPanel may be passed into the // constructor. It creates an empty pane with a black background if // one isn't provided. pane = getContentPane(); pane.setBackground(Color.BLACK); pane.setFocusable(false); pane.setVisible(true); if (contents.length > 0) { pane.add(contents[0]); } keys = new ZombieKeyBinds((JComponent) pane); // Get the graphics device information. GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphics = environment.getDefaultScreenDevice(); pack(); // Go full screen, if supported. if (graphics.isFullScreenSupported()) { try { graphics.setFullScreenWindow(this); // Having gone full screen, retrieve the display size. // size = Toolkit.getDefaultToolkit().getScreenSize(); // This double-switching of setVisible is to fix a bug with // full-screen-exclusive mode on OS X. Versions 10.8 and later // don't send keyboard events properly without it. if (System.getProperty("os.name").contains("OS X")) { setVisible(false); } } catch (HeadlessException ex) { System.err.println( "Error: primary display not set or found. " + "Your experience of life may be suboptimal."); ex.printStackTrace(); } } else { // If full-screen-exclusive mode isn't supported, switch to // maximized window mode. System.err.println("Full-screen-exclusive mode not supported."); setExtendedState(Frame.MAXIMIZED_BOTH); } setVisible(true); }
/** * Create the window, asking for which screen to use if there are multiple monitors and either * forcechoice is true, or the user hasn't already picked a screen. * * @param part the JComponent to display * @param forcechoice false if user shouldn't be asked twice which of several monitors to use. */ private void init(JComponent part, boolean forcechoice) { if (forcechoice) { defaultScreen = null; } screen = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screens[] = ge.getScreenDevices(); if (defaultScreen != null) { for (int i = 0; i < screens.length; i++) { if (screens[i] == defaultScreen) { screen = defaultScreen; } } } if (screens.length == 1) { screen = screens[0]; } if (screen == null) { screen = pickScreen(screens); } if (dead) { return; } defaultScreen = screen; DisplayMode dm = screen.getDisplayMode(); GraphicsConfiguration gc = screen.getDefaultConfiguration(); jf = new JFrame(gc); jf.setUndecorated(true); jf.setBounds(gc.getBounds()); jf.getContentPane().add(part); jf.setVisible(true); screen.setFullScreenWindow(jf); }
public void stop() { started = false; timer.stop(); setVisible(false); stopper.terminate(); if (terminateOnClose) { System.exit(0); } gd.setFullScreenWindow(null); }
/** * 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. "); } }
public void start() { started = true; if (allowAltTab && !debugMode) { stopper.start(); } setVisible(true); if (SystemUtil.isMac()) { gd.setFullScreenWindow(this); } timer.start(); }
/** 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 } } }
/** * Close the full screen window. This particular FullScreenWindow * * <p>object cannot be used again. */ public void close() { dead = true; flag.set(); screen.setFullScreenWindow(null); if (jf != null) { jf.dispose(); } }
public static void setFullscreen(boolean fs) { GraphicsDevice device = guiFrame.getGraphicsConfiguration().getDevice(); // hide window guiFrame.setVisible(false); guiFrame.dispose(); // change options guiFrame.setUndecorated(fs); device.setFullScreenWindow(fs ? guiFrame : null); // display window guiFrame.setLocationRelativeTo(null); guiFrame.setVisible(true); fullscreen = fs; }
private void exitFullscreen() { GraphicsDevice device = m_renderTarget.getGraphicsConfiguration().getDevice(); Window fullscrenWindow = device.getFullScreenWindow(); if (fullscrenWindow == m_renderTarget) { device.setFullScreenWindow(null); m_renderTarget.setBounds( new Rectangle( m_renderTarget.getLocation(), new Dimension(m_canvasRenderWidth, m_canvasRenderHeight))); } }
public static void main(String agrs[]) { // Determine if full-screen mode is supported directly GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); if (gs.isFullScreenSupported()) { // Full-screen mode is supported } else { // Full-screen mode will be simulated } // Create a button that leaves full-screen mode Button btn = new Button("OK"); btn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Return to normal windowed mode GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); gs.setFullScreenWindow(null); } }); // Create a window for full-screen mode; add a button to leave full-screen mode Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); win.add(btn, BorderLayout.CENTER); try { // Enter full-screen mode gs.setFullScreenWindow(win); win.validate(); // ... } finally { // Exit full-screen mode gs.setFullScreenWindow(null); } }
/** 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 MultiBufferTest(int numBuffers, GraphicsDevice device) { try { 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) { System.out.println("lag = " + lag); 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); g.fillRect(0, 0, 20, 20); bufferStrategy.show(); g.dispose(); } try { Thread.sleep((int) lag); } catch (InterruptedException e) { } } } } catch (Exception e) { logger.error(e.getMessage(), e); } finally { device.setFullScreenWindow(null); } }
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 static void setFullscreen(boolean fs) { if (fs != fullscreen) { GraphicsDevice device = guiFrame.getGraphicsConfiguration().getDevice(); // hide window guiFrame.setVisible(false); guiFrame.dispose(); // change options guiFrame.setUndecorated(fs); device.setFullScreenWindow(fs ? guiFrame : null); // display window guiFrame.setLocationRelativeTo(null); guiFrame.setVisible(true); instance.requestFocusInWindow(); fullscreen = fs; } Options.set(Options.FULLSCREEN, fullscreen); }
/** @param args */ public static void main(String[] args) { // Make instance of this class, acts as parent for frames Init init = new Init(); // get the graphics environment GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); // check there are more than one devices // this is actually broken (has 2 devices whether or not projector is connected) // odd if (gs.length < 1) { System.err.println("You haven't connected the projector!"); System.exit(1); } // get the projector and screen GraphicsDevice gd0 = gs[1]; // projector GraphicsDevice gd1 = gs[0]; // screen GraphicsConfiguration gc = gd0.getDefaultConfiguration(); // set projection's graphics configuration to device 0 (projector) init.m_projection = new Projection(gc); // create the gui frame on device 1 (screen) init.m_gui = new GUI(init, gd1.getDefaultConfiguration()); // set size of control box init.m_gui.setSize(CONTROL_WIDTH, CONTROL_HEIGHT); // make projection fullscreen gd0.setFullScreenWindow(init.m_projection); // close everything on any frame's closing init.m_gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); init.m_projection.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // show frames init.m_gui.setVisible(true); init.m_projection.setVisible(true); // Create chess interface init.m_chess = new ChessInit(); // Make webcam init.m_camera = new Camera(init); // Start camera going init.m_camera.init(); }
private void leaveFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) { log.info("Leaving full screen mode."); frame.setVisible(false); device.setFullScreenWindow(null); frame.dispose(); frame.setUndecorated(false); frame.setVisible(true); break; } } }
public FullScreenFrame(final NodeBoxDocument document) { this.document = document; setLayout(new BorderLayout(0, 0)); viewer = new Viewer(); document.addZoomListener(viewer); add(viewer, BorderLayout.CENTER); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { setUndecorated(true); gd.setFullScreenWindow(this); } else { System.err.println("Full screen not supported"); setSize(100, 100); // just something to let you see the window setVisible(true); } }
public static void main(String[] args) { if (GraphicsEnvironment.isHeadless()) { System.out.println("no screen detected"); return; } else { // <begin> IFacade facade = new asteroids.Facade(); // <end> GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); Asteroids asteroids; if (device.isFullScreenSupported()) { asteroids = new Asteroids(facade, true); device.setFullScreenWindow(asteroids); } else { asteroids = new Asteroids(facade, false); } asteroids.start(); } }
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()))); } }