Before you read this I just want to say that any help would help me very much, right now. I'm very desperate. I've spent at least a week trying to get this work in Eclipse, I think I'm missing something obvious, I really need your help.
Right now my mouse listener contains if-statements for each 'room' and a double for-loop within those if-statements that tells the JFrame if the mouse is clicked within a certain region of the JFrame to repaint the corresponding 'room'.
Now let's say room #4 can lead to either #5 or #6. Going from #4 > #6 shows no issues. Now from #5 > #4 there is a problem. For some reason the event regions for room #4 show up in #5 (it should not) so now I can go to either #4 or #6 when I click on previous event regions.
I've tried this for other 'rooms' and the issue doesn't appear in them. I've concluded that it might have to do something with going back and forward between rooms that are connected with more than one path. I've attached a visual pathway and the isolated code to make things easier (The numbers are just the room #'s).
MouseAdapter mouseHandler = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
//System.out.println(e.getPoint());
if(n==6)//R6
{
for(int i = 116;i<132;i++)//3a
{
if(e.getX() == i)
{
for(int j = 388;j<404;j++)
{
if(e.getY() == j)
{
n = 7;//3b
return;
}
}
}
}
for(int i = 116;i<132;i++)//2b
{
if(e.getX() == i)
{
for(int j = 308;j<324;j++)
{
if(e.getY() == j)
{
n = 4;//2a
return;
}
}
}
}
for(int i = 580;i<596;i++)//8a
{
if(e.getX() == i)
{
for(int j = 372;j<388;j++)
{
if(e.getY() == j)
{
n = 2;//8b
return;
}
}
}
}
}
if(n==5)//R5
{
for(int i = 220;i<268;i++)//1b
{
if(e.getX() == i)
{
for(int j = 437;j<485;j++)
{
if(e.getY() == j)
{
n = 4;//1a
return;
}
}
}
}
}
if(n==4)//R4
{
for(int i = 179;i<244;i++)//2a
{
if(e.getX() == i)
{
for(int j = 403;j<468;j++)
{
if(e.getY() == j)
{
n = 6;//2b
return;
}
}
}
}
for(int i = 436;i<500;i++)//1a
{
if(e.getX() == i)
{
for(int j = 403;j<468;j++)
{
if(e.getY() == j)
{
n = 5;//1b
return;
}
}
}
}
for(int i = 274;i<406;i++)//A2
{
if(e.getX() == i)
{
for(int j = 193;j<276;j++)
{
if(e.getY() == j)
{
n = 0;//A1
return;
}
}
}
}
}
if(n==0)//R0
{
for(int i = 459;i<493;i++)//A1
{
if(e.getX() == i)
{
for(int j = 110;j<133;j++)
{
if(e.getY() == j)
{
n = 4;//A2
return;
}
}
}
}
}
repaint();
//http://stackoverflow.com/questions/5654208/making-a-jbutton-invisible-but-clickable
}
public void mouseMoved(MouseEvent e)
{
// = e.getPoint();
//repaint();
}
};
addMouseMotionListener(mouseHandler);
addMouseListener(mouseHandler);