Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use the back and forward mouse buttons in a Swing application?

The question is pretty simple. I couldn't find many links regarding this issue, and the ones I found didn't seemed to avoid the real question. My application must handle the mouse pressed/released events for the back and forward mouse buttons. How can I handle this?

EDIT: This is using JDK 1.6.

like image 831
Sam Harwell Avatar asked Oct 04 '11 08:10

Sam Harwell


1 Answers

Check if additional mouse buttons are detected by calling:

MouseInfo.getNumberOfButtons();

Check if MouseEvents are fired when you click those additional buttons. If so, what does MouseInfo.getButton() return?

According to the javadocs for MouseInfo.getButton():

If a mouse with five buttons is installed, this method may return the following values:

* 0 (NOBUTTON)
* 1 (BUTTON1)
* 2 (BUTTON2)
* 3 (BUTTON3)
* 4
* 5
like image 133
dogbane Avatar answered Oct 02 '22 19:10

dogbane