public void mouseMoved(MouseEvent e) {
      if (geoDisplayPopup != null) {
        geoDisplayPopup.hide();
      }

      String pointMessage = "";

      x = e.getX();
      y = e.getY();
      double minDist = -1;
      if (geoPoints == null || geoPoints.size() == 0) {
        return;
      }
      for (GeoPoint p : geoPoints) {
        double dist = p.distance(x, y);
        if (minDist > dist || minDist < 0) {
          pointMessage = p.getMessage();
          minDist = dist;
        }
      }
      if (minDist > 2.5) {
        return;
      }
      geoPanel = GeoPolygonPanel.this;
      message.setText(pointMessage);
      PopupFactory factory = PopupFactory.getSharedInstance();
      geoDisplayPopup =
          factory.getPopup(
              owner,
              message,
              (int) geoPanel.getLocationOnScreen().getX() + x,
              (int) geoPanel.getLocationOnScreen().getY() + y - 15);
      geoDisplayPopup.show();
    }
    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();
      }
    }
 /** Perform a search when user stop to type in the search combo for 2 sec or pressed enter */
 private void search() {
   try {
     bNeedSearch = false;
     setEnabled(false); // no typing during search
     if (sTyped.length() >= MIN_CRITERIA_LENGTH) {
       // second test to get sure user didn't
       // typed before entering this method
       TreeSet<SearchResult> tsResu = TrackManager.getInstance().search(sTyped.toString());
       // Add web radio names
       tsResu.addAll(WebRadioManager.getInstance().search(sTyped.toString()));
       if (tsResu.size() > 0) {
         DefaultListModel model = new DefaultListModel();
         alResults = new ArrayList<SearchResult>();
         alResults.addAll(tsResu);
         for (SearchResult sr : tsResu) {
           model.addElement(sr);
         }
         jlist = new JList(model);
         jlist.setLayoutOrientation(JList.VERTICAL);
         jlist.setCellRenderer(new SearchListRenderer());
         PopupFactory factory = PopupFactory.getSharedInstance();
         JScrollPane jsp = new JScrollPane(jlist);
         int width = (int) ((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.7f);
         jsp.setMinimumSize(new Dimension(width, 250));
         jsp.setPreferredSize(new Dimension(width, 250));
         jsp.setMaximumSize(new Dimension(width, 250));
         jlist.setSelectionMode(0);
         jlist.addListSelectionListener(lsl);
         jsp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         if (popup != null) {
           popup.hide();
         }
         // take upper-left point relative to the
         // textfield
         Point point = new Point(0, 0);
         // take absolute coordonates in the screen (popups works
         // only on absolute coordonates in opposition to swing
         // widgets)
         SwingUtilities.convertPointToScreen(point, this);
         popup =
             factory.getPopup(
                 this, jsp, (int) point.getX() + 500 - (width), (int) point.getY() - 250);
         popup.show();
       } else {
         if (popup != null) {
           popup.hide();
         }
       }
     }
     requestFocusInWindow();
   } catch (Exception e) {
     Log.error(e);
   } finally { // make sure to enable search box in all cases
     setEnabled(true);
   }
 }
      public PopupComponent getPopup(Component owner, Component content, int x, int y) {
        final PopupFactory factory = PopupFactory.getSharedInstance();

        final int oldType = PopupUtil.getPopupType(factory);
        PopupUtil.setPopupType(factory, 2);
        final Popup popup = factory.getPopup(owner, content, x, y);
        if (oldType >= 0) PopupUtil.setPopupType(factory, oldType);

        return new AwtPopupWrapper(popup);
      }
    @Override
    public Popup getPopup(final Component owner, final Component contents, final int x, final int y)
        throws IllegalArgumentException {
      final Point point = fixPopupLocation(contents, x, y);

      final int popupType =
          UIUtil.isUnderGTKLookAndFeel() ? WEIGHT_HEAVY : PopupUtil.getPopupType(this);
      if (popupType >= 0) {
        PopupUtil.setPopupType(myDelegate, popupType);
      }

      final Popup popup = myDelegate.getPopup(owner, contents, point.x, point.y);
      fixPopupSize(popup, contents);
      return popup;
    }
 /** Perform a search when user stop to type in the search combo for 2 sec or pressed enter */
 private void search() {
   try {
     bNeedSearch = false;
     setEnabled(false); // no typing during search
     if (sTyped.length()
         >= MIN_CRITERIA_LENGTH) { // second test to get sure user didn't typed before entering
                                   // this method
       TreeSet tsResu = FileManager.getInstance().search(sTyped.toString());
       if (tsResu.size() > 0) {
         DefaultListModel model = new DefaultListModel();
         alResults = new ArrayList();
         alResults.addAll(tsResu);
         Iterator it = tsResu.iterator();
         while (it.hasNext()) {
           model.addElement(((SearchResult) it.next()).getResu());
         }
         jlist = new JList(model);
         PopupFactory factory = PopupFactory.getSharedInstance();
         JScrollPane jsp = new JScrollPane(jlist);
         jlist.setSelectionMode(0);
         jlist.addListSelectionListener(lsl);
         jsp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         if (popup != null) {
           popup.hide();
         }
         Point point = new Point(0, 0); // take upper-left point relative to the textfield
         SwingUtilities.convertPointToScreen(
             point,
             this); // take absolute coordonates in the screen ( popups works only on absolute
                    // coordonates in oposition to swing widgets)
         popup = factory.getPopup(this, jsp, (int) point.getX(), (int) point.getY() + 25);
         popup.show();
       } else {
         if (popup != null) {
           popup.hide();
         }
       }
     }
     requestFocusInWindow();
   } catch (Exception e) {
     Log.error(e);
   } finally { // make sure to enable search box in all cases
     setEnabled(true);
   }
 }
 public void actionPerformed(ActionEvent e) {
   PopupFactory popupFactory = PopupFactory.getSharedInstance();
   JToolTip tip = new JToolTip();
   tip.setTipText(TextUtils.getText("docear.monitoring.reload.name"));
   final Point locationOnScreen = comp.getLocationOnScreen();
   final int height = comp.getHeight();
   Rectangle sBounds = comp.getGraphicsConfiguration().getBounds();
   final int minX = sBounds.x;
   final int maxX = sBounds.x + sBounds.width;
   final int minY = sBounds.y;
   final int maxY = sBounds.y + sBounds.height;
   int x = locationOnScreen.x;
   int y = locationOnScreen.y + height;
   final Dimension tipSize = tip.getPreferredSize();
   final int tipWidth = tipSize.width;
   if (x + tipWidth > maxX) {
     x = maxX - tipWidth;
   }
   if (x < minX) {
     x = minX;
   }
   final int tipHeight = tipSize.height;
   if (y + tipHeight > maxY) {
     if (locationOnScreen.y - tipHeight > minY) {
       y = locationOnScreen.y - tipHeight;
     } else {
       y = maxY - tipHeight;
     }
   }
   if (y < minY) {
     y = minY;
   }
   final Popup tipPopup = popupFactory.getPopup(comp, tip, x, y);
   tipPopup.show();
   showTimer.removeActionListener(this);
   hideTimer.addActionListener(new HideToolTipAction(tipPopup, tip, comp));
   hideTimer.start();
 }
  private void showPopup(Set<AppearancePort> portObjects) {
    dragStart = null;
    CircuitState circuitState = canvas.getCircuitState();
    if (circuitState == null) return;
    ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
    for (AppearancePort portObject : portObjects) {
      ports.add(portObject.getPin());
    }

    hideCurrentPopup();
    LayoutThumbnail layout = new LayoutThumbnail();
    layout.setCircuit(circuitState, ports);
    JViewport owner = canvasPane.getViewport();
    Point ownerLoc = owner.getLocationOnScreen();
    Dimension ownerDim = owner.getSize();
    Dimension layoutDim = layout.getPreferredSize();
    int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
    int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
    PopupFactory factory = PopupFactory.getSharedInstance();
    Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
    popup.show();
    curPopup = popup;
    curPopupTime = System.currentTimeMillis();
  }