// <applet code="SpellCheck" width="300" height="200"></applet>
// use: >appletviewer SpellCheck.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;;
public class SpellCheck extends JApplet implements ActionListener {
JTextField textField;
String[] words = new String[10];
public void init() {
// read file and store the 10 "words" in the words array.
textField = new JTextField(16);
textField.addActionListener(this);
JPanel first = new JPanel();
first.add(textField);
JButton button = new JButton("check");
button.addActionListener(this);
JPanel last = new JPanel();
last.add(button);
getContentPane().add(first, BorderLayout.PAGE_START);
getContentPane().add(last, BorderLayout.PAGE_END);
}
public void actionPerformed(ActionEvent e) {
String text = textField.getText();
System.out.println("text = " + text);
checkSpelling(text);
}
private void checkSpelling(String s) {
// Run through the words array and test the
// variable "s" against each word in the list
// that begins with the same first letter as
// "s" has. Print the results of your test.
}
}