Java Programming
CIS279
Tori Basford
tori@bly.net
Assignment(s):
CIS 279 Homework 1, parts b and c: Adding a Listener / Creating Bars of different Colors
Exercise(s):
Quiz 3:
Review: Java Basics
Outside of a method, you can only put declaration statements.
Java demands that every variable MUST be initalized. Object and Class variables are automatically initialized to zero or false or NULL.
The standard Java Classes are located in "java.lang.*" and are imported by default.
Components, continued:
Everything on the screen is a Component with extra stuff added. The basic Component contains
Layout Managers:
A Layout Manager Object is a collection of methods to size and position components.
To change the Layout Manager:
| LayoutManager lm = new FlowLayout();
panel object.setLayout(lm); |
More on the ColorBar class:
The ColorBar class will recieve a value to show whether the ColorBar deals with Red, Green or Blue.
The value for what coresponds to each color will be stored in the static variables RED_SIGNAL, BLUE_SIGNAL, and GREEN_SIGNAL. So, if you've chosen character data, for example, then you'r econstructor will be ColorBar(char c) {. For now, just store the color.
example:
ColorBar cb1 = new ColorBar(ColorBar.BLUE);