当前位置: 首页>>代码示例>>Java>>正文


Java StyleConstants.setForeground方法代码示例

本文整理汇总了Java中javax.swing.text.StyleConstants.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java StyleConstants.setForeground方法的具体用法?Java StyleConstants.setForeground怎么用?Java StyleConstants.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.StyleConstants的用法示例。


在下文中一共展示了StyleConstants.setForeground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publish

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
@Override
public void publish(final LogRecord record) {
  StyledDocument doc = textPane.getStyledDocument();
  SimpleAttributeSet keyWord = new SimpleAttributeSet();
  StyleConstants.setForeground(keyWord, getColor(record.getLevel()));
  StyleConstants.setBold(keyWord, true);
  StyleConstants.setFontSize(keyWord, 12);
  StyleConstants.setFontFamily(keyWord, CONSOLE_FONT);

  SimpleAttributeSet text = new SimpleAttributeSet();
  StyleConstants.setForeground(text, getColor(record.getLevel()));
  StyleConstants.setFontFamily(text, CONSOLE_FONT);
  try {
    doc.insertString(doc.getLength(), String.format("%1$-10s", record.getLevel()), keyWord);
    if (record.getParameters() != null) {
      doc.insertString(doc.getLength(), MessageFormat.format(record.getMessage(), record.getParameters()), text);
    } else {
      doc.insertString(doc.getLength(), record.getMessage(), text);
    }

    doc.insertString(doc.getLength(), "\n", text);
  } catch (BadLocationException e) {
  }

  textPane.setCaretPosition(doc.getLength());
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:27,代码来源:ConsoleLogHandler.java

示例2: getUnusedFieldAttributes

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private static AttributeSet getUnusedFieldAttributes () {
    if (unusedFieldAttributeSet == null) {
        SimpleAttributeSet sas = new SimpleAttributeSet ();
        StyleConstants.setForeground (sas, new Color (115, 115, 115));
        StyleConstants.setBold (sas, true);
        unusedFieldAttributeSet = sas;
    }
    return unusedFieldAttributeSet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ColorsManager.java

示例3: QueryBuilderSqlTextArea

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public QueryBuilderSqlTextArea(QueryBuilder queryBuilder) {
        super();
        _queryBuilder = queryBuilder;
        createSqlTextPopup();
        // Get Netbeans-registered EditorKit for SQL content
	setEditorKit(CloneableEditorSupport.getEditorKit("text/x-sql"));
        if ( SYNTAX_HIGHLIGHT ) {
            addKeyListener(this);
        }
        
        // set the bold attribute
        // colors chosen from :
        // http://ui.netbeans.org/docs/hi/annotations/index2.html
        StyleConstants.setForeground(keyword,new Color(0,0,153));
        StyleConstants.setForeground(schema, new Color(0,111,0));
        StyleConstants.setForeground(column,new Color(120,0,0));
          
        // Add support for code completion (comment out, breaks syntax highlighting)
//        QueryBuilderSqlCompletion doc = new QueryBuilderSqlCompletion( this, sqlReservedWords);
//        this.setDocument(doc);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:QueryBuilderSqlTextArea.java

示例4: initialize

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
 * Initialises this
 */
private void initialize() {
	
	black = new SimpleAttributeSet();
    StyleConstants.setForeground(black, Color.black);
    StyleConstants.setFontFamily(black, "Courier");
    StyleConstants.setFontSize(black, 11);
    red = new SimpleAttributeSet();
    StyleConstants.setForeground(red, Color.red);
    StyleConstants.setFontFamily(red, "Courier");
    StyleConstants.setFontSize(red, 11);
    
    this.setLayout(new BorderLayout());
	this.setSize(400,100);
	this.setPreferredSize(new Dimension(400, 100));
    this.add(getJScrollPane(),BorderLayout.CENTER);
	
	if (this.isLocalConsole()==true) {
		// --- listen to local Out/Err-Output ---------
		SysOutBoard.setSysOutScanner(new SysOutScanner(this));
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:26,代码来源:JPanelConsole.java

示例5: addStyles

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private void addStyles() {
	Style s;
	Style def = StyleContext.getDefaultStyleContext().getStyle(
			StyleContext.DEFAULT_STYLE);

	Style regular = doc.addStyle("regular", def);
	// StyleConstants.setForeground(regular, Color.BLACK);
	StyleConstants.setFontFamily(regular, "SansSerif");
	// StyleConstants.setFontSize(regular, 10)
	// StyleConstants.setBold(regular, true);
	// StyleConstants.setItalic(regular, true);
	// StyleConstants.setAlignment(regular, StyleConstants.ALIGN_CENTER);

	s = doc.addStyle("debug", regular);
	StyleConstants.setForeground(s, Color.ORANGE);
	StyleConstants.setFontFamily(s, "SansSerif");
	// StyleConstants.setFontSize(s, 10)
	// StyleConstants.setBold(s, true);
	// StyleConstants.setItalic(s, true);
	// StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);

	s = doc.addStyle("warn", regular);
	StyleConstants.setForeground(s, Color.RED);
	StyleConstants.setFontFamily(s, "SansSerif");
	// StyleConstants.setFontSize(s, 10)
	StyleConstants.setBold(s, true);
	// StyleConstants.setItalic(s, true);
	// StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);

	s = doc.addStyle("notify", regular);
	StyleConstants.setForeground(s, Color.GREEN);
	StyleConstants.setFontFamily(s, "SansSerif");
	// StyleConstants.setFontSize(s, 10)
	StyleConstants.setBold(s, true);
	// StyleConstants.setItalic(s, true);
	// StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:38,代码来源:ConsolePanel.java

示例6: appendLog

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private void appendLog(final String text, final Color color) {
    SimpleAttributeSet sas = new SimpleAttributeSet();
    StyleConstants.setForeground(sas, color);
    StyledDocument sd = logText.getStyledDocument();
    try {
        synchronized (this) {
            sd.insertString(sd.getLength(), text + "\n", sas);
        }
    } catch (BadLocationException e) { }

    logText.setCaretPosition(sd.getLength());
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:13,代码来源:MainWindow.java

示例7: insert

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public void insert(String str){
       StyleConstants.setForeground( attrs, Color.BLACK );
       if( str.charAt(0) != ' ' ){
       	str = " " + str;
       }
       	
       String str2 = str.replaceAll(";", ";\n");
       
       try {
		doc.insertString(offs, str2, attrs);
		offs += str2.length();
	} catch (BadLocationException e) { 
		e.printStackTrace();
	}
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:16,代码来源:HMLP_TextPane.java

示例8: style

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
 * Helper method that construct a mutable style with the given font name,
 * font size, boldness, color, and left indentation.
 */
static MutableAttributeSet style(String fontName, int fontSize, boolean boldness, Color color, int leftIndent) {
	MutableAttributeSet s = new SimpleAttributeSet();
	StyleConstants.setFontFamily(s, fontName);
	StyleConstants.setFontSize(s, fontSize);
	StyleConstants.setBold(s, boldness);
	StyleConstants.setForeground(s, color);
	StyleConstants.setLeftIndent(s, leftIndent);
	return s;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:14,代码来源:OurConsole.java

示例9: changeColor

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
 * Description method that changes the foreground color 
 * @param document document to be changed
 * @return Style for the new document
 * @throws BadLocationException 
 */
public static Style changeColor(DefaultStyledDocument document) throws BadLocationException {
    StyleContext context = new StyleContext();
    // build a style
    Style style = context.addStyle("test", null);
    // set some style properties
    StyleConstants.setForeground(style, Color.RED);
    return style;
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:15,代码来源:ConsoleCore.java

示例10: getUnusedParameterAttributes

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private static AttributeSet getUnusedParameterAttributes () {
    if (unusedParameterAttributeSet == null) {
        SimpleAttributeSet sas = new SimpleAttributeSet ();
        StyleConstants.setForeground (sas, new Color (115, 115, 115));
        unusedParameterAttributeSet = sas;
    }
    return unusedParameterAttributeSet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ColorsManager.java

示例11: initStyleContext

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public static void initStyleContext(Font font) {
    Style defaultStyle = StyleContext.getDefaultStyleContext()
        .getStyle(StyleContext.DEFAULT_STYLE);

    STYLE_CONTEXT = new StyleContext();
    Style regular = STYLE_CONTEXT.addStyle("regular", defaultStyle);
    StyleConstants.setFontFamily(regular, font.getFamily());
    StyleConstants.setFontSize(regular, font.getSize());

    Style buttonStyle = STYLE_CONTEXT.addStyle("button", regular);
    StyleConstants.setForeground(buttonStyle, LINK_COLOR);

    Style right = STYLE_CONTEXT.addStyle("right", regular);
    StyleConstants.setAlignment(right, StyleConstants.ALIGN_RIGHT);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:16,代码来源:Utility.java

示例12: LogAreaOutputStream

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/** Constructs an Out or Err LogAreaOutputStream */
public LogAreaOutputStream(boolean anIsErr) {
  isErr = anIsErr;
  if(isErr) {
    style = addStyle("error", getStyle("default"));
    StyleConstants.setForeground(style, Color.red);
  } else {
    style = addStyle("out", getStyle("default"));
    StyleConstants.setForeground(style, Color.black);
  }// End if
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:12,代码来源:LogArea.java

示例13: setColor

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public void setColor(Color c,String s){
    try {
        StyledDocument doc = jTextPane1.getStyledDocument();
        javax.swing.text.Style style = jTextPane1.addStyle("", null);
        StyleConstants.setForeground(style, c);
        doc.insertString(doc.getLength(), s, style);
        jTextPane1.select(0, 10);
        jTextPane1.setSelectedTextColor(Color.YELLOW);
    } catch (BadLocationException ex) {
            System.out.println(ex);
    }
}
 
开发者ID:8085simulator,项目名称:8085simulator,代码行数:13,代码来源:text.java

示例14: setInfo

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
 * Applies to next append
 */
private void setInfo() {
	StyleConstants.setForeground(attr, Color.black);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:7,代码来源:AEViewerConsoleOutputFrame.java

示例15: print

import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public static final void print(final String s, final ConsoleStyle style) {

		final StyledDocument doc = textPane.getStyledDocument();

		if (style == null || style.equals(ConsoleStyle.INFO)) StyleConstants.setForeground(Console.style, Color.BLACK);
		else if (style.equals(ConsoleStyle.WARNING)) StyleConstants.setForeground(Console.style, Color.ORANGE);
		else StyleConstants.setForeground(Console.style, Color.RED);

		try {

			doc.insertString(doc.getLength(), s + "\n", Console.style);

		} catch (final BadLocationException e) {

		}

	}
 
开发者ID:ASasseCreations,项目名称:Voxel_Game,代码行数:18,代码来源:Console.java


注:本文中的javax.swing.text.StyleConstants.setForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。