Search code examples
javaswingjbutton

Difference between isArmed,isPressed and isSelected


What is the difference between the following methods :

jButton.getModel().isArmed()
jButton.getModel().isSelected()
jButton.getModel().isPressed()

I do not understand what the documentation says for isArmed and the rest two have an obvious documentation. But I do not how do they behave differently.


Solution

  • isArmed means:

    When the user presses the mouse button down on the JButton , but hasn't yet released it, the JButton is armed. However the armed state does'nt mean that action is going to be triggered for sure , because The user may release the button while the cursor is over the JButton, or the user may move the cursor elsewhere and release.Hence isArmed returns true if the JButton is armed, else it return false.