Nada

Lab assignment 1 - The Prutt-button

The first thing to do is to register for the course. Log in at CSC and write in a terminal window: res checkin prutt08. Each member in a lab group must register from his/her own account.

Now write course join prutt08 This command will improve your environment a little and make messages from the course leader of prutt08 available to you. The following (optional) command will create a common directory prutt08 for you and your lab partner.

course labdir prutt08 loginNameOfLabPartner

The labpartner must then log in and give the command with your login name last. If you don't want a common directory, just create a directory for the course: mkdir prutt08

Write a Java application and an applet!

Connect to the directory prutt08, create a subdirectory lab1 and in lab1 create two java source code files, Hipp.java and Happ.java. Hipp must be an application that opens a window (Frame) and Happ must be an applet to be shown in a web browser. The only thing required of these first programs is that they display the name(s) of their author(s).

Remember that to run an applet, you need a html-file, e.g. Happ.html. While testing your applet, it is more convenient to run it with appletviewer instead of using the browser:

appletviewer Happ.html
First time you use appletviewer it takes some time to start it but henceforth it will be faster than the browser.

Create a Prutt-button!

Create a file Pruttbutton.java with a public class Pruttbutton which extends the class Button with some attributes och behaviours. On a just created Pruttbutton the text PRUTT must be displayed but when you press the button, at least two things should happen: The text content changes, perhaps also the font size and the colour. Sound effects are not allowed! An object of your new class Pruttbuttonshould be added to Hipp as well as to Happ.

Finally, put the code of Pruttbutton in a subdirectory myPackage and add the proper lines to all java files so that Hipp and Happ both use the class Pruttbutton of the package myPackage (you may of course use any name of you choice for the package!).


Well done (student)......................................................................

applauds (teacher)............................................. on (date) ........................


Published by: <karlm@nada.kth.se>
Updated 2008-04-15
Technical support: <webmaster@nada.kth.se>