CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Lab #18 (Exercise 18-1)

Develop a payment applet

Due Date: Tuesday of Week 6
20 points

In this lab, you'll modify the Payment application so that it can be run as an applet.

Console

  1. Open the PaymentApp class.
  2. Open a new file, and cut and paste the code for the PaymentPanel class from the PaymentApp file to the new file. Give this class public access, add any required import statements, save the file as PAymentPanel, and compile it.

  3. Delete the import statements that aren't needed from the PaymentApp file, then compile the file and run the applications to see that it still works.

  4. Create a class named PaymentApplet that displays the payment panel. When you're done, compile the applet class to make sue that it compiles cleanly.

  5. Open the payment.html file and review the starting code. This file contains all the tags needed for the Payment applet except the APPLET tag. Add an APPLET tag that displays the PaymentApplet at 300 by 300 pixels, and then save the file.

  6. Use the Applet Viewver to view and test the applet. When you're done, click the Exit button to see that an exception is thrown indicating that the applet doesn't have the proper security clearance to access the current thread.

  7. Modify the PaymentPanel class so that it doesn't include an Exit button, and compile this class. Then, run the PaymentApp class and test it. This application won't display an exit button anymore, but you can still close it by clicking the Close button in the upper right corner.

  8. Use the Applet viewer to run and test the PaymentApplet class. This time, you'll have to exit from the applet by closing the browser window. Now, you have an application (PaymentApp) and an applet (PaymentApplet) that both use the same panel class.

  9. Run the HTML Converter to convert the the payment.html page. Then, open the payment.html page that's in the Payment directory and review the new code. Also open the payment.html page that's in the Payment_BAK directory to see that it contains the original code.

  10. Use your Web browser to test the HTML page and the applet. Since the JRE and Java Plug-in were automatically installed when you installed the JDK, the applet should work properly.

  11. Modify the actionPerformed method of the PaymentPanel class so that when you click the Accept button, a message is printed to the console indicating that the payment was accepted. Then, compile the class and run the applet from the browser again. this time, display the Java Console and view the statement that's printed to the console when you click the Accept button.

Include in your program the following comments:
  • Name of program
  • Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java program and the gif file by clicking the link below:

Upload Lab

I cannot grade if I don't get the files and receive your email.