Java Applet Programming


History

What is Java Applet

Java is safe

Java Development Kit

Java Applet Development Environment

Basics of Applet Programming

Operators and Their Precedence

The following table shows the precedence assigned to Java's operators. The operators in this table are listed in precedence order: the higher in the table an operator appears, the higher its precedence. Operators with higher precedence are evaluated before operators with a relatively lower precedence. Operators on the same line have equal precedence.
postfix operators [] . (params) expr++ expr--
unary operators ++expr --expr +expr -expr ~ !
creation or cast new (type)expr
multiplicative * / %
additive + -
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
conditional ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=

When operators of equal precendence appear in the same expression, some rule must govern which is evaluated first. In Java, all binary operators except for the assignment operators are evaluated in left to right order. Assignment operators are evaluated right to left.

Control Flow Statements

A statement such as the while statement is a control flow statement, that is, it determines the order in which other statements are executed. Besides while, similar to C, the Java language supports several other control flow statements (except the exception handling), including:

Statement Keyword
decision making  if-else, switch-case
loop  for, while, do-while 
exception  try-catch-finally, throw
miscellaneous  break, continue, label: , return 

Note: Although goto is a reserved word, currently the Java language does not support the goto statement.

Handling errors with Expression using Try, Catch, and Throw

Basic Steps:

Abstract Window Toolkit (AWT)

Tutorial from Netscape

Using AWT Components: http://owl.uccs.edu/~cs301/java/awt/oldui/components/using.html

Layout the Components in a container: http://owl.uccs.edu/~cs301/java/awt/oldui/layout/index.html

Note that there are new GUI packages such swing and Java 2D graphics recommended by Netscape. They are great for making Java applications with GUI, but there are still a lot of browsers do not support that. They require JDK1.2 compatible viewer or Java plug in.

"Java Plug-in software enables enterprise customers to direct Java applets or JavaBeansTM components on their intranet web pages to run using Sun's Java Runtime Environment (JRE), instead of  the browser's default Java runtime. This enables an enterprise to deploy Java applets that take full advantage of the latest capabilities and features of the Java platform and be assured that they will run reliably and consistently. " -- http://java.sun.com/applets/index.html.
 

Using JFC/SWING to create GUI

The swing components in Java Foundation Classes (JFC) is the new package in JDK1.1 and JDK1.2 for supporting GUI design in Java applications and applets.
It provides much more features to those of AWT. For examples,


Unfortunately, Sun recommends that SWING and AWT components not mix.  Their drawing sequence are basically different.  "Heavyweight" AWT components such as menu, scrollpane, canvas, and panel always draw on top of "lightweight" SWING components.

Tutorial on using GridBagLayout.

Note that the current tutorial on java.sun.com is going through major revision.  Some web pages, such as the layout manager tutorial, event hung the whole browser. Use them with caution.  12/3/98.
 

Example for using GridBagLayout and submit data to a CGI script

http://owl.uccs.edu/~cs301/java/Register.html and Register.java

Goal:

How we arrange the GridBagLayout using GridBagConstraints:

Basic steps for using the applet:

Example for plotting the cookie sale of a particular year.

http://owl.uccs.edu/~cs301/java/plotdemo/CookieSales.html and CookieSales.java.

Goal:

Here are the basic steps for using the Applet:

Reasons for Extending Canvas Class

Important Site

Good References

Debug Java Applet