Discussion Locked

who can access fireActionPerformed()

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

fireActionPerformed(ActionEvent ae) is a prptected method in the class javax.swing.AbstractButton.
JButton is a class extending AbstractButton.
Why can't we call "fireActionPerformed" on an instance of JButton ?

1 reply

by leif

Protected methods can be called by a subclass of the class containing the method. Protected methods are not made public by a subclass.

In your example above, AbstractButton contains a protected method fireActionPerformed(), and JButton extends AbstractButton. Any method in JButton may call fireActionPerformed(). Any method in a class that extends JButton may call fireActionPerformed(). However, an arbitrary class may not call fireActionPerformed() on an instance of JButton or AbstractButton: the method is still protected.

This discussion is closed to new replies.