This is
the complete source code of the applet seen on the demonstration
page.
The code necessary to implement JSpell in your applet is highlighted.
To return
to the JSpell demo site, click here.
More examples can be found in the JSpell Java SDK Wiki.
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.jspell.domain.*;
import com.jspell.domain.net.*;
import com.jspell.gui.*;
public class JSpellAppletTestServlet extends
Applet implements ActionListener
{
Button checkIt;
TextArea textArea;
JSpellDictionaryServlet jdServlet;
JSpellParser jsp;
JSpellErrorHandler handler;
public void init()
{
checkIt=new Button("Check");
checkIt.addActionListener(this);
textArea=new TextArea("Type your text here",24,80);
setLayout(new BorderLayout());
add("North",checkIt);
add("Center",textArea);
jdServlet=new
JSpellDictionaryServlet();
jdServlet.setURL("http://www.jspell.com/servlet/JSpellServlet");
try {
jdServlet.open();
} catch (JSpellException j)
{
Messages.error(j);
}
jsp=new JSpellParser(jdServlet);
handler=new JSpellErrorHandler(jsp,new JSpellTextComponentWrapper(textArea));
handler.setFrame(this);
handler.init();
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==checkIt)
{
if(!handler.getBusy())
handler.check();
}
}
} |