Package javax.swing.text

Examples of javax.swing.text.Document


    }

    try
    {
      inUpdate = true;
      final Document document = e.getDocument();
      final String queryName = document.getText(0, document.getLength());
      item.setQueryName(queryName);
      dialogModel.getQueries().fireItemChanged(item);
    }
    catch (BadLocationException e1)
    {
View Full Code Here


    private void update(DocumentEvent event)
    {
      String newValue = "";
      try
      {
        Document doc = event.getDocument();
        newValue = doc.getText(0, doc.getLength());
      }
      catch (BadLocationException e)
      {
        e.printStackTrace();
      }
View Full Code Here

    public int getLineOffset(int line) throws BadLocationException {
        return lineToOffset(line);
    }

    private int lineToOffset(int line) throws BadLocationException {
        Document d = getDocument();
        try {
            Element element = d.getDefaultRootElement().getElement(line - 1);
            if (element == null) {
                throw new BadLocationException("line " + line + " does not exist", -line);
            }
            return element.getStartOffset();
        } catch (ArrayIndexOutOfBoundsException aioobe) {
View Full Code Here

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        InputStream is
                            = u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

    Style defaultStyle = this.textPane.getStyle(defaultStyleName);
    // Style style = textPane.getStyle(typeName);
    // if (style == null || defaultStyle == null) {
    // System.out.println("Style is null.");
    // }
    Document doc = this.textPane.getDocument();
    try {
      doc.remove(0, doc.getLength());
      doc.insertString(doc.getLength(), "This is what an ", defaultStyle);
      doc.insertString(doc.getLength(), "annotation", this.currentStyle);
      doc.insertString(doc.getLength(), " of type ", defaultStyle);
      doc.insertString(doc.getLength(), this.currentTypeName, this.currentStyle);
      doc.insertString(doc.getLength(), " will look like.", defaultStyle);
    } catch (BadLocationException e) {
      // assert(false);
    }
    this.textPane.repaint();
  }
View Full Code Here

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        InputStream is
                            = u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

   * @param harness the test harness to use
   */
  public void test(TestHarness harness)
  {
    TestTextField tf = new TestTextField();
    Document doc = tf.createDefaultModel();
    harness.check(doc.getClass(), PlainDocument.class);
    harness.check(doc.getProperty("filterNewlines"), null);
  }
View Full Code Here

  public void test(TestHarness harness)
  {
    h2 = harness;
    TestTextField tf = new TestTextField();
    tf.setUI(new TestUI());
    Document doc = tf.createDefaultModel();
    tf.setDocument(doc);
  }
View Full Code Here

  class TestUI extends BasicTextFieldUI
  {
    protected void propertyChange(PropertyChangeEvent evt)
    {
      Document doc = ((JTextField)getComponent()).getDocument();
      h2.check (doc.getProperty("filterNewlines"), Boolean.TRUE);
      super.propertyChange(evt);
      h2.check (doc.getProperty("filterNewlines"), Boolean.TRUE);
    }
View Full Code Here

                    checkNextButtonState();
                }

                private void checkNextButtonState()
                {
                    Document doc = ((JTextField) pathComboBox.getEditor().getEditorComponent()).getDocument();
                    try
                    {
                        if (pathMatches(doc.getText(0, doc.getLength())))
                        {
                            getInstallerFrame().unlockNextButton(false);
                        }
                        else
                        {
View Full Code Here

TOP

Related Classes of javax.swing.text.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.