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움직임 }
/** Restores the screen's display mode. */ public void restoreScreen() { Window window = device.getFullScreenWindow(); if (window != null) { window.dispose(); } device.setFullScreenWindow(null); }
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; } }
/** * 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); }
private static GraphicsDevice getScreen(JFrame window) { for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { if (gd.getDefaultConfiguration().getBounds().contains(window.getLocationOnScreen())) return gd; } System.err.println( window + " does not appear to be on any screen; fullscreening onto default screen"); return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); }
/** 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 } } }
@Override public Rectangle getScreenBounds(@NotNull Project project) { final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); final Point onScreen = getFrame(project).getLocationOnScreen(); final GraphicsDevice[] devices = environment.getScreenDevices(); for (final GraphicsDevice device : devices) { final Rectangle bounds = device.getDefaultConfiguration().getBounds(); if (bounds.contains(onScreen)) { return bounds; } } return null; }
public CapabilitiesTest(GraphicsDevice dev) { super(dev.getDefaultConfiguration()); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); initComponents(getContentPane()); GraphicsConfiguration[] gcs = dev.getConfigurations(); for (int i = 0; i < gcs.length; i++) { gcSelection.addItem(new GCWrapper(gcs[i], i)); } gcSelection.addItemListener(this); gcChanged(); }
public GraphicsDevice getGraphicsDeviceAt(Point pos) { GraphicsDevice device = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice lstGDs[] = ge.getScreenDevices(); ArrayList<GraphicsDevice> lstDevices = new ArrayList<>(lstGDs.length); for (GraphicsDevice gd : lstGDs) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle screenBounds = gc.getBounds(); if (screenBounds.contains(pos)) { lstDevices.add(gd); } } if (lstDevices.size() == 1) { device = lstDevices.get(0); } return device; }
/** Returns true if the GraphicsDevice has been changed, false otherwise. */ public boolean updateGraphicsDevice() { GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice(); synchronized (getStateLock()) { if (graphicsDevice == newGraphicsDevice) { return false; } graphicsDevice = newGraphicsDevice; } final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); if (!setGraphicsConfig(newGC)) return false; SunToolkit.executeOnEventHandlerThread( getTarget(), new Runnable() { public void run() { AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC); } }); return true; }
public static void toFullScreen( JFrame window, GraphicsDevice gd, boolean tryAppleFullscreen, boolean tryExclusiveFullscreen) { if (appleEawtAvailable() && tryAppleFullscreen && appleOSVersion() >= 7 && // lion and above javaVersion() >= 7) { // java 7 and above System.out.println("trying to apple fullscreen"); enableAppleFullscreen(window); doAppleFullscreen(window); } else if (appleEawtAvailable() && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL tryExclusiveFullscreen && gd.isFullScreenSupported()) { if (javaVersion() >= 7) setAutoRequestFocus(window, true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setUndecorated(true); // window.setExtendedState(JFrame.MAXIMIZED_BOTH); gd.setFullScreenWindow(window); window.toFront(); Rectangle r = gd.getDefaultConfiguration().getBounds(); window.setBounds(r); // window.pack(); } else { // Windows and Linux TODO: test this window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setUndecorated(true); window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight()); window.setLocation(0, 0); window.setExtendedState(JFrame.MAXIMIZED_BOTH); window.toFront(); } window.pack(); window.setVisible(true); }
BufferedImage createImageFromComponent(Component comp) { BufferedImage retImage = null; if (comp == null) return retImage; try { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = genv.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); java.awt.image.ColorModel cm = gc.getColorModel(); boolean hasAlpha = cm.hasAlpha(); int cw = comp.getSize().width; int ch = comp.getSize().height; if (hasAlpha) { retImage = gc.createCompatibleImage(cw, ch); } else { retImage = new BufferedImage(cw, ch, BufferedImage.TYPE_INT_ARGB); } if (retImage == null) return retImage; Graphics og = retImage.getGraphics(); comp.paint(og); og.dispose(); } catch (Throwable t) { } return retImage; }
public void setFullScreen(IdeFrameImpl frame, boolean fullScreen) { if (!isFullScreenSupportedInCurrentOS() || frame.isInFullScreen() == fullScreen) return; try { if (SystemInfo.isMacOSLion) { frame.getFrameDecorator().toggleFullScreen(fullScreen); return; } if (SystemInfo.isWindows) { GraphicsDevice device = ScreenUtil.getScreenDevice(frame.getBounds()); if (device == null) return; try { frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, Boolean.TRUE); if (fullScreen) { frame.getRootPane().putClientProperty("oldBounds", frame.getBounds()); } frame.dispose(); frame.setUndecorated(fullScreen); } finally { if (fullScreen) { frame.setBounds(device.getDefaultConfiguration().getBounds()); } else { Object o = frame.getRootPane().getClientProperty("oldBounds"); if (o instanceof Rectangle) { frame.setBounds((Rectangle) o); } } frame.setVisible(true); frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, null); } } } finally { frame.storeFullScreenStateIfNeeded(fullScreen); } }
public Rectangle getScreenViewableBounds(GraphicsDevice gd) { Rectangle bounds = new Rectangle(0, 0, 0, 0); if (gd != null) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); bounds = gc.getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom); } return bounds; }
@Override public void start() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); gd = ge.getDefaultScreenDevice(); if (!gd.isFullScreenSupported()) { onError("Full-screen exclusive mode not supported"); System.exit(0); } // switch on FSEM // gd.setFullScreenWindow(window); window.setVisible(true); renderThread.start(); updateThread.start(); inputThread.start(); }
@Override public final synchronized void render() { final Graphics graphics = buffer.getDrawGraphics(); if (smoothScale) { ((Graphics2D) graphics) .setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); } if (inFullScreen) { graphics.setColor(Color.BLACK); DisplayMode dm = gd.getDisplayMode(); int scrnheight = dm.getHeight(); int scrnwidth = dm.getWidth(); // don't ask why this needs to be done every frame, // but it does b/c the canvas keeps resizing itself canvas.setSize(scrnwidth, scrnheight); graphics.fillRect(0, 0, scrnwidth, scrnheight); if (PrefsSingleton.get().getBoolean("maintainAspect", true)) { double scalefactor = getmaxscale(scrnwidth, scrnheight); int height = (int) (NES_HEIGHT * scalefactor); int width = (int) (256 * scalefactor * 1.1666667); graphics.drawImage( frame, ((scrnwidth / 2) - (width / 2)), ((scrnheight / 2) - (height / 2)), width, height, null); } else { graphics.drawImage(frame, 0, 0, scrnwidth, scrnheight, null); } graphics.setColor(Color.DARK_GRAY); graphics.drawString(this.getTitle(), 16, 16); } else { graphics.drawImage( frame, 0, 0, NES_WIDTH * screenScaleFactor, NES_HEIGHT * screenScaleFactor, null); } graphics.dispose(); buffer.show(); }
/** * invoked by reflection * * @param dataManager * @param applicationInfoEx * @param actionManager * @param uiSettings */ public WindowManagerImpl( DataManager dataManager, ApplicationInfoEx applicationInfoEx, ActionManagerEx actionManager, UISettings uiSettings, MessageBus bus) { myApplicationInfoEx = applicationInfoEx; myDataManager = dataManager; myActionManager = actionManager; myUiSettings = uiSettings; if (myDataManager instanceof DataManagerImpl) { ((DataManagerImpl) myDataManager).setWindowManager(this); } final Application application = ApplicationManager.getApplication(); if (!application.isUnitTestMode()) { Disposer.register( application, new Disposable() { @Override public void dispose() { disposeRootFrame(); } }); } myCommandProcessor = new CommandProcessor(); myWindowWatcher = new WindowWatcher(); final KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); keyboardFocusManager.addPropertyChangeListener(FOCUSED_WINDOW_PROPERTY_NAME, myWindowWatcher); if (Patches.SUN_BUG_ID_4218084) { keyboardFocusManager.addPropertyChangeListener( FOCUSED_WINDOW_PROPERTY_NAME, new SUN_BUG_ID_4218084_Patch()); } myLayout = new DesktopLayout(); myProject2Frame = new HashMap<Project, IdeFrameImpl>(); myDialogsToDispose = new HashMap<Project, Set<JDialog>>(); myFrameExtendedState = Frame.NORMAL; // Calculate screen bounds. Rectangle screenBounds = new Rectangle(); if (!application.isHeadlessEnvironment()) { final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = env.getScreenDevices(); for (final GraphicsDevice device : devices) { screenBounds = screenBounds.union(device.getDefaultConfiguration().getBounds()); } } myScreenBounds = screenBounds; myActivationListener = new WindowAdapter() { public void windowActivated(WindowEvent e) { Window activeWindow = e.getWindow(); if (activeWindow instanceof IdeFrameImpl) { // must be proceedDialogDisposalQueue(((IdeFrameImpl) activeWindow).getProject()); } } }; bus.connect() .subscribe( AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appClosing() { // save fullscreen window states if (isFullScreenSupportedInCurrentOS() && GeneralSettings.getInstance().isReopenLastProject()) { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 0) { WindowManagerEx wm = WindowManagerEx.getInstanceEx(); for (Project project : openProjects) { IdeFrameImpl frame = wm.getFrame(project); if (frame != null) { frame.storeFullScreenStateIfNeeded(); } } } } } }); if (UIUtil.hasLeakingAppleListeners()) { UIUtil.addAwtListener( new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event.getID() == ContainerEvent.COMPONENT_ADDED) { if (((ContainerEvent) event).getChild() instanceof JViewport) { UIUtil.removeLeakingAppleListeners(); } } } }, AWTEvent.CONTAINER_EVENT_MASK, application); } }
/** creates the lobby. */ public ClientLobby(User u) { this.user = u; /* * Get Infos about the screen * */ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = ge.getDefaultScreenDevice(); DisplayMode disp = screen.getDisplayMode(); screenX = disp.getWidth(); screenY = disp.getHeight(); JPanel bg = createBackground(); /* * Set up lobby / inputs * */ lobbyParent = new JFrame("SwissDefcon Lobby"); lobbyParent.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); lobbyParent.setSize(iLobbyX, iLobbyY); lobbyParent.setResizable(false); lobbyParent.setLocation(screenX / 2 - iLobbyX / 2, screenY / 2 - iLobbyY / 2); lobbyParent.setContentPane(bg); s = new SelectServer(user); s.addServerSelectedListener( new ServerSelectedListener() { public void serverSelected(final ServerSelectedEvent ev) { ServerAddress server = ev.getServer(); String desiredNick = ev.getUsername(); try { Log.InformationLog( "-->Connecting to " + ev.getServer().getServerName() + "(" + server.getAddress().getHostAddress() + ") as " + ev.getUsername() + "(desired Username)"); // stop discovery s.stopSearch(); s.setVisible(false); // make Connection socket = new Clientsocket(server); // JOptionPane.showMessageDialog(lobbyParent, "Verbunden mit Server"); l = new InnerLobby(socket, user); lobbyParent.add(l); // request nick socket.sendData(Protocol.CON_NICK.str() + desiredNick); // TODO Game Listener to start game here. socket.addInfoEventListener( new InfoEventListener() { @Override public void received(final InfoEvent evt) { if (evt.getId() == -1) { Log.InformationLog("Connection to server broken, starting ServerSelect"); JOptionPane.showMessageDialog( lobbyParent, "Verbindungsunterbruch", "Connection Error", JOptionPane.ERROR_MESSAGE); // TODO remove the game if it exists. socket.disconnect(); lobbyParent.remove(l); lobbyParent.validate(); lobbyParent.repaint(); s.setVisible(true); s.startSearch(); } } }); } catch (Exception e) { // e.printStackTrace(); Log.WarningLog("-->connection broken, could not connect"); JOptionPane.showMessageDialog( lobbyParent, "Konnte nicht mit Server verbinden: ", "Connection Error", JOptionPane.ERROR_MESSAGE); if (socket != null) { socket.disconnect(); } s.setVisible(true); s.startSearch(); } } }); lobbyParent.add(s); Log.InformationLog("you can now select a server"); lobbyParent.setVisible(true); }
/** Returns the window currently used in full screen mode. */ public Window getFullScreenWindow() { return device.getFullScreenWindow(); }