30 lines
649 B
Java
30 lines
649 B
Java
|
|
package gui;
|
||
|
|
|
||
|
|
import javax.swing.JTextField;
|
||
|
|
import javax.swing.text.Document;
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An text field with the ability to set a list of words to attempt to auto-complete from.
|
||
|
|
*/
|
||
|
|
public class CompletingField extends JTextField
|
||
|
|
{
|
||
|
|
private static final long serialVersionUID = 1L;
|
||
|
|
private CompletingDocument document;
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected Document createDefaultModel()
|
||
|
|
{
|
||
|
|
document = new CompletingDocument(this);
|
||
|
|
return document;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param fileName The name of a file to read a list of auto-complete candidates from
|
||
|
|
*/
|
||
|
|
public void setWordList(final String fileName)
|
||
|
|
{
|
||
|
|
document.setWordList(fileName);
|
||
|
|
}
|
||
|
|
}
|