Esempio n. 1
0
    public void mouseDragged(java.awt.event.MouseEvent e) {
      if (dragTargetArea != null) {
        // Since we're dragging, this is no longer considered a click
        isClick = false;

        // Draw the target feedback and position the drag button based
        // on the mouse's new location
        e.translatePoint(dragSourceArea.x, dragSourceArea.y);
        Point p = makeSafePoint(e.getX(), e.getY());
        paintTargetFeedback(p.x, p.y);
        getDragButton().setLocation(p.x - cursorOffset.x, p.y - cursorOffset.y);
      }
    }
Esempio n. 2
0
    public void mouseReleased(java.awt.event.MouseEvent e) {
      if (dragTargetArea != null) {

        // Turn off the drag button and feedback
        getDragButton().setVisible(false);
        paintTargetFeedback(-1, -1);

        e.translatePoint(dragSourceArea.x, dragSourceArea.y);
        Point p = makeSafePoint(e.getX(), e.getY());

        JButton b = (JButton) e.getSource();
        if (isClick || dragTargetArea.contains(p.x, p.y)) {
          // if we're considered a simple click, or the dragging ended
          // within the target area, perform the move.
          slide(buttons.indexOf(b));
        } else {
          // The drag finished outside the target, so just show the
          // hidden button and don't move anything.
          b.setVisible(true);
        }
        dragTargetArea = null;
        dragSourceArea = null;
      }
    }