use of javax.swing.text.PlainDocument in project GCViewer by chewiebug.
the class AutoCompletionTextField method createDefaultModel.
protected Document createDefaultModel() {
return new PlainDocument() {
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
final String text = this.getText(0, offs) + str;
List oldSuggestions = suggestions;
suggestions = recentResourceNamesModel.getResourceNamesStartingWith(text);
String appendString = "";
if (!suggestions.isEmpty()) {
final String suggestion = (String) suggestions.get(0);
appendString = suggestion.substring(text.length());
}
super.insertString(offs, str + appendString, a);
setCaretPosition(offs);
setSelectionStart(text.length());
setSelectionEnd(getLength());
if (!oldSuggestions.equals(suggestions)) {
comboBoxModel.fireContentsChanged();
}
}
public void remove(int offs, int len) throws BadLocationException {
super.remove(offs, len);
final List oldSuggestions = suggestions;
suggestions = recentResourceNamesModel.getResourceNamesStartingWith(AutoCompletionTextField.this.getText());
if (!oldSuggestions.equals(suggestions)) {
comboBoxModel.fireContentsChanged();
}
}
};
}
use of javax.swing.text.PlainDocument in project intellij-community by JetBrains.
the class JUnitConfigurable method installDocuments.
private void installDocuments() {
for (int i = 0; i < myTestLocations.length; i++) {
final LabeledComponent testLocation = getTestLocation(i);
final JComponent component = testLocation.getComponent();
final ComponentWithBrowseButton field;
Object document;
if (component instanceof TextFieldWithBrowseButton) {
field = (TextFieldWithBrowseButton) component;
document = new PlainDocument();
((TextFieldWithBrowseButton) field).getTextField().setDocument((Document) document);
} else if (component instanceof EditorTextFieldWithBrowseButton) {
field = (ComponentWithBrowseButton) component;
document = ((EditorTextField) field.getChildComponent()).getDocument();
} else {
field = myPatternTextField;
document = new PlainDocument();
((TextFieldWithBrowseButton) field).getTextField().setDocument((Document) document);
}
myBrowsers[i].setField(field);
if (myBrowsers[i] instanceof MethodBrowser) {
final EditorTextField childComponent = (EditorTextField) field.getChildComponent();
((MethodBrowser) myBrowsers[i]).installCompletion(childComponent);
document = childComponent.getDocument();
}
myModel.setJUnitDocument(i, document);
}
}
use of javax.swing.text.PlainDocument in project intellij-community by JetBrains.
the class StepicStudyOptions method createUIComponents.
private void createUIComponents() {
Document doc = new PlainDocument();
myPasswordField = new JPasswordField(doc, null, 0);
}
Aggregations