I trying to solve this problem but I can't find any solution for it.. I don't neither know if it would work like I won't.
final MouseListener ml = new MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
mouseClicked(evt);
for (int x = 0; x <= 10; x++) {
grid[x][P].addMouseListener (ml); //The local variable ml may not have been
initialized
}
for (int x = 0; x <= 10; x++) {
if (grid[x][P] == evt.getSource()) {
if (grid[x][P].getText()
.equals("You clicked!")) {
for (int y = 0; y <= 10; y++) {
grid[x][P].removeMouseListener (ml);
System.out.println("MouseListener removed!");
}
}
}
}
}
};
Can someone tell me if this will work and I have a problem with initializing the variable ml also. Can someone help me?
Thx


Sign In
Create Account


Back to top









