當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。