Change JButton focus area
问题 How do i change the area of focus on a JButton so that when i hover my cursor over the button my costume rollover Icon isn't activated slightly before my cursor is over the actual button itself. 回答1: The contains(x, y) method of the button determines when the mouse enters the button. If your custom button is not rectangular then you would need to override this method. Here is an old example that demonstrates this concept: // Old example code found on the internet somewhere // to paint a Round