/**
     * This method is called when the mouse is pressed in the JToolBar. If the press doesn't occur
     * in a place where it causes the JToolBar to be dragged, it returns. Otherwise, it starts a
     * drag session.
     *
     * @param e The MouseEvent.
     */
    public void mousePressed(MouseEvent e) {
      if (!toolBar.isFloatable()) return;

      Point ssd = e.getPoint();
      Insets insets = toolBar.getInsets();

      // Verify that this click occurs in the top inset.
      if (toolBar.getOrientation() == SwingConstants.HORIZONTAL) {
        if (e.getX() > insets.left) return;
      } else {
        if (e.getY() > insets.top) return;
      }

      origin = new Point(0, 0);
      if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(ssd, toolBar);

      if (!(SwingUtilities.getAncestorOfClass(Window.class, toolBar) instanceof UIResource))
        // Need to know who keeps the toolBar if it gets dragged back into it.
        origParent = toolBar.getParent();

      if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(origin, toolBar);

      isDragging = true;

      if (dragWindow != null)
        dragWindow.setOffset(new Point(cachedBounds.width / 2, cachedBounds.height / 2));

      dragTo(e.getPoint(), origin);
    }
    public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
      Point cpos = combo1.getLocation();
      SwingUtilities.convertPointToScreen(cpos, panel);

      JPopupMenu pm = (JPopupMenu) combo1.getUI().getAccessibleChild(combo1, 0);

      if (pm != null) {
        Point p = pm.getLocation();
        SwingUtilities.convertPointToScreen(p, pm);
        if (p.y < cpos.y) {
          throw new RuntimeException("ComboBox popup is wrongly aligned");
        } // check that popup was opened down
      }
    }
  private boolean dispatchMouseEvent(AWTEvent event) {
    if (event.getID() != MouseEvent.MOUSE_PRESSED) {
      return false;
    }

    if (ourShowingStep == null) {
      return false;
    }

    WizardPopup eachParent = ourShowingStep;
    final MouseEvent mouseEvent = ((MouseEvent) event);

    Point point = (Point) mouseEvent.getPoint().clone();
    SwingUtilities.convertPointToScreen(point, mouseEvent.getComponent());

    while (true) {
      JComponent content = eachParent.getContent();
      if (content == null || !content.isShowing()) {
        getActiveRoot().cancel();
        return false;
      }

      if (eachParent.getBounds().contains(point) || !eachParent.canClose()) {
        return false;
      }

      eachParent = eachParent.getParent();
      if (eachParent == null) {
        getActiveRoot().cancel();
        return false;
      }
    }
  }
  /**
   * A chat room was selected. Opens the chat room in the chat window.
   *
   * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just
   *     occurred.
   */
  public void mousePressed(MouseEvent e) {
    // Select the object under the right button click.
    if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
        || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
        || (e.isControlDown() && !e.isMetaDown())) {
      int ix = this.chatRoomList.rowAtPoint(e.getPoint());

      if (ix != -1) {
        this.chatRoomList.setRowSelectionInterval(ix, ix);
      }
    }

    Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    Point selectedCellPoint = e.getPoint();

    SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList);

    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
      JPopupMenu rightButtonMenu;

      if (o instanceof ChatRoomWrapper)
        rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o);
      else return;

      rightButtonMenu.setInvoker(this);
      rightButtonMenu.setLocation(selectedCellPoint);
      rightButtonMenu.setVisible(true);
    }
  }
  public static void showPopupMenu(
      final JPopupMenu popup, final Component component, int x, int y) {
    final Point p = new Point(x, y);
    SwingUtilities.convertPointToScreen(p, component);
    final Dimension size = popup.getPreferredSize();
    final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

    boolean horiz = false;
    boolean vert = false;

    final int origX = x;

    if ((p.x + size.width > screen.width) && (size.width < screen.width)) {
      x += (screen.width - p.x - size.width);
      horiz = true;
    }

    if ((p.y + size.height > screen.height) && (size.height < screen.height)) {
      y += (screen.height - p.y - size.height);
      vert = true;
    }

    if (horiz && vert) {
      x = origX - size.width - 2;
    }
    popup.show(component, x, y);
  }
示例#6
0
  public TabSpawnable spawn() {
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.setTitle(_title);
    TabSpawnable newPanel = (TabSpawnable) clone();
    if (newPanel == null) return null; // failed to clone
    newPanel.setTitle(_title);
    if (newPanel instanceof TabToDoTarget) {
      TabToDoTarget me = (TabToDoTarget) this;
      TabToDoTarget it = (TabToDoTarget) newPanel;
      it.setTarget(me.getTarget());
    } else if (newPanel instanceof TabModelTarget) {
      TabModelTarget me = (TabModelTarget) this;
      TabModelTarget it = (TabModelTarget) newPanel;
      it.setTarget(me.getTarget());
    }
    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this);

    return newPanel;
  }
  @Override
  public void mousePressed(MouseEvent e) {
    //	The mouseMoved event continually updates this variable

    if (direction == 0) return;

    //  Setup for resizing. All future dragging calculations are done based
    //  on the original bounds of the component and mouse pressed location.

    resizing = true;

    Component source = e.getComponent();
    pressed = e.getPoint();
    SwingUtilities.convertPointToScreen(pressed, source);
    bounds = source.getBounds();

    //  Making sure autoscrolls is false will allow for smoother resizing
    //  of components

    if (source instanceof JComponent) {
      JComponent jc = (JComponent) source;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
    public void mousePressed(MouseEvent e) {
      dragType = 0;
      Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), getContentPane());
      /*if (p.y < 10){
        dragType |= DRAG_TOP;
      }
      if (p.x < 5){
        dragType |= DRAG_LEFT;
      }
      if (p.x > getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y > getHeight() - 5){
        dragType |= DRAG_BOTTOM;
      }*/
      if (p.y < title.getY() + title.getHeight()) {
        dragType |= DRAG_TOP;
      }
      if (p.x < left.getX() + left.getWidth()) {
        dragType |= DRAG_LEFT;
      }
      if (p.x >= right.getX()) { // getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y >= bottom.getY()) {
        dragType |= DRAG_BOTTOM;
      }

      lastPoint = e.getPoint();
      SwingUtilities.convertPointToScreen(lastPoint, e.getComponent());
    }
    public void mouseDragged(final MouseEvent evt) {
      Point mousePoint = evt.getPoint();
      if (resizing == 0 && MOVE != 0) {
        int x = getX() + mousePoint.x - mousePointer.x;
        int y = getY() + mousePoint.y - mousePointer.y;
        setLocation(x, y);
        repaint();
        return;
      }
      Rectangle bounds = getBounds(tempBounds);

      SwingUtilities.convertPointToScreen(mousePoint, ResizableWindow.this);
      if ((resizing & RESIZE_E) != 0) {
        bounds.width = evt.getX();
      } else if ((resizing & RESIZE_W) != 0) {
        bounds.width += bounds.x - mousePoint.x;
        bounds.x = mousePoint.x;
      }
      if ((resizing & RESIZE_S) != 0) {
        bounds.height = evt.getY();
      } else if ((resizing & RESIZE_N) != 0) {
        bounds.height += bounds.y - mousePoint.y;
        bounds.y = mousePoint.y;
      }

      if (bounds.getSize().height >= getMinimumSize().height
          && bounds.getSize().width >= getMinimumSize().width) {
        setBounds(bounds);
        validate();
        repaint();
      }

      Graphics graphics = getGraphics();
      paint(graphics);
    }
  /**
   * @param editor
   * @param idDialog
   * @param dialog
   * @param title
   */
  public static void setDialogVisible(
      @Nullable Editor editor, String idDialog, JDialog dialog, String title) {
    Point location = null;

    if (editor != null) {
      Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
      SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent());

      String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x");
      if (!(position[0].equals("0") && position[1].equals("0"))) {
        location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1]));
      }
    }

    if (location == null) {
      // Center to screen
      dialog.setLocationRelativeTo(null);
    } else {
      dialog.setLocation(location.x, location.y);
    }

    dialog.setTitle(title);
    dialog.pack();
    dialog.setVisible(true);
  }
示例#11
0
  private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
示例#12
0
 public void mouseDragged(MouseEvent e) {
   Point newPos = e.getPoint();
   SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
   int xDelta = newPos.x - origPos.x;
   int yDelta = newPos.y - origPos.y;
   Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
   if (wind != null) { // Should always be true
     if (getComponentOrientation().isLeftToRight()) {
       int w = wind.getWidth();
       if (newPos.x >= wind.getX()) {
         w += xDelta;
       }
       int h = wind.getHeight();
       if (newPos.y >= wind.getY()) {
         h += yDelta;
       }
       wind.setSize(w, h);
     } else { // RTL
       int newW = Math.max(1, wind.getWidth() - xDelta);
       int newH = Math.max(1, wind.getHeight() + yDelta);
       wind.setBounds(newPos.x, wind.getY(), newW, newH);
     }
     // invalidate()/validate() needed pre-1.6.
     wind.invalidate();
     wind.validate();
   }
   origPos.setLocation(newPos);
 }
  private boolean handleNextStep(final PopupStep nextStep, Object parentValue, InputEvent e) {
    if (nextStep != PopupStep.FINAL_CHOICE) {
      final Point point = myList.indexToLocation(myList.getSelectedIndex());
      SwingUtilities.convertPointToScreen(point, myList);
      myChild = createPopup(this, nextStep, parentValue);
      if (myChild instanceof ListPopupImpl) {
        for (ListSelectionListener listener : myList.getListSelectionListeners()) {
          ((ListPopupImpl) myChild).addListSelectionListener(listener);
        }
      }
      final JComponent container = getContent();
      assert container != null : "container == null";

      int y = point.y;
      if (parentValue != null && getListModel().isSeparatorAboveOf(parentValue)) {
        SeparatorWithText swt = new SeparatorWithText();
        swt.setCaption(getListModel().getCaptionAboveOf(parentValue));
        y += swt.getPreferredSize().height - 1;
      }

      myChild.show(container, point.x + container.getWidth() - STEP_X_PADDING, y, true);
      setIndexForShowingChild(myList.getSelectedIndex());
      return false;
    } else {
      setOk(true);
      setFinalRunnable(myStep.getFinalRunnable());
      disposeAllParents(e);
      setIndexForShowingChild(-1);
      return true;
    }
  }
  @Override
  public void mouseMoved(MouseEvent e) {
    final MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, getParent());
    final boolean insideRec = getBounds().contains(event.getPoint());
    boolean buttonsNotPressed =
        (e.getModifiersEx()
                & (InputEvent.BUTTON1_DOWN_MASK
                    | InputEvent.BUTTON2_DOWN_MASK
                    | InputEvent.BUTTON3_DOWN_MASK))
            == 0;
    if (!myPopupIsShowing && insideRec && buttonsNotPressed) {
      showPopup(null, false);
    } else if (myPopupIsShowing && !insideRec) {
      final Component over =
          SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
      JPopupMenu popup = myUnderPopup.isShowing() ? myUnderPopup : myAbovePopup;
      if (over != null && popup.isShowing()) {
        final Rectangle rec = new Rectangle(popup.getLocationOnScreen(), popup.getSize());
        int delta = 15;
        rec.x -= delta;
        rec.width += delta * 2;
        rec.y -= delta;
        rec.height += delta * 2;

        final Point eventPoint = e.getPoint();
        SwingUtilities.convertPointToScreen(eventPoint, e.getComponent());

        if (rec.contains(eventPoint)) {
          return;
        }
      }

      closePopup();
    }
  }
 private void disposeAndUpdate(boolean update) {
   if (myView != null) {
     boolean visible = myView.isVisible();
     myView.setVisible(false);
     Container container = myContent.getParent();
     if (container != null) {
       container.remove(myContent);
     }
     if (myView instanceof Window) {
       myViewBounds = myView.getBounds();
       Window window = (Window) myView;
       if (!push(UIUtil.getWindow(myOwner), window)) {
         window.dispose();
       }
     } else {
       Container parent = myView.getParent();
       if (parent == null) {
         myViewBounds = new Rectangle(myContent.getPreferredSize());
       } else {
         myViewBounds = new Rectangle(myView.getBounds());
         parent.remove(myView);
         Point point = new Point(myViewBounds.x, myViewBounds.y);
         SwingUtilities.convertPointToScreen(point, parent);
         myViewBounds.x = point.x;
         myViewBounds.y = point.y;
       }
     }
     myView = null;
     if (update && visible) {
       setVisible(true);
     }
   }
 }
    private boolean withinPopup(final AWTEvent event) {
      if (!myContent.isShowing()) return false;

      final MouseEvent mouse = (MouseEvent) event;
      final Point point = mouse.getPoint();
      SwingUtilities.convertPointToScreen(point, mouse.getComponent());
      return new Rectangle(myContent.getLocationOnScreen(), myContent.getSize()).contains(point);
    }
示例#17
0
 public void mouseDragged(MouseEvent e) {
   if (enabled) {
     Point loc = e.getPoint();
     SwingUtilities.convertPointToScreen(loc, (Component) e.getSource());
     SwingUtility.subtract(loc, dragOffset);
     frame.setLocation(loc);
   }
 }
  @Override
  protected final void actionPerformed(PhpModule phpModule) {
    // called via shortcut
    if (!CakePhpUtils.isCakePHP(phpModule)) {
      return;
    }

    JTextComponent editor = EditorRegistry.lastFocusedComponent();
    if (editor == null) {
      return;
    }

    Document document = editor.getDocument();
    if (document == null) {
      return;
    }

    FileObject fileObject = NbEditorUtilities.getFileObject(document);
    if (fileObject == null) {
      return;
    }
    // get go to files
    CakePhpGoToStatusFactory factory = CakePhpGoToStatusFactory.getInstance();
    CakePhpGoToStatus status = factory.create(fileObject, editor.getCaretPosition());
    final List<GoToItem> items = getGoToItems(status);
    if (items == null || items.isEmpty()) {
      return;
    }

    // if there are multiple items, show popup list
    if (items.size() == 1 && !CakePreferences.isShowPopupForOneItem(phpModule)) {
      for (GoToItem item : items) {
        UiUtils.open(item.getFileObject(), item.getOffset());
        return;
      }
    }

    // show popup
    try {
      Rectangle rectangle = editor.modelToView(editor.getCaretPosition());
      final Point point = new Point(rectangle.x, rectangle.y + rectangle.height);
      SwingUtilities.convertPointToScreen(point, editor);
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              String title = getPopupTitle();
              if (title == null) {
                title = ""; // NOI18N
              }
              PopupUtil.showPopup(new GoToPopup(title, items), title, point.x, point.y, true, 0);
            }
          });
    } catch (BadLocationException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
示例#19
0
 /*
  *  Create a BufferedImage for AWT components.
  *
  *  @param	 component AWT component to create image from
  *  @param	 fileName name of file to be created or null
  *  @return	image the image for the given region
  *  @exception AWTException see Robot class constructors
  *  @exception IOException if an error occurs during writing
  */
 public static BufferedImage createImage(Component component, String fileName)
     throws AWTException, IOException {
   Point p = new Point(0, 0);
   SwingUtilities.convertPointToScreen(p, component);
   Rectangle region = component.getBounds();
   region.x = p.x;
   region.y = p.y;
   return ScreenCapture.createImage(region, fileName);
 }
示例#20
0
 /**
  * Uses the Robot class to try to postion the mouse in the center of the screen.
  *
  * <p>Note that use of the Robot class may not be available on all platforms.
  */
 private synchronized void recenterMouse() {
   if (robot != null && comp.isShowing()) {
     centerLocation.x = comp.getWidth() / 2;
     centerLocation.y = comp.getHeight() / 2;
     SwingUtilities.convertPointToScreen(centerLocation, comp);
     isRecentering = true;
     robot.mouseMove(centerLocation.x, centerLocation.y);
   }
 }
示例#21
0
 /** 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 static Point getCenterOf(final Component aContainer, final JComponent content) {
    final JComponent component = getTargetComponent(aContainer);

    Point containerScreenPoint = component.getVisibleRect().getLocation();
    SwingUtilities.convertPointToScreen(containerScreenPoint, aContainer);

    return UIUtil.getCenterPoint(
        new Rectangle(containerScreenPoint, component.getVisibleRect().getSize()),
        content.getPreferredSize());
  }
  /** Tests if the popup is on the screen. */
  public static void isPopupOnScreen(JPopupMenu popup, Rectangle checkBounds) {
    Dimension dim = popup.getSize();
    Point pt = new Point();
    SwingUtilities.convertPointToScreen(pt, popup);
    Rectangle bounds = new Rectangle(pt, dim);

    if (!SwingUtilities.isRectangleContainingRectangle(checkBounds, bounds)) {
      throw new RuntimeException("We do not match! " + checkBounds + " / " + bounds);
    }
  }
 /**
  * Removes the painted value.
  *
  * @see MouseListener#mouseReleased(MouseEvent)
  */
 public void mouseReleased(MouseEvent e) {
   canvas.setCursor(Cursor.getDefaultCursor());
   Point p = e.getPoint();
   if ((handleKeyDown && e.isAltDown()) || model.isBigImage()) {
     pan(p, true);
   }
   pressedPoint = DEFAULT_POINT;
   SwingUtilities.convertPointToScreen(pressedPoint, canvas);
   if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(-1, -1);
 }
  /**
   * Resize the component ensuring location and size is within the bounds of the parent container
   * and that the size is within the minimum and maximum constraints.
   *
   * <p>All calculations are done using the bounds of the component when the resizing started.
   */
  @Override
  public void mouseDragged(MouseEvent e) {
    if (resizing == false) return;

    Component source = e.getComponent();
    Point dragged = e.getPoint();
    SwingUtilities.convertPointToScreen(dragged, source);

    changeBounds(source, direction, bounds, pressed, dragged);
  }
  public void mouseDragged(MouseEvent e) {
    Component c = e.getComponent();

    Point p = (Point) e.getPoint().clone();
    SwingUtilities.convertPointToScreen(p, c);
    SwingUtilities.convertPointFromScreen(p, glassPane);
    glassPane.setPoint(p);

    glassPane.repaint();
  }
示例#27
0
 @Override
 public void mouseReleased(final MouseEvent mouseEvent) {
   if (mouseEvent.isPopupTrigger()) {
     final Point point = mouseEvent.getPoint();
     SwingUtilities.convertPointToScreen(point, layerCanvas);
     sliderPopUp.show(point);
   } else {
     sliderPopUp.hide();
   }
 }
示例#28
0
 @Override
 public void mouseExited(MouseEvent e) {
   // Since we registered this listener on the child components of
   // the JWindow, not the JWindow iteself, we have to be careful.
   Component source = (Component) e.getSource();
   Point p = e.getPoint();
   SwingUtilities.convertPointToScreen(p, source);
   if (!TipWindow.this.getBounds().contains(p)) {
     ft.possiblyDisposeOfTipWindow();
   }
 }
示例#29
0
文件: Look.java 项目: Gogoro/Undef
  // recenter the mouse using the robot
  public synchronized void recenterMouse() {
    Window w = s.getFullScreenWindow();

    if (robot != null && w.isShowing()) {
      center.x = w.getWidth() / 2;
      center.y = w.getHeight() / 2;

      SwingUtilities.convertPointToScreen(center, w);
      centering = true;
      robot.mouseMove(center.x, center.y);
    }
  }
  private void processDrag(final MouseEvent e) {
    if (myDragCancelled) return;
    if (!isDraggingNow()) {
      if (myPressedPoint == null) return;
      if (isWithinDeadZone(e)) return;

      myDragPane = findLayeredPane(e);
      if (myDragPane == null) return;
      final BufferedImage image =
          new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
      paint(image.getGraphics());
      myDragButtonImage =
          new JLabel(new ImageIcon(image)) {

            public String toString() {
              return "Image for: " + StripeButton.this.toString();
            }
          };
      myDragPane.add(myDragButtonImage, JLayeredPane.POPUP_LAYER);
      myDragButtonImage.setSize(myDragButtonImage.getPreferredSize());
      setVisible(false);
      myPane.startDrag();
      myDragKeyEventDispatcher = new DragKeyEventDispatcher();
      KeyboardFocusManager.getCurrentKeyboardFocusManager()
          .addKeyEventDispatcher(myDragKeyEventDispatcher);
    }
    if (!isDraggingNow()) return;

    Point xy = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), myDragPane);
    if (myPressedPoint != null) {
      xy.x -= myPressedPoint.x;
      xy.y -= myPressedPoint.y;
    }
    myDragButtonImage.setLocation(xy);

    SwingUtilities.convertPointToScreen(xy, myDragPane);

    final Stripe stripe =
        myPane.getStripeFor(new Rectangle(xy, myDragButtonImage.getSize()), (Stripe) getParent());
    if (stripe == null) {
      if (myLastStripe != null) {
        myLastStripe.resetDrop();
      }
    } else {
      if (myLastStripe != null && myLastStripe != stripe) {
        myLastStripe.resetDrop();
      }
      stripe.processDropButton(this, myDragButtonImage, xy);
    }

    myLastStripe = stripe;
  }