Package javax.swing.text

Examples of javax.swing.text.Document


        settings.setNrDays(-1);
        SearchHelper.search(mInfoEP, settings, null, true);
      }

      private String getLink(int pos, JEditorPane html) {
        Document doc = html.getDocument();
        if (doc instanceof HTMLDocument) {
          HTMLDocument hdoc = (HTMLDocument) doc;
          Element e = hdoc.getCharacterElement(pos);
          AttributeSet a = e.getAttributes();
          AttributeSet anchor = (AttributeSet) a.getAttribute(HTML.Tag.A);
View Full Code Here


   * Calls revalidate() and repaint()
   */
  private void setMetrics() {
    Font refFont = null;
  
    Document doc = this.textComponent.getDocument();
    if(doc instanceof DefaultStyledDocument) {
        DefaultStyledDocument myDoc = (DefaultStyledDocument)doc;
        refFont = myDoc.getFont(myDoc.getDefaultRootElement().getElement(0)
          .getAttributes());
    } else {
View Full Code Here

     */
    public void propertyChange(final PropertyChangeEvent evt)
    {
      if (FormValidator.DOCUMENT_PROPERTY_NAME.equals(evt.getPropertyName()))
      {
        final Document olddoc = (Document) evt.getOldValue();
        olddoc.removeDocumentListener(this);
        final Document newdoc = (Document) evt.getOldValue();
        newdoc.addDocumentListener(this);
      }
    }
View Full Code Here

  public Object convert(final Element source, final Object value)
  {
    try
    {
      final Document doc = RichTextConverterUtilities.parseDocument(editorKit, value);
      if (doc == null)
      {
        return value;
      }

      final Element element = process(doc.getDefaultRootElement());
      return RichTextConverterUtilities.convertToBand(StyleKey.getDefinedStyleKeys(), source, element);
    }
    catch (Exception e)
    {
      return value;
View Full Code Here

    }

    final InputStream inputStream = RichTextConverterUtilities.convertToStream(value);
    if (inputStream != null)
    {
      Document doc = editorKit.createDefaultDocument();
      editorKit.read(inputStream, doc, 0);
      return doc;
    }

    final Reader reader = RichTextConverterUtilities.convertToReader(value);
    if (reader != null)
    {
      final Document doc = editorKit.createDefaultDocument();
      editorKit.read(reader, doc, 0);
      return doc;
    }

    return null;
View Full Code Here

  public Object convert(final Element source, final Object value)
  {
    try
    {
      final Document doc = RichTextConverterUtilities.parseDocument(editorKit, value);
      if (doc == null)
      {
        return value;
      }

      final Element element = process(doc.getDefaultRootElement());
      final Band band = RichTextConverterUtilities.convertToBand(StyleKey.getDefinedStyleKeys(), source, element);
      band.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, "inline");
      return band;
    }
    catch (Exception e)
View Full Code Here

        }
    }

    public void setIPString( String ipString )
    {
        Document doc = part1.getDocument();
        try
        {
            doc.remove( 0, doc.getLength() );
            doc.insertString( 0, ipString, new SimpleAttributeSet() );
        }
        catch ( BadLocationException exp )
        {
        }
    }
View Full Code Here

        if ( nextTF == null )
        {// drop string
            return;
        }
        nextTF.requestFocus();
        Document doc = nextTF.getDocument();
        try
        {
            doc.remove( 0, doc.getLength() );
            doc.insertString( 0, nextTextFieldStr, new SimpleAttributeSet() );
        }
        catch ( BadLocationException exp )
        {
        }
    }
View Full Code Here

    }

    InputStream stream = null;
    try {
      stream = rawDocument.getContentAsStream();
      Document doc = mRTFEditorKit.createDefaultDocument();
      mRTFEditorKit.read(stream, doc, 0);

      String cleanedContent = doc.getText(0, doc.getLength());
      setCleanedContent(cleanedContent);
    }
    catch (Exception exc) {
      throw new RegainException("Reading RTF dokument failed: "
        + rawDocument.getUrl(), exc);
View Full Code Here

   * @param string  The String to be appended.
   * @param saSet    The SimpleAttributeSet to be used for for the string.
   */
  private void append(String string, SimpleAttributeSet saSet)
  {
    Document document = getStyledDocument();
    try
    {
         /////////////////////////////////////////////////////////////////////////////////
         // Checks if the former message should be highlighted in a 'history' color.
         if (document.getLength() >= _lastLength && null != _lastMessage)
      {
            SimpleAttributeSet historySaSet = _saSetHistoryBySaSet.get(_lastSASet);
            document.remove(_lastLength, _lastMessage.length());
            document.insertString(document.getLength(), _lastMessage, historySaSet);
      }
         //
         ///////////////////////////////////////////////////////////////////////////////////

         _lastLength = document.getLength();
      _lastMessage = string;
      _lastSASet = saSet;

      document.insertString(document.getLength(), string, saSet);
    }
    catch (BadLocationException ble)
    {
      s_log.error("Error appending text to MessagePanel document.", ble);
    }
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.