Changing value of boolean when mouse cursor hovers over a JButton
问题 I have a button that will change from black to gray when you hover over, I do this with setRolloverIcon(ImageIcon); . Is there any easy way to make a boolean equals to true while the mouse cursor hovers over the JButton or would I have to use a MouseMotionListener to check the position of the mouse cursor? 回答1: Is there any easy way to make a boolean equals to true while the mouse cursor hovers over the JButton you can to add ChangeListener to ButtonModel , e.g. JButton.getModel()