java setforeground_Java StyleConstants.setForeground方法代碼示例

本文整理匯總了Java中javax.swing.text.StyleConstants.setForeground方法的典型用法代碼示例。如果您正苦於以下問題:Java StyleConstants.setForeground方法的具體用法?Java StyleConstants.setForeground怎麽用?Java StyleConstants.setForeground使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.StyleConstants的用法示例。

在下文中一共展示了StyleConstants.setForeground方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: publish

​點讚 3

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,

示例2: getUnusedFieldAttributes

​點讚 3

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,

示例3: QueryBuilderSqlTextArea

​點讚 3

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,

示例4: initialize

​點讚 3

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,

示例5: addStyles

​點讚 2

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,

示例6: appendLog

​點讚 2

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,

示例7: insert

​點讚 2

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,

示例8: style

​點讚 2

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,

示例9: changeColor

​點讚 2

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,

示例10: getUnusedParameterAttributes

​點讚 2

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,

示例11: initStyleContext

​點讚 2

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,

示例12: LogAreaOutputStream

​點讚 2

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,

示例13: setColor

​點讚 2

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,

示例14: setInfo

​點讚 2

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類

/**

* Applies to next append

*/

private void setInfo() {

StyleConstants.setForeground(attr, Color.black);

}

開發者ID:SensorsINI,項目名稱:jaer,代碼行數:7,

示例15: print

​點讚 2

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,

示例16: addToConsole

​點讚 2

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類

private void addToConsole(LogEntry logentry, boolean update) {

StyledDocument doc = console.textpane.getStyledDocument();

Style style = doc.addStyle("Style", null);

if(update) {

updateLogEntry(logentry);

}

boolean doesLog = true;

switch(logentry.getLevel()) {

case LogEntry.LEVELERROR:

doesLog = showError;

StyleConstants.setBackground(style, Color.WHITE);

StyleConstants.setForeground(style, Color.red);

break;

case LogEntry.LEVELINPUT:

doesLog = showInput;

StyleConstants.setBackground(style, Color.WHITE);

StyleConstants.setForeground(style, Color.BLUE);

break;

case LogEntry.LEVELLOW:

doesLog = showLow;

StyleConstants.setBackground(style, Color.WHITE);

StyleConstants.setForeground(style, Color.GRAY);

break;

case LogEntry.LEVELNORMAL:

doesLog = showNormal;

StyleConstants.setBackground(style, Color.WHITE);

StyleConstants.setForeground(style, Color.BLACK);

break;

case LogEntry.LEVELCOMMAND:

doesLog = showCommand;

StyleConstants.setBackground(style, Color.BLACK);

StyleConstants.setForeground(style, Color.YELLOW);

break;

}

if(doesLog) {

try {

doc.insertString(doc.getLength(), logentry.toString() + "\n", style);

} catch (Exception ex) {

logErr(String.format(lang.getProperty("error_while_adding_to_the_console", "Error while adding to the console: %s"), ex));

}

console.textpane.setCaretPosition(doc.getLength());

}

}

開發者ID:Panzer1119,項目名稱:JAddOn,代碼行數:44,

示例17: createNormalStyle

​點讚 2

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類

private Style createNormalStyle (JTextPane textPane) {

Style normalStyle = textPane.addStyle("normal", null); //NOI18N

StyleConstants.setForeground(normalStyle, UIManager.getColor("List.foreground")); //NOI18N

return normalStyle;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,

示例18: createIssueHyperlinkStyle

​點讚 2

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類

private Style createIssueHyperlinkStyle (JTextPane textPane, Style normalStyle) {

Style issueHyperlinkStyle = textPane.addStyle("issuehyperlink", normalStyle); //NOI18N

StyleConstants.setForeground(issueHyperlinkStyle, LINK_COLOR == null ? Color.BLUE : LINK_COLOR);

StyleConstants.setUnderline(issueHyperlinkStyle, true);

return issueHyperlinkStyle;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,

示例19: createSelectedStyle

​點讚 2

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類

private Style createSelectedStyle (JTextPane textPane) {

Style selectedStyle = textPane.addStyle("selected", null); //NOI18N

StyleConstants.setForeground(selectedStyle, selectionForeground);

StyleConstants.setBackground(selectedStyle, selectionBackground);

return selectedStyle;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,

注:本文中的javax.swing.text.StyleConstants.setForeground方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值