Java Reference
In-Depth Information
The applet class is shown in Listing 9.10.
L ISTING 9.10
The AnApplet Applet Class
package com.marinilli.b2.c9;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class AnApplet extends JApplet {
String name;
JLabel jLabel = new JLabel();
JButton jButton = new JButton();
public AnApplet() {
}
public void init() {
try {
name = getParameter(“name”);
if (name==null)
name=”a param.”;
jLabel.setForeground(Color.yellow);
jLabel.setText(“Hello Applet”);
jButton.setForeground(Color.red);
jButton.setText(“I am a Button”);
setBackground(SystemColor.desktop);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(jLabel, null);
getContentPane().add(jButton, null);
getContentPane().add(new JLabel(name), null);
}
catch(Exception e) {
e.printStackTrace();
}
}
public void start() {
}
public void stop() {
}
public void destroy() {
}
public String getAppletInfo() {
return “Some Applet Information”;
}
}
Search WWH ::




Custom Search