Jump to content

Help with initializing Mouselistener

- - - - -

  • Please log in to reply
No replies to this topic

#1
Serialcek

Serialcek

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Help everyone!
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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users