Please send questions to
st10@humboldt.edu .
Random notes for CIS 480 - Advanced Java Programming, Week 3, 2-5-01
Topic: Java Applications, Part 2 (applications with a GUI)
* last time: went over how an application needs to set up its
own window, usually using a Frame (in Java 1.1, AWT);
* see example, GuiApplic1.java
* (note that it does not close properly under BlueJ,
but does when run using the JDK)
* inner class: a class defined within another class
(called an outer class)
* advantage: this inner class can see the private
data fields of the outer class;
* GuiApplic2.java gives an example application with some
user-sensitive components, and:
* hows two inner classes used to handle action
events on two different buttons
* also shows multiple top-level classes in the
same file --- this is permitted, BUT only one
of the classes will be declared as "public"
(and that, of course, is the one the file is
named after.
* note the use of GuiApplic2Frame class here;
* steps to set up a a menubar and menus in a frame:
("Java Examples in a Nutshell", OLD FIRST EDITION, Flanagan, p. 124)
1. create a MenuBar object, and you display it in a Frame
by calling the setMenuBar() method of Frame
2. create the desired menu panes, which are represented by Menu
objects, and add them to your MenuBar with its add() method.
3. (if one of your menus is a Help menus, some platforms treat
them specially --- you should pass such a menu on to the
setHelpMenu() method to indicate this.)
4. Finally, you create MenuItem and CheckboxMenuItem objects
and add them to each menu pane using the add() method of the
appropriate Menu object.
* simple Menubar example: see GuiApplic3.java