Exemplo n.º 1
0
    private void showJPopupMenu(MouseEvent e) {
      try {
        if (e.isPopupTrigger() && menu != null) {
          if (window == null) {

            if (isWindows) {
              window = new JDialog((Frame) null);
              ((JDialog) window).setUndecorated(true);
            } else {
              window = new JWindow((Frame) null);
            }
            window.setAlwaysOnTop(true);
            Dimension size = menu.getPreferredSize();

            Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height);
            else window.setLocation(e.getX(), e.getY());

            window.setVisible(true);

            menu.show(((RootPaneContainer) window).getContentPane(), 0, 0);

            // popup works only for focused windows
            window.toFront();
          }
        }
      } catch (Exception ignored) {
      }
    }
Exemplo n.º 2
0
  /**
   * Uninstalls the sheet on the owner. This method is invoked immediately after the JSheet is
   * hidden.
   */
  protected void uninstallSheet() {
    if (isInstalled) {
      Window owner = getOwner();
      if (owner != null) {
        if (isExperimentalSheet()) {
          owner.removeWindowListener(windowEventHandler);
        } else {
          // Note: We mustn't change the windows focusable state
          // because
          // this also affects the focusable state of the JSheet.
          // owner.setFocusableWindowState(true);
          owner.setEnabled(true);
          // ((JFrame) owner).setResizable(true);
          owner.removeComponentListener(ownerMovementHandler);

          if (shiftBackLocation != null) {
            owner.setLocation(shiftBackLocation);
          }
          if (oldFocusOwner != null) {
            owner.toFront();
            oldFocusOwner.requestFocus();
          }
        }
      }
      isInstalled = false;
    }
  }
Exemplo n.º 3
0
  /**
   * Show the window.
   *
   * @param container - Window of JFrame to show
   */
  private void showPopup(Window container) {
    if (visibleComponent.isEnabled()) {
      Point pt = visibleComponent.getLocationOnScreen();
      pt.translate(0, visibleComponent.getHeight());
      container.setLocation(pt);
      container.toFront();

      ApplicationManager.setCurrentlySelectedField(fieldName);
      if (container instanceof OntologySelector) {
        ((OntologySelector) container).makeVisible();
      } else {
        container.setVisible(true);
        container.requestFocusInWindow();
      }
    }
  }
Exemplo n.º 4
0
 /**
  * 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();
   }
 }
Exemplo n.º 5
0
    public void mousePressed(MouseEvent ev) {
      JRootPane rootPane = getRootPane();

      if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }
      Point dragWindowOffset = ev.getPoint();
      Window w = (Window) ev.getSource();
      if (w != null) {
        w.toFront();
      }
      Point convertedDragWindowOffset =
          SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane());

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      int frameState = (f != null) ? f.getExtendedState() : 0;

      if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) {
        if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null))
            && dragWindowOffset.y >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x < w.getWidth() - BORDER_DRAG_THICKNESS) {
          isMovingWindow = true;
          dragOffsetX = dragWindowOffset.x;
          dragOffsetY = dragWindowOffset.y;
        }
      } else if (f != null && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0)
          || (d != null && d.isResizable())) {
        dragOffsetX = dragWindowOffset.x;
        dragOffsetY = dragWindowOffset.y;
        dragWidth = w.getWidth();
        dragHeight = w.getHeight();
        dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
      }
    }
Exemplo n.º 6
0
 /*
 	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;
 }
Exemplo n.º 7
0
 /** Bring the dialog to the front */
 public void toFront() {
   if (!windowOk()) {
     return;
   }
   window.toFront();
 }