CISC370-011 -- demo code from class #7

This page provides links to some short demo programs from class #7 (21 Oct).

OptionDialogTest.java is an extended example (from the textbook) of the configurability of the JOptionPane class.

Ruler.java and Ruler.html demonstrate the simplest possible applet.

Ruler2.java and Ruler2.html demonstrate an applet with a single parameter, msg. RulerAll.html demonstrates multiple applets on one Web page.

CButtons.java shows Swing components in an applet.

BControl.java is an applet with three JButtons that open Web pages in new browser windows.

PlaySound.java shows how an application can use Applet methods (in this case, the play() method for playing AudioClips).

RTC.java is a simple digital clock applet (with test HTML at RTC.html). Its JAR file was assembled with the following command:

D:\CIS370\Web\demo\class07>jar cvf rtc.jar RTC*.class

ResTest.java illustrates a JAR file which includes image resources. Here are the commands to build the JAR file, including the Main-Class attribute that makes the file double-clickable:

D:\CIS370\Web\demo\class07>type ResManifest.txt
Main-Class: ResTest

D:\CIS370\Web\demo\class07>jar cvfm ResTest.jar ^
    ResManifest.txt Res*.class marvel.gif images
added manifest
adding: ResAction.class(in = 1030) (out= 588)(deflated 42%)
adding: ResTest$1.class(in = 479) (out= 327)(deflated 31%)
adding: ResTest.class(in = 2357) (out= 1338)(deflated 43%)
adding: marvel.gif(in = 9427) (out= 9156)(deflated 2%)
adding: images/(in = 0) (out= 0)(stored 0%)
adding: images/barnie_3.jpg(in = 41556) (out= 41512)(deflated 0%)
adding: images/inkie_3.jpg(in = 36984) (out= 36958)(deflated 0%)
adding: images/inkie_6.jpg(in = 41287) (out= 41265)(deflated 0%)
adding: images/p0207210741b.jpg(in = 46760) (out= 37483)(deflated 19%)
adding: images/P6150036.JPG(in = 44998) (out= 36042)(deflated 19%)

D:\CIS370\Web\demo\class07>

PropTest.java exercises the Properties API.

PrefTest.java demonstrates the Preferences API with a simple three-button window that remembers its last background color from run to run. Its double-clickable JAR file is PrefTest.jar.