Class ComponentMover

    • Constructor Detail

      • ComponentMover

        public ComponentMover()
        Constructor for moving individual components. The components must be regisetered using the registerComponent() method.
      • ComponentMover

        public ComponentMover​(Class destinationClass,
                              Component... components)
        Constructor to specify a Class of Component that will be moved when drag events are generated on a registered child component. The events will be passed to the first ancestor of this specified class.
        Parameters:
        destinationClass - the Class of the ancestor component
        components - the Components to be registered for forwarding drag events to the ancestor Component.
      • ComponentMover

        public ComponentMover​(Component destinationComponent,
                              Component... components)
        Constructor to specify a parent component that will be moved when drag events are generated on a registered child component.
        Parameters:
        destinationComponent - the component drage events should be forwareded to
        components - the Components to be registered for forwarding drag events to the parent component to be moved
    • Method Detail

      • isChangeCursor

        public boolean isChangeCursor()
        Get the change cursor property
        Returns:
        the change cursor property
      • setChangeCursor

        public void setChangeCursor​(boolean changeCursor)
        Set the change cursor property
        Parameters:
        changeCursor - when true the cursor will be changed to the Cursor.MOVE_CURSOR while the mouse is pressed
      • getDragInsets

        public Insets getDragInsets()
        Get the drag insets
        Returns:
        the drag insets
      • setDragInsets

        public void setDragInsets​(Insets dragInsets)
        Set the drag insets. The insets specify an area where mouseDragged events should be ignored and therefore the component will not be moved. This will prevent these events from being confused with a MouseMotionListener that supports component resizing.
        Parameters:
        dragInsets -
      • deregisterComponent

        public void deregisterComponent​(Component... components)
        Remove listeners from the specified component
        Parameters:
        components - components the listeners are removed from
      • registerComponent

        public void registerComponent​(Component... components)
        Add the required listeners to the specified component
        Parameters:
        components - components the listeners are added to
      • getSnapSize

        public Dimension getSnapSize()
        Get the snap size
        Returns:
        the snap size
      • setSnapSize

        public void setSnapSize​(Dimension snapSize)
        Set the snap size. Forces the component to be snapped to the closest grid position. Snapping will occur when the mouse is dragged half way.
      • mousePressed

        public void mousePressed​(MouseEvent e)
        Setup the variables used to control the moving of the component: source - the source component of the mouse event destination - the component that will ultimately be moved pressed - the Point where the mouse was pressed in the destination component coordinates.
        Specified by:
        mousePressed in interface MouseListener
        Overrides:
        mousePressed in class MouseAdapter