For now this has a sample dictionary of words, but later I will allow the user to provide their own dictionary.
import java.io.*;
public class testReader
{
private String[] auto = {"lorem", "ipsum", "dolor", "sunglasses", "friend", "time", "flies", "like", "an", "arrow", "daisy", "bell", "the", "quick", "brown", "fox", "jumps", "over", "lazy", "yellow", "dog"};
private String guess = "";
public testReader()
{
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String strLine;
while ((strLine = reader.readLine()) != null)
{
while (strLine.length() >= 3)
{
for (String com : auto)
{
if ((com.substring(0, 2)).equals(strLine.substring(0, 2)))
{
myWindow.guess(com);
// if 'yes'
myWindow.guess(com);
// else
// myWindow.guess("unknown");
} else {
myWindow.guess("unknown");
}
}
}
}
} catch (Exception e) {}
}
public static void main(String[] args) throws Exception
{
new testReader();
}
}
Anyway, this code is not runnable. The VM just freezes when I try to execute this code... Although it does not work right now, it is supposed to get user input (while a word is being typed) compare it to the dictionary words, and guess (based on the first three letters typed) which word the user is going to type at which time the program displays the guess on a window I made (dummy window myWindow).. I also do not want the text area on myWindow, or moved anywhere else.
How can I fix this code so that it will work as explained above?