本文整理汇总了Java中javax.swing.text.StyleConstants.setBold方法的典型用法代码示例。如果您正苦于以下问题:Java StyleConstants.setBold方法的具体用法?Java StyleConstants.setBold怎么用?Java StyleConstants.setBold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.StyleConstants
的用法示例。
在下文中一共展示了StyleConstants.setBold方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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;
}
示例3: LogRecordEntry
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* Creates a new {@link LogRecordEntry} which automatically formats the given {@link LogRecord}
* with the RapidMiner Studio log styling and default logging format.
*
* @param logRecord
*/
public LogRecordEntry(LogRecord logRecord) {
logLevel = logRecord.getLevel();
initialString = logRecord.getMessage();
simpleAttributeSet = new SimpleAttributeSet();
if (logRecord.getLevel().intValue() >= Level.SEVERE.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_ERROR);
StyleConstants.setBold(simpleAttributeSet, true);
} else if (logRecord.getLevel().intValue() >= Level.WARNING.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_WARNING);
StyleConstants.setBold(simpleAttributeSet, true);
} else if (logRecord.getLevel().intValue() >= Level.INFO.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_INFO);
StyleConstants.setBold(simpleAttributeSet, false);
} else {
StyleConstants.setForeground(simpleAttributeSet, COLOR_DEFAULT);
StyleConstants.setBold(simpleAttributeSet, false);
}
formattedString = formatter.format(logRecord);
}
示例4: 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);
}
示例5: getFieldAttributes
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private static AttributeSet getFieldAttributes () {
if (fieldAttributeSet == null) {
SimpleAttributeSet sas = new SimpleAttributeSet ();
StyleConstants.setForeground (sas, new Color (9, 134, 24));
StyleConstants.setBold (sas, true);
fieldAttributeSet = sas;
}
return fieldAttributeSet;
}
示例6: 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;
}
示例7: getFontAttribute
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* 获取某种字体
* @param name 字体名称
* @param size 字体大小
* @param color 字体颜色
* @param bold 是否加粗
* @param underline 是否加下划线
* @return 返回获取的字体
*/
public static SimpleAttributeSet getFontAttribute(String name, int size, Color color,
boolean bold, boolean underline)
{
SimpleAttributeSet attribute = new SimpleAttributeSet();
StyleConstants.setFontFamily(attribute, name);
StyleConstants.setFontSize(attribute, size);
StyleConstants.setForeground(attribute, color);
StyleConstants.setBold(attribute, bold);
StyleConstants.setUnderline(attribute, underline);
return attribute;
}
示例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;
}
示例9: createStyles
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
static void createStyles() {
styles = new StyleContext();
doc = new DefaultStyledDocument(styles);
contentAttributes = new HashMap<>();
// no attributes defined
Style s = styles.addStyle(null, null);
contentAttributes.put("none", s);
Style def = styles.getStyle(StyleContext.DEFAULT_STYLE);
Style heading = styles.addStyle("heading", def);
StyleConstants.setFontFamily(heading, "SansSerif");
StyleConstants.setBold(heading, true);
StyleConstants.setAlignment(heading, StyleConstants.ALIGN_CENTER);
StyleConstants.setSpaceAbove(heading, 10);
StyleConstants.setSpaceBelow(heading, 10);
StyleConstants.setFontSize(heading, 18);
// Title
Style sty = styles.addStyle("title", heading);
StyleConstants.setFontSize(sty, 32);
// author
sty = styles.addStyle("author", heading);
StyleConstants.setItalic(sty, true);
StyleConstants.setSpaceBelow(sty, 25);
}
示例10: createLinkStyle
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private Style createLinkStyle (JTextPane textPane, Style normalStyle) {
Style linkStyle = textPane.addStyle("link", normalStyle); //NOI18N
StyleConstants.setForeground(linkStyle, LINK_COLOR == null ? Color.BLUE : LINK_COLOR);
StyleConstants.setBold(linkStyle, true);
return linkStyle;
}