AbstractButton and its sub classes - Tutorial

Here is a complete list of exhaustive tutorials on JButton, JToggleButton, JCheckBox, JRadioButton which will help you ace all the children of AbstractButton.
Let us now look about what they are.


JButton is a nothing more than a push-button which you might already have gone through many times. User can click on it to get anything done.


A JToggleButton is another component much similar to a JButton. But the difference is a JToggleButton goes into pressed state when mouse is pressed on it. To get that back into normal state, we need to press again. This component is mostly used when there is an on/off situation. You'll get a better idea of what it is when you see it in practical.


A JCheckBox lies on a single principle, checked/unchecked. This component is mostly used in when we are checking multiple items, for example in Job search site, you might have undergone this where you select multiple skills, a check box is mostly used.


JRadioButton is also based on the same principle as that of the JCheckBox. But the difference is that a JRadioButton is typically used when the user has to choose only one among the many items in a group. For instance, you can use it for Male/Female, the user has to select either of it, but not both. In AWT, you don't have specified class for JRadioButton as here.


A JMenuItem as said previously, is an item included in a menu where the user can click on it or invoke it by a shortcut. You can see this in Notepad, New, Open, Save etc. are called menu items. You can invoke them either by click on them or selecting them and hitting enter or via a shortcut.


This is a JMenuItem with JCheckBox in it. You might have seen this in Notepad > Format > Wordwrap.


This is a JMenuItem with a JRadioButton in it. You can better know it and its uses if you take a look at the example.

Note: JButton, JToggleButton, JMenuItem are all sub-classes of AbstractButton, JCheckBox and JRadioButton are sub-classes of JToggleButton. JRadioButtonMenuItem and JCheckBoxMenuItem are sub-classes of JMenuItem.

Posted by at on

Tags: Swing Theory,