You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
suppose in an applet, I've one button n one text field, and I've also a file where 10 words has been stored, now if anyone wants to check is the written word is correctly spelled or not by pressing the button, then how can I do this?
// <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.
}
}
thank you sooooo much
but I can't understand the following lines, can anyone plz explain it?
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.
}