Take the 2-minute tour ×  I am creating a program that displays
several bases and the amount of troops each base has. There are
two types of bases, friendly and enemy bases. Each Base extends
GCompound and consists of a GRect and a GLabel(to display the
number of troops). Two arrays are used to keep track of the
bases, one for friendly, one for enemy.  I want the user to be
able to press the mouse down on one friendly base and release on
a different friendly base, causing the troop amount to be
transferred from the first base to the second one.  My problem
currently is I am only able to detect the base the user presses
the mouse down on, and not the base that the mouse is released
on. I am using the method getElementAt from the ACM library to
return the GObject that a mouse action takes place on.  Code for
the mouse press:  public void mousePressed(MouseEvent e){
int mouseX = e.getX();     int mouseY = e.getY();     for(int i
= 0; i < PlayerBaseArray.length; i++){
if(getClickedObject(mouseX, mouse