Package javax.swing.text

Examples of javax.swing.text.StyleContext.addAttribute()


   * Append coloring text to TextPane
   */
  private void appendToPane(JTextPane tp, String msg, Color c)
    {
        StyleContext sc = StyleContext.getDefaultStyleContext();
        AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

        aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
        aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);

        int len = tp.getDocument().getLength();
View Full Code Here


  private void appendToPane(JTextPane tp, String msg, Color c)
    {
        StyleContext sc = StyleContext.getDefaultStyleContext();
        AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

        aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
        aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);

        int len = tp.getDocument().getLength();
        tp.setCaretPosition(len);
        tp.setCharacterAttributes(aset, false);
View Full Code Here

    {
        StyleContext sc = StyleContext.getDefaultStyleContext();
        AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

        aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
        aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);

        int len = tp.getDocument().getLength();
        tp.setCaretPosition(len);
        tp.setCharacterAttributes(aset, false);
        tp.replaceSelection(msg);
View Full Code Here

    private Component createSearchPanel() {
        StyleContext styleContent = StyleContext.getDefaultStyleContext();

        AttributeSet highlightStyle = gradleOutputTextPane.getDefaultStyle().copyAttributes();
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Foreground, Color.white);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Background, Color.orange);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Underline, true);

        AttributeSet emphasizedHighlightStyle = highlightStyle.copyAttributes();
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Foreground, Color.black);
View Full Code Here

    private Component createSearchPanel() {
        StyleContext styleContent = StyleContext.getDefaultStyleContext();

        AttributeSet highlightStyle = gradleOutputTextPane.getDefaultStyle().copyAttributes();
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Foreground, Color.white);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Background, Color.orange);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Underline, true);

        AttributeSet emphasizedHighlightStyle = highlightStyle.copyAttributes();
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Foreground, Color.black);
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Background, Color.yellow);
View Full Code Here

        StyleContext styleContent = StyleContext.getDefaultStyleContext();

        AttributeSet highlightStyle = gradleOutputTextPane.getDefaultStyle().copyAttributes();
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Foreground, Color.white);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Background, Color.orange);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Underline, true);

        AttributeSet emphasizedHighlightStyle = highlightStyle.copyAttributes();
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Foreground, Color.black);
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Background, Color.yellow);
View Full Code Here

        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Foreground, Color.white);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Background, Color.orange);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Underline, true);

        AttributeSet emphasizedHighlightStyle = highlightStyle.copyAttributes();
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Foreground, Color.black);
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Background, Color.yellow);

        searchPanel = new SearchPanel(new OutputPanelSearchInteraction(gradleOutputTextPane.getTextComponent(), gradleOutputTextPane.getDefaultStyle(), highlightStyle, emphasizedHighlightStyle));
        searchPanel.hide();
View Full Code Here

        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Background, Color.orange);
        highlightStyle = styleContent.addAttribute(highlightStyle, StyleConstants.Underline, true);

        AttributeSet emphasizedHighlightStyle = highlightStyle.copyAttributes();
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Foreground, Color.black);
        emphasizedHighlightStyle = styleContent.addAttribute(emphasizedHighlightStyle, StyleConstants.Background, Color.yellow);

        searchPanel = new SearchPanel(new OutputPanelSearchInteraction(gradleOutputTextPane.getTextComponent(), gradleOutputTextPane.getDefaultStyle(), highlightStyle, emphasizedHighlightStyle));
        searchPanel.hide();

        return searchPanel.getComponent();
View Full Code Here

public class ColorPane extends JTextPane {

  public void append(Color c, String s) { // better implementation--uses
                      // StyleContext
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,
        StyleConstants.Foreground, c);

    int len = getDocument().getLength(); // same value as
                       // getText().length();
    setCaretPosition(len); // place caret at the end (with no selection)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.