Thread: spell check
View Single Post
  #2 (permalink)  
Old 12-06-2007, 02:21 AM
hardwired hardwired is online now
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
// <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. } }
Reply With Quote