|
|
Java Student Project |
||
|
|||
| Date & Time | |||
|
|
|
||
| Ability Level: | Beginning | ||
|
|
|
||
| Estimated Time: | 50 minutes | ||
|
|
|
||
| Objectives: |
|
||
|
|
|
||
| Materials & Resources: |
|
||
|
|
|
||
| Overview: | Create an applet that displays the date and time in a TextField with the Label "Today is" when the user clicks a Button.
|
||
|
|
|
||
| Instructions: |
1. Use the template
below to create your button applet
|
||
|
|
|||
| Hints: | 1. When you create an applet, you do the
following: * Create a project and write Java programming code in files with extensions of .java, just like when you write an application. * Design an HTML document that includes a statement to call your compiled Java class. * Build the project to compile the applet's .java files into bytecode with extensions of .class, just like when you write an application. * Open the HTML document in a Web browser or in AppletViewer. 2. Visual J++ assigns a file extension of .htm to the HTML documents it creates. 3. HTML is not case-sensitive, the Java programming language is case-sensitive. 4. HTML documents are text documents containing formatting instructions, called tags, along with the text that is to be displayed on a Web page. 5. The <APPLET> tag consists of three parts: * CODE = and the name of the compiled applet you are calling * WIDTH = and the width of the applet on the screen measured in pixels * HEIGHT = and the height of the applet on the screen measured in pixels 6. Pixels are the picture elements, or tiny dots of light that make up the image on your video monitor. The maximum size of your applets should be approximately 600 x 400 pixels to make sure that most people can see the entire applet as screens have different displays. 7. Visual Studio has a built-in HTML editor called the HTML
Editor window, which is similar to the Text Editor window used
for creating Java code files. The HTML Editor window contains
three views for working with HTML documents: Design view - used
for graphic creations, Source view -- allows editing of the raw
HTML code, and Quick View -- used to display an HTML document.
The different views may be accessed through the View Menu. 11. Applets begin the same way as Java applications, but they
also must include the words extends Applet. The keyword extends
indicates that your applet will build upon, or inherit, the
traits of the Applet class defined in the java.applet package. 22. Class must be declared with the name and extends Applet to
indicate Applet is being
created. 23. A method (like a function in C++) is needed for each
constructor, which is a block of code whenever a new object is
created. Open and close braces enclose the code. 24. To use graphics the method must be declared. 25. There are many commands available such as g.setFont, g.setColor, and g.drawString which should be used in the paint method. 26. The pipe character ( | ) is used for "or" and allows the use of two different font sets. The pipe is generally the shift of the backslash on most keyboards. 27. Color uses red, green, blue sequentially. The maximum
color is 255 and the minimum is 0. Three parameters are
necessary.
|
||