File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Newbie problem with Event ... MouseListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Newbie problem with Event ... MouseListener" Watch "Newbie problem with Event ... MouseListener" New topic
Author

Newbie problem with Event ... MouseListener

Tirthankar Mukherjee
Ranch Hand

Joined: Apr 08, 2006
Posts: 51


Can anyone take the pain to compile this code and see why my mousePressed() is not getting called. I this program I am trying make a GUI ChessBoard.
Thanks in Advance...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
comment out this line, recompile/rerun

//square.setToolTipText(Integer.toString(i));
Tirthankar Mukherjee
Ranch Hand

Joined: Apr 08, 2006
Posts: 51
Michael Dunn wrote:comment out this line, recompile/rerun

//square.setToolTipText(Integer.toString(i));


ThankYou for your fast reply , the problem is solved ! But can you explain me why ??? Whats the problem with that ??
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the panel (square) is on top, setToolTipText adds a mouseListener to the panel,
and when fired, consumes the event.

you would need to add a separate mouseListener to the panel, then dispatch the event to the layeredPane
Tirthankar Mukherjee
Ranch Hand

Joined: Apr 08, 2006
Posts: 51
ThankYou again Michael Dunn , you really took me out of this soup !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Newbie problem with Event ... MouseListener
 
Similar Threads
Chessboard-Newbie Question
How to add MouseLsitener to JMenu
chess game : moving piece
display image in jpanel
Queen 8 ChessBoard Example Help