// START TYPING HERE ... //CIS 757 PROF. AUCIELLO. PLEASE TYPE IN THE // FOLLOWING PROGRAMS. // THIS IS THE 1ST PROGRAM. call it f124.java // NOTE: I PUT SYNTAX ERRORS INTO THIS PROGRAM AS AN // EXERCISE IN DEBUGGING TO EMPOWER YOUR TECHNOLOGY! // CIS 757 PROF. AUCIELLO // TYPE THIS IN. // THIS JAVA PROGRAM (APPLET) DISPLAYS // IMAGES (LIKE AN AUTOMATIC SLIDE PROJECTOR) // YOU CAN CONTROL THE SPEED, ADD MUSIC, OTHER MEDIA. // THIS ALSO WILL SERVES AS A TEMPLATE FOR JAVA PROGRAMMING. // LEARN THIS. // ALL JAVA APPLETS START WITH LINKING (IMPORTING) // ROUTINES FROM STORED HUGE, POWERFUL LIBRARIES // WHICH CONTAIN POWERFUL ROUTINES. (DID I SAY THAT?) import java.applet.Applet; import java.awt.Graphics; import java.awt.image.*; import java.awt.*; // (4) LIBRARIES ARE LINKED TO. // 'PUBLIC CLASS' STARTS THE MAIN BODY OF THE APPLET. // f124 is the APPLET NAME. NOTE THAT IT INHERITS FEATURES (EXTENDS) public class f124 extends java.applet.Applet { // start 'public class' Image currentgif; // THIS DEFINES currentgif AS AN IMAGE. Image erasegif; Image gifarray[] = new Image[150]; // defines gifarray as having 'n' levels [indexable] String namearray[] = {"blue.gif", "1.GIF", "1lc.gif", "1A.GIF", "2.GIF", "3A.GIF", "4.GIF, "4A.GIF", "5.GIF", "5A.GIF", "6.GIF", "7.GIF", "7A.GIF", "ALAN.GIF", "APRIL.JPG", "AUCI-07.GIF", "AUCIELLO.GIF", "C_MONICA.GIF", // "COLUMN~1.JPG", // "CYNDI.BMP", // CYNDI4.GIF", // "CYNI2.GIF", // "DALI.JPG", // "DALI4.JPG", // "DUNIAV.JPG", "EDIE.GIF", // "FIG1.GIF", // "FIG2.GIF", // "FROSTY01.JPG", // "FROSTY04.JPG", // "FROSTY08.JPG", // "FULL.GIF", // "GR_1.GIF", "GRAB0011.GIF", "GRAB0012.GIF", "GRAB0013.GIF", "GRAB0014.GIF", "GRAB0017.GIF", "GRAB0023.GIF", // "GRAB0024.GIF", "GRAB0025.GIF", "graciela.JPG", // "I0.GIF", "I1.GIF", // "I11.GIF", // "I12.GIF", "I13.GIF", // "I14.GIF", "I15.GIF", "I16.GIF", "I17.GIF", "I2.GIF", "I3.GIF", "I4.GIF", "I5.GIF", "I6.GIF", // "I8.GIF", "I9.GIF", // "IMAGE.GIF", // "IMAGE7.GIF", // "IMG0007.GIF", // "IMGDAVE2.JPG", // "IP_1.GIF", // "IP_5.GIF", // "ISP.GIF", "KAREN.GIF", // "KOBE1.GIF", // "M&C1.GIF", // "NETSCA~1.JPG", // "PROFA.GIF", // "PROFA1.GIF", // "PROFACR.GIF", // "PUNY.GIF", // "QUE.JPG", // "SONIA.JPG", "susan.gif" }; int nal = namearray.length; int ilc; public void init() { // start init() for ( int i=0; i < nal; i++ ) { gifarray[i] = getImage(getCodeBase(),namearray[i]); } // block started and ended. } // end init() public void paint(Graphics g) { // start 'paint' int x = 1 int hor = 1; String yourname = "PROF. AUCIELLO'S GALLERY (takes time to load images into array ... "; Font fs = new Font("Sans Serif", Font.BOLD, 12); Font fm = new Font("Monospaced", Font.BOLD, 14); g.setFont(fs); setBackground(Color.blue); g.setColor(Color.yellow); g.setFont(fm); hor = 220; ilc = 0; outerloop: while ( ilc < nal ) { // start outerloop. g.drawString(yourname, 20, 70); String strvar = namearray[ilc]; g.setColor(Color.red); g.drawString(strvar, 375, 85); g.drawString(yourname, 20, 70); currentgif = gifarray[ilc]; g.drawImage(currentgif, hor-80, 100, this); x = 1; while ( x < 30 ) // (12 = 1 sec delay) (50 = 10 sec delay) // delay to reduce flicker. // syntax of "while" { System.out.println("x = " + x); g.drawString(" " + x, 1, 1); x ++; } // 'while started and ended. ilc = ilc + 1; erasegif = gifarray[0]; g.drawImage(erasegif, hor-80, 100, this); g.setColor(Color.blue); g.drawString(strvar, 375, 85); repaint(); } // end 'outerloop' } // end 'paint' } // end 'public class 47' /* THIS APPLET ALLOWS YOU TO SELECT IMAGES, TO PUT THEM IN A SEQUENCE, AND DISPLAY THEM. IT IS, LITERALLY, 'MOTION PICTURES'. THIS IS HOW THE MULTI-MEDIA BEGAN. */ // this is the end of the java source program. // Stop typing java source program here. // 2nd step. Compile f124.java using the java compiler (of course) // correct all errors. check that you get a f124.class output // 3rd step. create the following html set:// start typing html here. Contains a .class object (compiled from Java Source Program) // stop typing html. // 4th step. run the html using a browser. // upload the html, .class program, and all the images that // make the images the same size. // you want to your web site. // this is about demonstrating that you can use a java applet on your home page.