Button class:
class SubmitButton extends JButton implements ActionListener { public SubmitButton(String title){ super(title); ....
Where I declare it:
SubmitButton submit = new SubmitButton('Submit'); submit.setBounds(530+150, 200, 100, 25);
How does super(title) set the String title to the title of the button? How does it do the same as the method .setText() for regular JButtons?
In other words, how did calling super() do the same thing as .setText() how does super() know to change title? is .setText() the only method in JButton Class that takes in string as parameter?
JButton has a constructor which might look like this (simplified):
SubmitBUtton has a constructor:
The SubmitButton constructor is calling the superclass (JButton) constructor, which is in turn calling setText. Now internally, JButton might work differently, but the effect is the same.
The overall point is that super(…) calls the superclass constructor.