I'm making a program where the user will drag a card across a table using the mouse. The Card is a JPanel
and so is Table. Table has a null
layout. In the Card class, I have this:
@Override
public void mouseDragged(MouseEvent e)
{
if (this.getWhere() == 1) // makes sure the card is on the table
{
Table.table.moveCard(this, e.getX(), e.getY());
}
}
Then in the Table class:
public void moveCard(Card card, int x, int y)
{
card.setLocation(x, y);
}
When I drag the card, it will jump back and forth from where the mouse is and a point near the top left corner of the panel.
Any help?