/** * Enter full-screen mode, or return to windowed mode. The entered full-screen mode may be either * exclusive or simulated. Exclusive mode is only available if <code>isFullScreenSupported</code> * returns <code>true</code>. * * <p>Exclusive mode implies: * * <ul> * <li>Windows cannot overlap the full-screen window. All other application windows will always * appear beneath the full-screen window in the Z-order. * <li>There can be only one full-screen window on a device at any time, so calling this method * while there is an existing full-screen Window will cause the existing full-screen window * to return to windowed mode. * <li>Input method windows are disabled. It is advisable to call <code> * Component.enableInputMethods(false)</code> to make a component a non-client of the input * method framework. * </ul> * * <p>Simulated full-screen mode resizes the window to the size of the screen and positions it at * (0,0). * * <p>When entering full-screen mode, if the window to be used as a full-screen window is not * visible, this method will make it visible. It will remain visible when returning to windowed * mode. * * <p>When entering full-screen mode, all the translucency effects are reset for the window. Its * shape is set to {@code null}, the opacity value is set to 1.0f, and the background color alpha * is set to 255 (completely opaque). These values are not restored when returning to windowed * mode. * * <p>When returning to windowed mode from an exclusive full-screen window, any display changes * made by calling {@code setDisplayMode} are automatically restored to their original state. * * @param w a window to use as the full-screen window; {@code null} if returning to windowed mode. * Some platforms expect the fullscreen window to be a top-level component (i.e., a {@code * Frame}); therefore it is preferable to use a {@code Frame} here rather than a {@code * Window}. * @see #isFullScreenSupported * @see #getFullScreenWindow * @see #setDisplayMode * @see Component#enableInputMethods * @see Component#setVisible * @since 1.4 */ public void setFullScreenWindow(Window w) { if (w != null) { if (w.getShape() != null) { w.setShape(null); } if (w.getOpacity() < 1.0f) { w.setOpacity(1.0f); } if (!w.isOpaque()) { Color bgColor = w.getBackground(); bgColor = new Color(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), 255); w.setBackground(bgColor); } } if (fullScreenWindow != null && windowedModeBounds != null) { // if the window went into fs mode before it was realized it may // have (0,0) dimensions if (windowedModeBounds.width == 0) windowedModeBounds.width = 1; if (windowedModeBounds.height == 0) windowedModeBounds.height = 1; fullScreenWindow.setBounds(windowedModeBounds); } // Set the full screen window synchronized (fsAppContextLock) { // Associate fullscreen window with current AppContext if (w == null) { fullScreenAppContext = null; } else { fullScreenAppContext = AppContext.getAppContext(); } fullScreenWindow = w; } if (fullScreenWindow != null) { windowedModeBounds = fullScreenWindow.getBounds(); // Note that we use the graphics configuration of the device, // not the window's, because we're setting the fs window for // this device. Rectangle screenBounds = getDefaultConfiguration().getBounds(); fullScreenWindow.setBounds( screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height); fullScreenWindow.setVisible(true); fullScreenWindow.toFront(); } }
public void start() { Toolkit.getDefaultToolkit() .addAWTEventListener( new AWTEventListener() { public void eventDispatched(AWTEvent e) { System.out.println(e.toString()); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK); frame = new Frame("Frame"); frame.setName("Frame-owner"); frame.setBounds(100, 0, 100, 100); dialog = new Dialog(frame, "Dialog"); dialog.setName("Dialog-owner"); dialog.setBounds(100, 0, 100, 100); window1 = new Window(frame); window1.setName("1st child"); window1.setBounds(100, 300, 100, 100); window2 = new Window(window1); window2.setName("2nd child"); window2.setBounds(100, 500, 100, 100); test1(frame, window1); test2(frame, window1, window2); test3(frame, window1, window2); window1 = new Window(dialog); window1.setBounds(100, 300, 100, 100); window1.setName("1st child"); window2 = new Window(window1); window2.setName("2nd child"); window2.setBounds(100, 500, 100, 100); test1(dialog, window1); test2(dialog, window1, window2); test3(dialog, window1, window2); System.out.println("Test passed."); }
/* This could live in the desktop script. However we'd like to get it on the screen as quickly as possible. */ public static void startSplashScreen() { int width = 275, height = 148; Window win = new Window(new Frame()); win.pack(); BshCanvas can = new BshCanvas(); can.setSize(width, height); // why is this necessary? Toolkit tk = Toolkit.getDefaultToolkit(); Dimension dim = tk.getScreenSize(); win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height); win.add("Center", can); Image img = tk.getImage(Interpreter.class.getResource("/bsh/util/lib/splash.gif")); MediaTracker mt = new MediaTracker(can); mt.addImage(img, 0); try { mt.waitForAll(); } catch (Exception e) { } Graphics gr = can.getBufferedGraphics(); gr.drawImage(img, 0, 0, can); win.setVisible(true); win.toFront(); splashScreen = win; }
public void mouseDragged(MouseEvent ev) { Window w = (Window) ev.getSource(); Point pt = ev.getPoint(); if (isMovingWindow) { Point windowPt; try { windowPt = (Point) AccessController.doPrivileged(getLocationAction); windowPt.x = windowPt.x - dragOffsetX; windowPt.y = windowPt.y - dragOffsetY; w.setLocation(windowPt); } catch (PrivilegedActionException e) { } } else if (dragCursor != 0) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (dragCursor) { case Cursor.E_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: adjust( r, min, 0, pt.y - dragOffsetY, pt.x + (dragWidth - dragOffsetX) - r.width, -(pt.y - dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: adjust( r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: adjust( r, min, pt.x - dragOffsetX, pt.y - dragOffsetY, -(pt.x - dragOffsetX), -(pt.y - dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: adjust( r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), pt.y + (dragHeight - dragOffsetY) - r.height); break; default: break; } if (!r.equals(startBounds)) { w.setBounds(r); // Defer repaint/validate on mouseReleased unless dynamic // layout is active. if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); getRootPane().repaint(); } } } }