Ejemplo n.º 1
0
  /**
   * Returns a <code>Popup</code> instance from the <code>PopupMenuUI</code> that has had <code>show
   * </code> invoked on it. If the current <code>popup</code> is non-null, this will invoke <code>
   * dispose</code> of it, and then <code>show</code> the new one.
   *
   * <p>This does NOT fire any events, it is up the caller to dispatch the necessary events.
   */
  private Popup getPopup() {
    Popup oldPopup = popup;

    if (oldPopup != null) {
      oldPopup.hide();
    }
    PopupFactory popupFactory = PopupFactory.getSharedInstance();

    if (isLightWeightPopupEnabled()) {
      popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    } else {
      popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
    }

    // adjust the location of the popup
    Point p = adjustPopupLocationToFitScreen(desiredLocationX, desiredLocationY);
    desiredLocationX = p.x;
    desiredLocationY = p.y;

    Popup newPopup = getUI().getPopup(this, desiredLocationX, desiredLocationY);

    popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    newPopup.show();
    return newPopup;
  }
Ejemplo n.º 2
0
 public static void hidePopups(Component comp) {
   if (comp != null) {
     label0:
     for (Component c = comp; c != null; c = c.getParent()) {
       if (!(c instanceof ZPopupGallery)) continue;
       do {
         if (currShownList.size() <= 0) continue label0;
         if (currShownList.getLast() == c) return;
         ZPopupGallery jpg = (ZPopupGallery) currShownList.removeLast();
         Popup popup = (Popup) popupGalleryHM.get(jpg);
         popup.hide();
         popupGalleryHM.remove(jpg);
       } while (true);
     }
   }
   Iterator iterator = popupGalleryHM.keySet().iterator();
   do {
     if (!iterator.hasNext()) break;
     ZPopupGallery gallery = (ZPopupGallery) iterator.next();
     ((Popup) popupGalleryHM.get(gallery)).hide();
     if (gallery.getActionListener() != null)
       gallery.getActionListener().actionPerformed(new ActionEvent(gallery, 1, "Hidden"));
   } while (true);
   popupGalleryHM.clear();
 }
Ejemplo n.º 3
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
Ejemplo n.º 4
0
 protected void showInfoPopup(String info, int x, int y) {
   JPanel content = new JPanel();
   content.add(new JLabel(info));
   content.setBorder(BorderFactory.createLineBorder(Color.BLACK));
   Point location = getLocationOnScreen();
   location.x += x + 5;
   location.y += y + 5;
   popup = PopupFactory.getSharedInstance().getPopup(this, content, location.x, location.y);
   popup.show();
 }
Ejemplo n.º 5
0
    public void hide(boolean dispose) {
      myPopup.hide();

      Window wnd = getWindow();
      if (wnd instanceof JWindow) {
        JRootPane rootPane = ((JWindow) wnd).getRootPane();
        if (rootPane != null) {
          ReflectionUtil.resetField(rootPane, "clientProperties");
        }
      }
    }
Ejemplo n.º 6
0
    void reset(Component owner, Component contents, int ownerX, int ownerY) {
      if ((owner instanceof JFrame) || (owner instanceof JDialog) || (owner instanceof JWindow)) {
        // Force the content to be added to the layered pane, otherwise
        // we'll get an exception when adding to the RootPaneContainer.
        owner = ((RootPaneContainer) owner).getLayeredPane();
      }
      super.reset(owner, contents, ownerX, ownerY);

      x = ownerX;
      y = ownerY;
      this.owner = owner;
    }
Ejemplo n.º 7
0
  /**
   * Sets the visibility of the popup menu.
   *
   * @param b true to make the popup visible, or false to hide it
   * @beaninfo bound: true description: Makes the popup visible
   */
  public void setVisible(boolean b) {
    if (DEBUG) {
      System.out.println("JPopupMenu.setVisible " + b);
    }

    // Is it a no-op?
    if (b == isVisible()) return;

    // if closing, first close all Submenus
    if (b == false) {

      // 4234793: This is a workaround because JPopupMenu.firePopupMenuCanceled is
      // a protected method and cannot be called from BasicPopupMenuUI directly
      // The real solution could be to make
      // firePopupMenuCanceled public and call it directly.
      Boolean doCanceled = (Boolean) getClientProperty("JPopupMenu.firePopupMenuCanceled");
      if (doCanceled != null && doCanceled == Boolean.TRUE) {
        putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.FALSE);
        firePopupMenuCanceled();
      }
      getSelectionModel().clearSelection();

    } else {
      // This is a popup menu with MenuElement children,
      // set selection path before popping up!
      if (isPopupMenu()) {
        MenuElement me[] = new MenuElement[1];
        me[0] = this;
        MenuSelectionManager.defaultManager().setSelectedPath(me);
      }
    }

    if (b) {
      firePopupMenuWillBecomeVisible();
      popup = getPopup();
      firePropertyChange("visible", Boolean.FALSE, Boolean.TRUE);

    } else if (popup != null) {
      firePopupMenuWillBecomeInvisible();
      popup.hide();
      popup = null;
      firePropertyChange("visible", Boolean.TRUE, Boolean.FALSE);
      // 4694797: When popup menu is made invisible, selected path
      // should be cleared
      if (isPopupMenu()) {
        MenuSelectionManager.defaultManager().clearSelectedPath();
      }
    }
  }
Ejemplo n.º 8
0
    private static void fixPopupSize(final Popup popup, final Component contents) {
      if (!UIUtil.isUnderGTKLookAndFeel() || !(contents instanceof JPopupMenu)) return;

      for (Class<?> aClass = popup.getClass();
          aClass != null && Popup.class.isAssignableFrom(aClass);
          aClass = aClass.getSuperclass()) {
        try {
          final Method getComponent = aClass.getDeclaredMethod("getComponent");
          getComponent.setAccessible(true);
          final Object component = getComponent.invoke(popup);
          if (component instanceof JWindow) {
            ((JWindow) component).setSize(new Dimension(0, 0));
          }
          break;
        } catch (Exception ignored) {
        }
      }
    }
Ejemplo n.º 9
0
 public void show() {
   myPopup.show();
 }
Ejemplo n.º 10
0
 public void mouseReleased(MouseEvent e) {
   if (e.isPopupTrigger()) {
     Popup popup = new Popup();
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Ejemplo n.º 11
0
 public void mouseReleased(MouseEvent e) {
   if (e.getButton() == e.BUTTON3) {
     popup.hide();
   }
 }
Ejemplo n.º 12
0
 public void hideInfo() {
   if (popup != null) popup.hide();
 }
Ejemplo n.º 13
0
 void _dispose() {
   super.dispose();
 }
Ejemplo n.º 14
0
 //
 // Popup methods
 //
 public void hide() {
   super.hide();
   recycleHeavyWeightPopup(this);
 }