JCS-Java Class Series

Hey guys, You have been interfacing with this class for longer than you can remember. We have buttons in every login pages. Have you thought about implementing your own button in java?

Well this class, will help you in implementing a button and also provide a set of actions with the help of predefined methods. Let’s see how it’s done.

Defines common behaviors for buttons and menu items.

Buttons can be configured, and to some degree controlled, by Actions.

Using an Action with a button has many benefits beyond directly configuring a button

The abstract button is a framework-provided class that implements some, but not all, behaviors of a button.

import javax.swing.AbstractButton

public abstract class AbstractButton
extends JComponent
implements ItemSelectable, SwingConstants

Updates the button’s state in response to property changes in the associated action

Adds an ActionListener to the button.

Adds an ItemListener to the checkbox.

Programmatically perform a “click”.

Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Returns the button’s text.

Resets the UI property to a value from the current look and feel.

Sets the button’s text

Sets the button’s default icon.

Returns a string representation of this AbstractButton.

Takeaways From this class

  • common behaviors for buttons
  • Action + button= configuring a button
  • abstract button = framework-provided class

Conclusion

This series is intended for one purpose only. It is for you to get in touch with all the classes in Java. If you have any doubts regarding the classes do ask me about it. I will make sure that your doubts are cleared.

Thank you For reading this blog. Do follow HouseofCodes.

Author: Akshay Ravindran

Code -> Understand-> Repeat is my motto. I am a Data Engineer who writes about everything related to Data Science and Interview Preparation for SDE.

Code -> Understand-> Repeat is my motto. I am a Data Engineer who writes about everything related to Data Science and Interview Preparation for SDE.