Codota Logo
DefaultStyledDocument.setCharacterAttributes
Code IndexAdd Codota to your IDE (free)

How to use
setCharacterAttributes
method
in
javax.swing.text.DefaultStyledDocument

Best Java code snippets using javax.swing.text.DefaultStyledDocument.setCharacterAttributes (Showing top 20 results out of 315)

  • Common ways to obtain DefaultStyledDocument
private void myMethod () {
DefaultStyledDocument d =
  • Codota Iconnew DefaultStyledDocument()
  • Codota IconStyleContext styleContext;new DefaultStyledDocument(styleContext)
  • Smart code suggestions by Codota
}
origin: stanfordnlp/CoreNLP

private void removeTags() {
 if (editorPane.getContentType().equals("text/html")) {
  editorPane.setText(htmlContents);
  editorPane.revalidate();
  editorPane.repaint();
 } else {
  DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument();
  SimpleAttributeSet attr = new SimpleAttributeSet();
  StyleConstants.setForeground(attr, Color.BLACK);
  StyleConstants.setBackground(attr, Color.WHITE);
  doc.setCharacterAttributes(0, doc.getLength(), attr, false);
 }
 saveTaggedAs.setEnabled(false);
}
origin: stanfordnlp/CoreNLP

private void removeTags() {
 if (editorPane.getContentType().equals("text/html")) {
  if (htmlContents != null) {
   editorPane.setText(htmlContents);
  }
  editorPane.revalidate();
  editorPane.repaint();
 } else {
  DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument();
  SimpleAttributeSet attr = new SimpleAttributeSet();
  StyleConstants.setForeground(attr, Color.BLACK);
  StyleConstants.setBackground(attr, Color.WHITE);
  doc.setCharacterAttributes(0, doc.getLength(), attr, false);
 }
 saveTaggedAs.setEnabled(false);
}
origin: stanfordnlp/CoreNLP

try {
 String entity = finalText.substring(start, end);
 doc.setCharacterAttributes(start, entity.length(), attSet, false);
} catch (Exception ex) {
 throw new RuntimeException(ex);
origin: groovy/groovy-core

  styledDocument.setCharacterAttributes(matchEnd,
                     offset - matchEnd,
                     defaultStyle,
styledDocument.setCharacterAttributes(offset,
                   matchEnd - offset,
                   style, true);
styledDocument.setCharacterAttributes(matchEnd,
                   checkPoint - matchEnd,
                   defaultStyle,
origin: stanfordnlp/CoreNLP

try {
 String entity = finalText.substring(start, end);
 doc.setCharacterAttributes(start, entity.length(), attSet, false);
} catch (Exception ex) {
 log.err(ex);
origin: stackoverflow.com

  if (wordR == after || String.valueOf(text.charAt(wordR)).matches("\\W")) {
    if (text.substring(wordL, wordR).matches("(\\W)*(private|public|protected)"))
      setCharacterAttributes(wordL, wordR - wordL, attr, false);
    else
      setCharacterAttributes(wordL, wordR - wordL, attrBlack, false);
    wordL = wordR;
  setCharacterAttributes(before, after - before, attr, false);
} else {
  setCharacterAttributes(before, after - before, attrBlack, false);
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Searches for a quote token.
 * 
 * @param content the content to search
 * @param startOffset the start of the search
 * @param endOffset the end of the search
 * @return the new position
 */
protected int getQuoteToken(String content, int startOffset, int endOffset) {
 String quoteDelimiter = content.substring(startOffset, startOffset + 1);
 String escapeString = escapeQuote(quoteDelimiter);
 int index;
 int endOfQuote = startOffset;
 // skip over the escape quotes in this quote
 index = content.indexOf(escapeString, endOfQuote + 1);
 while ((index > -1) && (index < endOffset)) {
  endOfQuote = index + 1;
  index = content.indexOf(escapeString, endOfQuote);
 }
 // now find the matching delimiter
 index = content.indexOf(quoteDelimiter, endOfQuote + 1);
 if ((index < 0) || (index > endOffset)) {
  endOfQuote = endOffset;
 } else {
  endOfQuote = index;
 }
 m_Self.setCharacterAttributes(startOffset, endOfQuote - startOffset + 1,
  DEFAULT_STRING, false);
 return endOfQuote + 1;
}
origin: Waikato/weka-trunk

/**
 * Searches for a quote token.
 * 
 * @param content the content to search
 * @param startOffset the start of the search
 * @param endOffset the end of the search
 * @return the new position
 */
protected int getQuoteToken(String content, int startOffset, int endOffset) {
 String quoteDelimiter = content.substring(startOffset, startOffset + 1);
 String escapeString = escapeQuote(quoteDelimiter);
 int index;
 int endOfQuote = startOffset;
 // skip over the escape quotes in this quote
 index = content.indexOf(escapeString, endOfQuote + 1);
 while ((index > -1) && (index < endOffset)) {
  endOfQuote = index + 1;
  index = content.indexOf(escapeString, endOfQuote);
 }
 // now find the matching delimiter
 index = content.indexOf(quoteDelimiter, endOfQuote + 1);
 if ((index < 0) || (index > endOffset)) {
  endOfQuote = endOffset;
 } else {
  endOfQuote = index;
 }
 m_Self.setCharacterAttributes(startOffset, endOfQuote - startOffset + 1,
  DEFAULT_STRING, false);
 return endOfQuote + 1;
}
origin: chatty/chatty

/**
 * Removes any prior style changes used to highlight a search result.
 */
private void clearSearchResult() {
  doc.setCharacterAttributes(0, doc.getLength(), styles.clearSearchResult(), false);
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Searches for a keyword token.
 * 
 * @param content the content to search in
 * @param startOffset the position to start the search fromm
 * @param endOffset the position to end the search
 * @return the new position
 */
protected int getOtherToken(String content, int startOffset, int endOffset) {
 int endOfToken = startOffset + 1;
 while (endOfToken <= endOffset) {
  if (isDelimiter(content.substring(endOfToken, endOfToken + 1))) {
   break;
  }
  endOfToken++;
 }
 String token = content.substring(startOffset, endOfToken);
 // see if this token has a highlighting format associated with it
 MutableAttributeSet attr = getKeywordFormatting(token);
 if (attr != null) {
  m_Self.setCharacterAttributes(startOffset, endOfToken - startOffset,
   attr, false);
 }
 return endOfToken + 1;
}
origin: Waikato/weka-trunk

/**
 * Searches for a keyword token.
 * 
 * @param content the content to search in
 * @param startOffset the position to start the search fromm
 * @param endOffset the position to end the search
 * @return the new position
 */
protected int getOtherToken(String content, int startOffset, int endOffset) {
 int endOfToken = startOffset + 1;
 while (endOfToken <= endOffset) {
  if (isDelimiter(content.substring(endOfToken, endOfToken + 1))) {
   break;
  }
  endOfToken++;
 }
 String token = content.substring(startOffset, endOfToken);
 // see if this token has a highlighting format associated with it
 MutableAttributeSet attr = getKeywordFormatting(token);
 if (attr != null) {
  m_Self.setCharacterAttributes(startOffset, endOfToken - startOffset,
   attr, false);
 }
 return endOfToken + 1;
}
origin: de.sciss/abc4j

/** Enables/disables coloring of the text.
 * @param coloring <TT>true</TT> if text coloring should be enabled,
 * <TT>false</TT> otherwise.
 * @see #isColoringEnabled() */
public void setColoringEnable(boolean coloring)
{
 m_enableColoring = coloring;
 if (m_enableColoring)
  m_refresher.redrawTune();
 else
 {
   ((DefaultStyledDocument)getDocument()).setCharacterAttributes(
 0,getDocument().getEndPosition().getOffset(),m_defaultStyle, true);
  //setSelectedTextColor(SELECTION_FOREGROUND_COLOR);
  //setSelectionColor(SELECTION_BACKGROUND_COLOR);
 }
}
origin: nz.ac.waikato.cms.weka/weka-stable

 || isMultiLineComment()
 || startingMultiLineComment(content, startOffset, endOffset)) {
 m_Self.setCharacterAttributes(startOffset, endOffset - startOffset + 1,
  DEFAULT_COMMENT, false);
 return;
.setCharacterAttributes(startOffset, lineLength, DEFAULT_NORMAL, true);
m_Self.setCharacterAttributes(index, endOffset - index + 1,
 DEFAULT_COMMENT, false);
endOffset = index - 1;
origin: chatty/chatty

    /**
     * Changes the background color of the given line and scrolls to it if
     * primary is true.
     * 
     * @param element The line to highlight
     * @param primary If true, then it uses a different background color and
     * scrolls to the line
     */
    private void highlightLine(Element element, boolean primary) {
      int startOffset = element.getStartOffset();
      int endOffset = element.getEndOffset() - 1;
      int length = endOffset - startOffset;
//            MutableAttributeSet style = primary && !subduedHl ? styles.searchResult2(primary) : styles.searchResult(primary);
      MutableAttributeSet style = primary ? styles.searchResult2(primary) : styles.searchResult(primary);
      doc.setCharacterAttributes(startOffset, length, style, false);
      if (primary) {
        scrollManager.scrollToOffset(startOffset);
      }
    }
    
origin: chatty/chatty

doc.setCharacterAttributes(start, length, style, false);
origin: chatty/chatty

doc.setCharacterAttributes(lineStart, msgEnd - lineStart, styles.deleted(), false);
setLineDeleted(lineStart);
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Highlight comment lines to matching end delimiter.
 * 
 * @param content the content to parse
 * @param line the line number
 */
protected void commentLinesAfter(String content, int line) {
 int offset = m_RootElement.getElement(line).getEndOffset();
 // End of comment not found, nothing to do
 int endDelimiter = -1;
 if (getMultiLineComment()) {
  endDelimiter = indexOf(content, getMultiLineCommentEnd(), offset);
 }
 if (endDelimiter < 0) {
  return;
 }
 // Matching start/end of comment found, comment the lines
 int startDelimiter = lastIndexOf(content, getMultiLineCommentStart(),
  endDelimiter);
 if (startDelimiter < 0 || startDelimiter <= offset) {
  m_Self.setCharacterAttributes(offset, endDelimiter - offset + 1,
   DEFAULT_COMMENT, false);
 }
}
origin: Waikato/weka-trunk

/**
 * Highlight comment lines to matching end delimiter.
 * 
 * @param content the content to parse
 * @param line the line number
 */
protected void commentLinesAfter(String content, int line) {
 int offset = m_RootElement.getElement(line).getEndOffset();
 // End of comment not found, nothing to do
 int endDelimiter = -1;
 if (getMultiLineComment()) {
  endDelimiter = indexOf(content, getMultiLineCommentEnd(), offset);
 }
 if (endDelimiter < 0) {
  return;
 }
 // Matching start/end of comment found, comment the lines
 int startDelimiter = lastIndexOf(content, getMultiLineCommentStart(),
  endDelimiter);
 if (startDelimiter < 0 || startDelimiter <= offset) {
  m_Self.setCharacterAttributes(offset, endDelimiter - offset + 1,
   DEFAULT_COMMENT, false);
 }
}
origin: Waikato/weka-trunk

/**
 * Highlight lines when a multi line comment is still 'open' (ie. matching end
 * delimiter has not yet been encountered).
 * 
 * @param content the content to check
 * @param line the line number
 * @return true if there are comment lines before
 */
protected boolean commentLinesBefore(String content, int line) {
 int offset = m_RootElement.getElement(line).getStartOffset();
 // Start of comment not found, nothing to do
 int startDelimiter = -1;
 if (getMultiLineComment()) {
  startDelimiter = lastIndexOf(content, getMultiLineCommentStart(),
   offset - 2);
 }
 if (startDelimiter < 0) {
  return false;
 }
 // Matching start/end of comment found, nothing to do
 int endDelimiter = indexOf(content, getMultiLineCommentEnd(),
  startDelimiter);
 if (endDelimiter < offset & endDelimiter != -1) {
  return false;
 }
 // End of comment not found, highlight the lines
 m_Self.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1,
  DEFAULT_COMMENT, false);
 return true;
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Highlight lines when a multi line comment is still 'open' (ie. matching end
 * delimiter has not yet been encountered).
 * 
 * @param content the content to check
 * @param line the line number
 * @return true if there are comment lines before
 */
protected boolean commentLinesBefore(String content, int line) {
 int offset = m_RootElement.getElement(line).getStartOffset();
 // Start of comment not found, nothing to do
 int startDelimiter = -1;
 if (getMultiLineComment()) {
  startDelimiter = lastIndexOf(content, getMultiLineCommentStart(),
   offset - 2);
 }
 if (startDelimiter < 0) {
  return false;
 }
 // Matching start/end of comment found, nothing to do
 int endDelimiter = indexOf(content, getMultiLineCommentEnd(),
  startDelimiter);
 if (endDelimiter < offset & endDelimiter != -1) {
  return false;
 }
 // End of comment not found, highlight the lines
 m_Self.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1,
  DEFAULT_COMMENT, false);
 return true;
}
javax.swing.textDefaultStyledDocumentsetCharacterAttributes

Popular methods of DefaultStyledDocument

  • <init>
  • getLength
  • insertString
  • getText
  • remove
  • addDocumentListener
  • setDocumentFilter
  • addUndoableEditListener
  • createPosition
  • getParagraphElement
  • getCharacterElement
  • setParagraphAttributes
  • getCharacterElement,
  • setParagraphAttributes,
  • getDefaultRootElement,
  • insert,
  • addStyle,
  • fireInsertUpdate,
  • fireRemoveUpdate,
  • getEndPosition,
  • getStyle

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • getContentResolver (Context)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now