@Override
    public void run() {

        //
        // Get the updated text field
        //
        String text = nameField.getText();

        //
        // Suggest a name if the text has changed.  The new name will start
        // with the characters entered so far and the caret will be
        // positioned at the start of the additional characters (which will
        // be selected and highlighted).
        //
        // No suggestion will be made if the entered text matches a name in
        // the suggestion list or if there is no name starting with the
        // entered characters.
        //
        if (!text.equals(currentText)) {
            Iterator<String> nameIterator = nameList.iterator();
            while (nameIterator.hasNext()) {
                String name = nameIterator.next();
                if (name.equals(text))
                    break;

                if (name.startsWith(text)) {
                    nameField.setText(name);
                    nameField.setCaretPosition(name.length());
                    nameField.moveCaretPosition(text.length());
                    break;
                }

                if (name.compareTo(text) > 0)
                    break;
            }

            currentText = text;
        }

        //
        // Allow document events to be processed
        //
        ignoreEvents = false;
    }