Quick Page Reference...
Project Sample: TextBurst
The TextBurst project contains source code for an applet to show text
zooming smaller and bigger to look like text bursting towards and away from you.
The colour is rotated randomly throughout the three colours (red, green and
blue) that combine to make the complete palette of standard available colours.
The key details of the project are as follows:-
- Located in the samples\TextBurst directory from the installation
directory of the QuickCup application - e.g. if QuickCup was
installed in C:\Program Files\Arctan Computer Ventures Ltd\QuickCup
then the directory would be C:\Program Files\Arctan Computer Ventures
Ltd\QuickCup\Samples\TextBurst
- Project filename is: TextBurst.qjp
- Two files are attached to the project:-
- TextBurst.htm - the web page in which the applet is embedded
- TextBurst.java - the java source code for the TextBurst
program.
- Three parameters are passed from the HTML web page to the Java program:-
- type: Default value is QuickCup Sample Project - TextBurst v1.0
- this is the text that will be shown bursting back and forth.
- maxfont: The maximum point size for the font. Default
value is 22
- bgcolor: The background colour for the applet. Default value is
#FFFFC6 which is a light-yellow (RGB value).
- Classes defined are as follows:-
- TextBurst: extends JApplet, so is the applet class.
Implements ActionListener which links the timer to the actionPerformed
method in the class which paces the bursting animation to work every
50ms.
Methods for this class are as follows:-
- init: Sets up the variables and timer, reads parameters
from the web page. Run once when the applet is created.
- start: Starts the timer if it is not running. Run either
after the applet is created, or if the applet is reactivated after,
for example, being minimized.
- stop: Stops the timer if the applet is deactivated - e.g.
by minimizing the browser inside which the applet is running.
- actionPerformed: Called by the timer every 50ms. Increases
or decreases the font size and the red, green and blue parts of the
text colour.
- getAppletInfo: Gives basic details about the application,
available from the Applet Viewer, possibly available in future
version of the JVM.
Project Sample: Pairs
The Pairs project contains source code for a game applet. It shows a
grid of buttons, each of which hides a number. Click on two buttons to try and
match the numbers. When all pairs have been revealed, the game is complete.
Simple scoring based on the number of attempts and pairs found/remaining is
shown at the bottom of the screen.
As two class files are generated by this project, they have been packaged
into a JAR file using the
button after compiling. The compile files
have then been removed from the directory to ensure they are not being used
during testing.
The HTML file reflect this by including the following tag to specify the JAR
file:-
<PARAM NAME="archive" VALUE="Pairs.jar">
The key details of the project are as follows:-
- Located in the samples\Pairs directory from the installation
directory of the QuickCup application - e.g. if QuickCup was
installed in C:\Program Files\Arctan Computer Ventures Ltd\QuickCup
then the directory would be C:\Program Files\Arctan Computer Ventures
Ltd\QuickCup\Samples\Pairs
- Project filename is: Pairs.qjp
- Two files are attached to the project:-
- Pairs.htm - the web page in which the applet is embedded
- Pairs.java - the java source code for the TextBurst
program.
- Two parameters are passed from the HTML web page to the Java program. Note
that the two multiplied together need to produce an even number in order to
give all pairs of buttons:-
- squaresAcross: The number of squares across to create.
- squaresDown: The number of squares down to create.
- Classes defined are as follows:-
- Pairs: extends JApplet, so is the applet class.
Implements ActionListener which picks up button clicks and
directs them to the actionPerformed method.
Methods for this class are as follows:-
- init: Sets up the variables and random numbers, and places
buttons in to the GridLayout, reads parameters from the web page.
Run once when the applet is created.
- randomOrdering: Randomizes the numbers behind the buttons
(stored in the buttonValues array).
- updateScore: Updates the text of the scoreLabel
label that shows the current score. Scores are held in the following
variables: pairsRemaining, pairsFound, and attempts.
- actionPerformed: Called by each of the buttons (added on
line 93) when the button is clicked. The ActionEvent class
passed to this method when the button is clicked, contains a method
called getSource which gives the button from which the click
event was initiated. The array index is held within the button name,
and matches the array index of the value behind the button, held in
the buttonValues array. If the last two clicks' values match,
this is a match, so update the scoring accordingly. If the number
remaining is zero, the game has finished.
- getAppletInfo: Gives basic details about the application,
available from the Applet Viewer, possibly available in future
version of the JVM.
- Pairs$1: An anonymous inner class defined on line 96-103. This
is used to define a mouse listener for each of the buttons to give a
different border for the button when the mouse hovers over it, using the
mouseEntered method to implement a raised bevel border, and mouseExited
to implement the standard etched border.
(c) Copyright 2001-2 Arctan
Computer Ventures Ltd. All Rights Reserved.
If you have any issues regarding this on-line help, please contact the
author by clicking here.
This Page was last updated: 26 April 2002 16:03