Jane Hall wrote:Also, what does
Jane Hall wrote: . . . looks at main, and executes what it finds there.
If you have something like Hangman hangmanGame = new Hangman(); then main calls the constructor Hangman().
No. You would call another method. That method would call your other methods in order. You might have another line like…and the start method contains all the instructions to get the game going.
The constructor would be the only thing to run in the class, so any methods you want to call must be in it. (Or must be called in a different method which is itself called in the constructor).
. . . Can you call methods using other means?
No. In a GUI application, actionPerformed methods are called by the JVM (or something like that) when the operating system sends an Event. That means, when you click the button, the OS sends an event, which passes through all objects at that location on screen until it finds something which is listening for it. When it finds whatever is listening, then the JVM invokes actionPerformed (or something vaguely along those lines). In fact there are hundreds of methods which can be called when events occur, but most events simply disappear into cyber‑limbo (officially called garbage collection) without starting any methods off.
For example, in my constructor, I've written button.addActionListener(this); Does that automatically call the actionPerformed(ActionEvent e) method? . . .