/**
 *
 */
package com.github.apixandru.games.rummikub.ui;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.MouseEvent;

import javax.swing.JComponent;

/**
 * @author Alexandru-Constantin Bledea
 * @since Oct 15, 2015
 */
final class ComponentDragSource implements DragSource {

	private final Container container;

	/**
	 * @param container
	 */
	public ComponentDragSource(final Container container) {
		this.container = container;
	}

	/* (non-Javadoc)
	 * @see com.github.apixandru.games.rummikub.ui.DragSource#getComponent(java.awt.event.MouseEvent)
	 */
	@Override
	public JComponent getComponent(final MouseEvent e) {
		return (JComponent) this.container.findComponentAt(e.getX(), e.getY());
	}

	/* (non-Javadoc)
	 * @see com.github.apixandru.games.rummikub.ui.DragSource#beginDrag(java.awt.Component)
	 */
	@Override
	public void beginDrag(final Component component) {
		// AAA Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.github.apixandru.games.rummikub.ui.DragSource#endDrag(java.awt.Component)
	 */
	@Override
	public void endDrag(final Component component) {
		// AAA Auto-generated method stub

	}

}

@@ -172,16 +172,49 @@
 mponent;
+%0Aimport javax.swing.JLayeredPane;
 %0A%0A/**%0A *
@@ -334,16 +334,49 @@
 urce %7B%0A%0A
+%09private final Container parent;%0A
 %09private
@@ -492,16 +492,55 @@
 iner) %7B%0A
+%09%09this.parent = container.getParent();%0A
 %09%09this.c
@@ -1011,42 +1011,60 @@
 %7B%0A%09%09
-// AAA Auto-generated method stub%0A
+this.parent.add(component, JLayeredPane.DRAG_LAYER);
 %0A%09%7D%0A
@@ -1241,42 +1241,63 @@
 %7B%0A%09%09
-// AAA Auto-generated method stub%0A
+this.parent.remove(component);%0A%09%09this.parent.repaint();
 %0A%09%7D%0A

add implementation