Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com

This is what it's about.

===============

The applet's actionPerformed method will be called when the button is pressed, ....

because it is registered initially with the button,

which is possible because it is an ActionListener.

The first click adds "Button clicked" to the TextArea,....

,because the boolean variable firsttime has been set to true initially .

The boolean is set to false at the first button press ,.....

so each next press will add "And again" on a new line to the TextArea, because the boolean has been set to false.

=======

The curly brackets, { } ,in the if statement are essential, because they demarcate two or more statements as one code block,....

to be executed in the if-branch .

Not necessary here, because this is only one statement.

You can nest if-else statements, but you'll have to pay special attention to the brackets and the fact that 'else' can only follow an if's closing bracket (or an if's single statement).

=======

A conditional expression can sometimes be used as an if-else shorthand. This one means : if nr is greater than 7, nr = 1, else nr = nr .

=======

NOTE

=======

Equivalent to :


if ( firsttime == true )
=======

\n new-line

.