Terms & Concepts
These are some of the terms and concepts you should know or learn. Some will be obvious, others will be confusing for a while. The more you can learn and identify, the easier programming will be...especially when Mr. Meinzen talks about them.
Basic Terms/Concepts |
Abstract Terms/Concepts |
|
|
Program Walkthrough (based upon PetRockGUI.java)
After Mr. Meinzen demonstrates the program walkthrough, answer the following questions:
PetRockGUI.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4 public class PetRockGUI extends JPanel implements ActionListener
5 {
6 private JFrame frameObject;
7 private JButton buttonObject;
8 private JLabel labelObject;
9 private int length;
10 private int width;
11 private String name;
12 public static void main(String a[])
13 {
14 PetRockGUI game = new PetRockGUI();
15 }
16 public PetRockGUI()
17 {
18 length = 50;
19 width = 100;
20 name = "Mr. Meinzen's PetRock";
21 Font niceFont = new Font("Courier New", Font.PLAIN, 24);
22 labelObject = new JLabel("My name is "+name);
23 labelObject.setFont(niceFont);
24 labelObject.setForeground(Color.RED);
25 this.add(labelObject);
26 buttonObject = new JButton("Click me to flip");
27 buttonObject.addActionListener(this);
27 this.add(buttonObject);
29 frameObject = new JFrame("My First Graphical Application");
30 frameObject.setSize(500, 500);
31 frameObject.setLayout(null);
32 frameObject.setContentPane(this);
33 frameObject.setVisible(true);
34 }
35 public void paintComponent(Graphics g)
36 {
37 super.paintComponent(g);
38 g.setColor(Color.GREEN);
39 g.fillRect(50,150,length,width);
40 }
41 public void flip()
42 {
43 int temp = length;
44 length = width;
45 width = temp;
46 }
47 public void actionPerformed(ActionEvent e)
48 {
49 flip();
50 repaint();
51 }
52 }
-
After hitting the "Hammer1" button, what happens and which line does the computer start on?
-
After hitting the “Hammer2” button, what happens and which line does the computer start on?
-
Name all the methods in the class.
-
Name all the variables and their Types.
-
What is the difference between starting with a capital letter and lower-case letter (i.e. when should you start with a capital letter and when should you start with a lower case letter?)
-
What is the difference between a Class and an object?
-
Which line(s) have the following:
-
a declaration for a Button
-
an instantiation for a Button
-
listens for clicks on a Button
-
puts a Button on the screen
-
find 3 lines that have a literal being assigned to a variable
-
find a line where a variable is declared inside a method
-
which lines have a matching method declaration and method call
-
find a line that uses a qualified name
-
