ptg7068951
Workshop 247
Q&A
Q. Is there a reason why the codebaseattribute should be used in an
applettag?
A. If all Java programs are grouped into their own subfolder using
codebase, this structure mightimprove the way a website is organized,
but there’s no other reason why using codebaseis better than omitting
it. The choice is a matter of personal preference.
Q. Why don’t applets have a main()method?
A. Applets don’t use main()because they have a more complicated life
cycle than applications. An application starts,runs until its work is com-
plete,and exits. An applet can be started and stopped multiple times
in a browser as the page on which it is contained is displayed.
If a user uses the back button to leave the page and then the forwards
button to return,the applet’s start()method is called again. If a pop-
up window that obscures the applet is closed,the applet’s paint()
method is called.
TheJAppletclass was designed to make these more complex interac-
tions work inside a browser.
Q. Have the Washington Generals ever beaten the Harlem Globetrotters?
A. The Generals have beaten the Globetrotters seven times over the
decades,most recently in 1971. Playing in Martin,Te n n e s s e e ,the
Generals won 100–99 on a shot by team owner Louis “Red” Klotz.
Although the Generals are known today for being patsies,they began in
1921 as the Philadelphia Sphas,a legitimate team that played in the
Eastern and American basketball leagues. The Sphas—an acronym for
South Philadelphia Hebrew Association—won 10 championships. Klotz
was a former Sphas player who bought the team and changed their
name to the Generals in 1952 when they became the permanent tour-
ing partner of Harlem’s famous team.
The 1971 victory ended a 2,495-game winning streak for the
Globetrotters.
Workshop
The following questions test your knowledge of applets.