• Post Reply Bookmark Topic Watch Topic
  • New Topic

buttons not showing  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is right from a book I'm reading but it doesn't work. The problem is to write an application that lets you determine the integer value
returned by the InputEvent method getModifiers() when you click your left, right, or middle mouse button on a JFrame.

This is the code copied directly from the book. Can someone tell me what is missing:

 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) the MouseListener code should be part of the main() method.
2) then once you create the listener you need to add the listener to the frame.

I would suggest you read the section from the Swing tutorial on How to Write a MouseListener for more information and a better example on how to write the code so that the GUI is created on the Event Dispatch Thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!