This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Does anyone know how to write the code for the following: Lets sat you have the button: JButton button = new JButton("Right Click me"); How do you write a mouse listener so that when you right click on it the following fucntion is executed : System.out.println("thanks"); Thanks in advance
All you have to do is add a MouseListener to the component that defines what to do in it's mousePressed method. In that method it should test isMetaDown on the MouseEvent it recieved. The code below illustrates one way to do this...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.