From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02
03 importimport means to make the classes and/or packages available in this program javax.swing.*;
04 importimport means to make the classes and/or packages available in this program java.awt.*;
05 importimport means to make the classes and/or packages available in this program java.awt.event.*;
06
07 /**
08 * All about my applet.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects ButtonListenerExample extendsextends means to customize or extend the functionality of a class JApplet
12 {open braces start code blocks and must be matched with a close brace
13 privateprivate is used to restrict access to the current class only JButton button;
14
15 classclass is a group of fields and methods used for making objects ButtonResponder implementsimplements means providing method bodies for the methods declared in the corresponding interface ActionListener
16 {open braces start code blocks and must be matched with a close brace
17 intint is the type for whole numbers and it is short for integer clicked=this assignment operator makes the left side equal to the right side0;
18
19 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value actionPerformed(ActionEvent e)
20 {open braces start code blocks and must be matched with a close brace
21 clicked++this is the increment operator, which increases the variable by 1;
22 button.setText("Clicked: "+adds two numbers together or concatenates Strings togetherclicked);
23 }close braces end code blocks and must match an earlier open brace
24 }close braces end code blocks and must match an earlier open brace
25
26 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value init()
27 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
28
29 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value start()
30 {open braces start code blocks and must be matched with a close brace
31 button=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor JButton("Not yet clicked.");
32 getContentPane().add(button);
33 button.addActionListener(newnew is used to create objects by calling the constructor ButtonResponder());
34 }close braces end code blocks and must match an earlier open brace
35
36 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value stop()
37 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
38 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/ButtonListenerExample.java