Search in sources :

Example 1 with Document

use of javax.swing.text.Document in project hackpad by dropbox.

the class ConsoleTextArea method returnPressed.

synchronized void returnPressed() {
    Document doc = getDocument();
    int len = doc.getLength();
    Segment segment = new Segment();
    try {
        doc.getText(outputMark, len - outputMark, segment);
    } catch (javax.swing.text.BadLocationException ignored) {
        ignored.printStackTrace();
    }
    if (segment.count > 0) {
        history.add(segment.toString());
    }
    historyIndex = history.size();
    inPipe.write(segment.array, segment.offset, segment.count);
    append("\n");
    outputMark = doc.getLength();
    inPipe.write("\n");
    inPipe.flush();
    console1.flush();
}
Also used : Document(javax.swing.text.Document) Segment(javax.swing.text.Segment)

Example 2 with Document

use of javax.swing.text.Document in project OpenAM by OpenRock.

the class TableJPanel method clearAll.

public void clearAll() {
    testsjTable.setEnabled(false);
    TestsTableModel model = (TestsTableModel) testsjTable.getModel();
    model.removeAll();
    Document doc = messagejEditorPane.getDocument();
    try {
        doc.remove(0, doc.getLength());
    } catch (Exception ex) {
        //ex.printStackTrace();
        System.out.println("Exception in TableJPanel :" + ex.getMessage());
    }
    testsjTable.setEnabled(true);
}
Also used : TestsTableModel(com.sun.identity.diagnostic.base.core.ui.gui.table.TestsTableModel) HTMLDocument(javax.swing.text.html.HTMLDocument) Document(javax.swing.text.Document)

Example 3 with Document

use of javax.swing.text.Document in project pcgen by PCGen.

the class InfoPane method setText.

public void setText(String text) {
    //This is done so the vertical scroll bar goes back up to the top when the text is changed
    EditorKit kit = textPane.getEditorKit();
    Document newDoc = kit.createDefaultDocument();
    try {
        kit.read(new StringReader(text), newDoc, 0);
    } catch (IOException | BadLocationException ex) {
        throw new UnreachableError(ex);
    }
    textPane.setDocument(newDoc);
}
Also used : EditorKit(javax.swing.text.EditorKit) StringReader(java.io.StringReader) IOException(java.io.IOException) UnreachableError(pcgen.base.lang.UnreachableError) Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException)

Example 4 with Document

use of javax.swing.text.Document in project intellij-community by JetBrains.

the class RequiredAttributesInspection method createOptionsPanel.

@Override
@Nullable
public JComponent createOptionsPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    FieldPanel additionalAttributesPanel = new FieldPanel(InspectionsBundle.message("inspection.javadoc.html.not.required.label.text"), InspectionsBundle.message("inspection.javadoc.html.not.required.dialog.title"), null, null);
    panel.add(additionalAttributesPanel, BorderLayout.NORTH);
    additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            try {
                final String text = document.getText(0, document.getLength());
                if (text != null) {
                    myAdditionalRequiredHtmlAttributes = text.trim();
                }
            } catch (BadLocationException e1) {
                LOG.error(e1);
            }
        }
    });
    additionalAttributesPanel.setText(myAdditionalRequiredHtmlAttributes);
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Document(javax.swing.text.Document) FieldPanel(com.intellij.ui.FieldPanel) BadLocationException(javax.swing.text.BadLocationException) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Document

use of javax.swing.text.Document in project intellij-community by JetBrains.

the class StepicStudyOptions method createUIComponents.

private void createUIComponents() {
    Document doc = new PlainDocument();
    myPasswordField = new JPasswordField(doc, null, 0);
}
Also used : PlainDocument(javax.swing.text.PlainDocument) Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Aggregations

Document (javax.swing.text.Document)166 BadLocationException (javax.swing.text.BadLocationException)84 DocumentEvent (javax.swing.event.DocumentEvent)15 DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)15 HTMLDocument (javax.swing.text.html.HTMLDocument)14 Element (javax.swing.text.Element)13 AbstractDocument (javax.swing.text.AbstractDocument)11 PlainDocument (javax.swing.text.PlainDocument)10 DocumentAdapter (com.intellij.ui.DocumentAdapter)8 StringReader (java.io.StringReader)8 Matcher (java.util.regex.Matcher)8 JTextComponent (javax.swing.text.JTextComponent)8 ActionEvent (java.awt.event.ActionEvent)7 DocumentListener (javax.swing.event.DocumentListener)7 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)7 IOException (java.io.IOException)6 PatternSyntaxException (java.util.regex.PatternSyntaxException)6 Caret (javax.swing.text.Caret)5 Highlighter (javax.swing.text.Highlighter)5 StyledDocument (javax.swing.text.StyledDocument)5