Topics on this page: Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

CIS256 - Class 7


Array Example

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is an example of how you can work with arrays in JavaTM. It include an example of how to read command line arguments.

You will most likely need to work with Arrays when you create Lab 4.

ArrClass - Source.
ArrClass - Listing.


Generating Random Numbers

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is an example of how you can create random numbers. It is also an example of how to simplify complicated functionality of another class by creating a "wrapper class".

Randomizing is also part of Lab 4.

RandCl - Source.
RandCl - Listing.


Menus

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is an example of how to create menus. You guessed it.....necessary for Lab 4.

Menus/MenuEx.java - Source.
MenuEx - Listing.


Timer Example

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is an example of how to use a timer.

You should use a timer for Lab 4.

TimerEx - Source.
TimerEx - Listing.


CardLayout Layout Manager

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is an example of how to use a CardLayout Layout manager.

CardLay - Source.
CardLay - Listing.


GridBag Layout Manager

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

This is how to use a GridBag Layout. Note that the GridBag layout gives you the most control over placement and adjustment of components, however it is also the most complicated to use.

GBLayout - Source.
GBLayout - Listing.


Homework

Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

Read pages: 407-439 (Arrays); 759-766 (Menus); 186-187 (Random Class)

Lab 4

Lab4
Top |Arrays | Random Number Generator | Menus | Timer | CardLayout | GridBagLayout | Homework/Lab

Questions? Email me:mcccjava@hotmail.com

CIS256 - Home Page

SunTM, Sun MicrosystemsTM, the Sun Logo, and JavaTM are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.