Java 8 DefaultStyledDocument - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DefaultStyledDocument class.

This code example shows how to use the following methods:addStyle, getStyle, setBase
        tfText.setText(StringUtils.excerpt(aText, EXCERPT_SENTENCES, EXCERPT_MIN_CHARS, EXCERPT_MAX_CHARS));
        tfText.setEditable(false);
        tfText.setToolTipText("<html>" + aText);
 
        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        doc.setBase(article.getLink());
        Style def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, articleConfig.getTextFont());
 
        setViewMode(config.getViewMode());
 
        layout = new FormLayout("5px, center:pref, 5px", "5px, pref, 5px, pref, 5px, pref, 5px");
        setLayout(layout);
 
        aImageURL = aImageURL == null ? config.getNoImageURL() : aImageURL;
        Dimension dim = modeToDimension(config.getViewMode());
        lbImage = new AsyncImagePanel(aImageURL, dim.width, dim.height,
            new ShadowBorder(COLOR_SHADOW_BORDER), article.isRead());
        setTextComponentsWidth(); 
6
CodeRank
This code example shows how to use the following methods:setDocumentFilter, addDocumentListener
  public static JTextArea newReadOnlyLengthLimitedTextArea(DocumentListener listener, int rows, int columns) {
 
    JTextArea textArea = newReadOnlyTextArea(rows, columns);
 
    // Limit the length of the underlying document 
    DefaultStyledDocument doc = new DefaultStyledDocument();
    doc.setDocumentFilter(new DocumentMaxLengthFilter(rows * columns));
    textArea.setDocument(doc);
 
    // Ensure we monitor changes 
    doc.addDocumentListener(listener);
 
    return textArea;
 
  } 
 
  /** 
   * @return A new "enter transaction label" text field 
   */ 
  public static JTextField newEnterTransactionLabel() {
4
CodeRank
This code example shows how to use the following methods:putProperty, insertString
     * 
     * @throws javax.swing.text.BadLocationException 
     */ 
    @Test
    public void testGetIndentString() throws BadLocationException {
        DefaultStyledDocument document = new DefaultStyledDocument();
        document.putProperty(Language.class, MarkdownTokenId.language());
        document.insertString(0, "    * list\n", null); // white space
        String result = MarkdownDocUtil.getIndentString(document, 10);
        assertEquals("    ", result);
 
        document.insertString(0, "	* list\n", null); // tab space
        result = MarkdownDocUtil.getIndentString(document, 7);
        assertEquals("	", result);
 
        document.insertString(0, "  	  * list\n", null); // white space and tab space
        result = MarkdownDocUtil.getIndentString(document, 11);
        assertEquals("  	  ", result);
 
        document.insertString(0, "* list\n", null); // no indent

4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:getDefaultRootElement
This code example shows how to use the following methods:
     
    /** The StyleContext for the Console. */ 
    ConsoleStyleContext styleContext = new ConsoleStyleContext();
     
    /** The text area to which everything is written. */ 
    JTextPane textArea = new JTextPane(new DefaultStyledDocument(styleContext));
 
    /** 
     * Creates a new Console object. 
     * @throws IOException 
     */ 
    private Console() throws IOException {
    	// Set up Custom 
    	piCustom = new PipedInputStream();
    	poCustom = new PipedOutputStream();
        printStream = new PrintStream(poCustom);
    	 
        // Set up System.out 
        piOut = new PipedInputStream();
        poOut = new PipedOutputStream(piOut);
3
CodeRank
This code example shows how to use the following methods:getCharacterElement
This code example shows how to use the following methods:
    	 this.setEditable(true);
    	this.setPreferredSize(new Dimension(550,500));
		this.setContentType("text/java");
		this.setText("");
		 
		doc = new DefaultStyledDocument();/* {
            public void insertString (int offset, String str, AttributeSet a) throws BadLocationException { 
                super.insertString(offset, str, a); 
 
                String text = getText(0, getLength()); 
                int before = findLastNonWordChar(text, offset); 
                if (before < 0) before = 0; 
                int after = findFirstNonWordChar(text, offset + str.length()); 
                int wordL = before; 
                int wordR = before; 
 
                while (wordR <= after) { 
                    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); 
2
CodeRank
See Code Examples for Java 8 DefaultStyledDocument Methods: