Search in sources :

Example 66 with Document

use of javax.swing.text.Document in project beast-mcmc by beast-dev.

the class RealNumberField method createDefaultModel.

protected Document createDefaultModel() {
    Document doc = new RealNumberField.RealNumberFieldDocument();
    doc.addDocumentListener(this);
    return doc;
}
Also used : Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Example 67 with Document

use of javax.swing.text.Document in project beast-mcmc by beast-dev.

the class WholeNumberField method createDefaultModel.

protected Document createDefaultModel() {
    Document doc = new WholeNumberFieldDocument();
    doc.addDocumentListener(this);
    return doc;
}
Also used : Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Example 68 with Document

use of javax.swing.text.Document in project enclojure by EricThorsen.

the class ClojureTemplatePanelVisual method updateTexts.

/**
 * Handles changes in the Project name and project directory,
 */
private void updateTexts(DocumentEvent e) {
    Document doc = e.getDocument();
    if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
        try {
            // Change in the project name
            String projectName = projectNameTextField.getText();
            String projectFolder = projectLocationTextField.getText();
            File tf = new File(projectFolder);
            String cp = tf.getCanonicalPath();
            if (cp.endsWith(File.separator))
                cp += projectName;
            cp += File.separatorChar + projectName;
            createdFolderTextField.setText(cp);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    // Notify that the panel changed
    panel.fireChangeEvent();
}
Also used : IOException(java.io.IOException) Document(javax.swing.text.Document) File(java.io.File)

Example 69 with Document

use of javax.swing.text.Document in project enclojure by EricThorsen.

the class ReplPanel method resultReceived.

public void resultReceived(JEditorPane pane, String result) {
    Document doc = (Document) pane.getDocument();
    try {
        if (pane != _replEditorPane)
            result = "\n" + result;
        doc.insertString(doc.getLength(), result, null);
        pane.setCaretPosition(doc.getLength());
    } catch (BadLocationException ex) {
        Logger.getLogger(ReplPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (pane == jEditorPaneOut && result.contains("Listening for transport dt_socket at address")) {
        // Listening for transport dt_socket at address: 58896
        String portString = result.substring(result.indexOf(":") + 1);
        _debugPort = Integer.parseInt(portString.trim());
    }
    if (pane == _replEditorPane) {
        _promptPos = _replEditorPane.getDocument().getLength();
        jTabbedPane1.setSelectedIndex(0);
        _undoManager.die();
    }
}
Also used : Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException)

Example 70 with Document

use of javax.swing.text.Document in project n2a by frothga.

the class SafeTextTransferHandler method exportToClipboard.

public void exportToClipboard(JComponent comp, Clipboard clipboard, int action) throws IllegalStateException {
    JTextComponent text = (JTextComponent) comp;
    int p0 = text.getSelectionStart();
    int p1 = text.getSelectionEnd();
    if (p0 != p1) {
        try {
            Document doc = text.getDocument();
            String srcData = doc.getText(p0, p1 - p0);
            StringSelection contents = new StringSelection(srcData);
            clipboard.setContents(contents, null);
            if (action == TransferHandler.MOVE)
                doc.remove(p0, p1 - p0);
        } catch (BadLocationException ble) {
        }
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Document (javax.swing.text.Document)72 BadLocationException (javax.swing.text.BadLocationException)35 DocumentEvent (javax.swing.event.DocumentEvent)10 DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)8 DocumentAdapter (com.intellij.ui.DocumentAdapter)7 HTMLDocument (javax.swing.text.html.HTMLDocument)7 ActionEvent (java.awt.event.ActionEvent)5 PlainDocument (javax.swing.text.PlainDocument)5 ActionListener (java.awt.event.ActionListener)4 File (java.io.File)4 IOException (java.io.IOException)3 FieldPanel (com.intellij.ui.FieldPanel)2 CheckBox (com.intellij.util.ui.CheckBox)2 Color (java.awt.Color)2 NumberFormat (java.text.NumberFormat)2 ParseException (java.text.ParseException)2 AbstractAction (javax.swing.AbstractAction)2 DocumentListener (javax.swing.event.DocumentListener)2 AbstractDocument (javax.swing.text.AbstractDocument)2 Element (javax.swing.text.Element)2