Class DragLayer

All Implemented Interfaces:
AWTEventListener, ImageObserver, MenuContainer, Serializable, EventListener

public class DragLayer extends JComponent implements AWTEventListener
A glass pane component for drawing dragged items. Using ideas (though no code) from Alexander Potochkin of the swing team. His blog entry describing the tricks used: https://weblogs.java.net/blog/2006/09/20/well-behaved-glasspane
See Also:
Serialized Form
  • Method Details

    • contains

      public boolean contains(int x, int y)
      Overrides:
      contains in class JComponent
    • get

      public static DragLayer get()
      Get the DragLayer instance.
      Returns:
      drag layer
    • startDrag

      public void startDrag(IEntity entity)
      Start dragging an entity. The DragLayer will take care of drawing, updating the position and dropping it to the right DropTarget.
      Parameters:
      entity - dragged entity
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • eventDispatched

      public void eventDispatched(AWTEvent e)
      Specified by:
      eventDispatched in interface AWTEventListener