Example #1
52
 /**
  * Show the given message in a dialog box or independent window, depending on whether the source
  * component is contained in a Frame or not.
  *
  * @param c The Controller that calls this method, or null if it is not called by a Controller.
  *     (The Controller, if any, will be notified when the error message is cleared.)
  * @param message The message to display.
  */
 public void setErrorMessage(Controller c, String message) {
   if (popup != null) clearErrorMessage();
   if (message == null) return;
   errorSource = c;
   errorMessage = message;
   Component parent = source;
   while (parent != null && !(parent instanceof Frame)) parent = parent.getParent();
   if (parent != null) popup = new Dialog((Frame) parent, "Error Message", true); // modal dialog
   else popup = new Frame("Error Message"); // independent window
   popup.setBackground(Color.white);
   popup.add(new MC(message), BorderLayout.CENTER);
   Panel buttonBar = new Panel();
   buttonBar.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10));
   Button OK = new Button("    OK    ");
   OK.addActionListener(this);
   buttonBar.add(OK);
   popup.add(buttonBar, BorderLayout.SOUTH);
   popup.pack();
   if (parent == null) popup.setLocation(100, 80);
   else popup.setLocation(parent.getLocation().x + 50, parent.getLocation().y + 30);
   popup.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent evt) {
           popup.dispose();
         }
       });
   popup.show(); // make the dialog visible.
 }
Example #2
0
  public LWWindowPeer(
      Window target,
      PlatformComponent platformComponent,
      PlatformWindow platformWindow,
      PeerType peerType) {
    super(target, platformComponent);
    this.platformWindow = platformWindow;
    this.peerType = peerType;

    Window owner = target.getOwner();
    LWWindowPeer ownerPeer =
        owner == null ? null : (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
    PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;

    // The delegate.initialize() needs a non-null GC on X11.
    GraphicsConfiguration gc = getTarget().getGraphicsConfiguration();
    synchronized (getStateLock()) {
      // graphicsConfig should be updated according to the real window
      // bounds when the window is shown, see 4868278
      this.graphicsConfig = gc;
    }

    if (!target.isFontSet()) {
      target.setFont(DEFAULT_FONT);
    }

    if (!target.isBackgroundSet()) {
      target.setBackground(SystemColor.window);
    } else {
      // first we check if user provided alpha for background. This is
      // similar to what Apple's Java do.
      // Since JDK7 we should rely on setOpacity() only.
      // this.opacity = c.getAlpha();
    }

    if (!target.isForegroundSet()) {
      target.setForeground(SystemColor.windowText);
      // we should not call setForeground because it will call a repaint
      // which the peer may not be ready to do yet.
    }

    platformWindow.initialize(target, this, ownerDelegate);

    // Init warning window(for applets)
    SecurityWarningWindow warn = null;
    if (target.getWarningString() != null) {
      // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
      // and TrayIcon balloon windows without a warning window.
      if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) {
        LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
        warn = toolkit.createSecurityWarning(target, this);
      }
    }

    warningWindow = warn;
  }
Example #3
0
 // set to full screen
 public void init() {
   s = new ScreenManager();
   DisplayMode dm = s.findFirstCompatibleMode(modes);
   s.setFullScreen(dm);
   Window w = s.getFullScreenWindow();
   w.setFont(new Font("Arial", Font.PLAIN, 20));
   w.setBackground(Color.GREEN);
   w.setForeground(Color.WHITE);
   running = true;
 }
 /**
  * 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();
   }
 }