當前位置: 首頁>>代碼示例>>Java>>正文


Java StyleConstants.setFontSize方法代碼示例

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


在下文中一共展示了StyleConstants.setFontSize方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: setFontName

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Set the font name. */
public void setFontName(String fontName) {
	if (log == null)
		return;
	this.fontName = fontName;
	log.setFont(new Font(fontName, Font.PLAIN, fontSize));
	StyleConstants.setFontFamily(styleRegular, fontName);
	StyleConstants.setFontFamily(styleBold, fontName);
	StyleConstants.setFontFamily(styleRed, fontName);
	StyleConstants.setFontSize(styleRegular, fontSize);
	StyleConstants.setFontSize(styleBold, fontSize);
	StyleConstants.setFontSize(styleRed, fontSize);
	// Changes all existing text
	StyledDocument doc = log.getStyledDocument();
	Style temp = doc.addStyle("temp", null);
	StyleConstants.setFontFamily(temp, fontName);
	StyleConstants.setFontSize(temp, fontSize);
	doc.setCharacterAttributes(0, doc.getLength(), temp, false);
	// Changes all existing hyperlinks
	Font newFont = new Font(fontName, Font.BOLD, fontSize);
	for (JLabel link : links) {
		link.setFont(newFont);
	}
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:25,代碼來源:SwingLogPanel.java

示例4: do_setFont

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Changes the font and tabsize for the document. */
public final void do_setFont(String fontName, int fontSize, int tabSize) {
   if (tabSize < 1) tabSize = 1; else if (tabSize > 100) tabSize = 100;
   if (fontName.equals(this.font) && fontSize == this.fontSize && tabSize == this.tabSize) return;
   this.font = fontName;
   this.fontSize = fontSize;
   this.tabSize = tabSize;
   for(MutableAttributeSet s: all) { StyleConstants.setFontFamily(s, fontName);  StyleConstants.setFontSize(s, fontSize); }
   do_reapplyAll();
   BufferedImage im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); // this is used to derive the tab width
   int gap = tabSize * im.createGraphics().getFontMetrics(new Font(fontName, Font.PLAIN, fontSize)).charWidth('X');
   TabStop[] pos = new TabStop[100];
   for(int i=0; i<100; i++) { pos[i] = new TabStop(i*gap + gap); }
   StyleConstants.setTabSet(tabset, new TabSet(pos));
   setParagraphAttributes(0, getLength(), tabset, false);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:17,代碼來源:OurSyntaxDocument.java

示例5: setFontName

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Set the font name. */
public void setFontName(String fontName) {
    if (log==null) return;
    this.fontName = fontName;
    log.setFont(new Font(fontName, Font.PLAIN, fontSize));
    StyleConstants.setFontFamily(styleRegular, fontName);
    StyleConstants.setFontFamily(styleBold, fontName);
    StyleConstants.setFontFamily(styleRed, fontName);
    StyleConstants.setFontSize(styleRegular, fontSize);
    StyleConstants.setFontSize(styleBold, fontSize);
    StyleConstants.setFontSize(styleRed, fontSize);
    // Changes all existing text
    StyledDocument doc=log.getStyledDocument();
    Style temp=doc.addStyle("temp", null);
    StyleConstants.setFontFamily(temp, fontName);
    StyleConstants.setFontSize(temp, fontSize);
    doc.setCharacterAttributes(0, doc.getLength(), temp, false);
    // Changes all existing hyperlinks
    Font newFont = new Font(fontName, Font.BOLD, fontSize);
    for(JLabel link: links) { link.setFont(newFont); }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:22,代碼來源:SwingLogPanel.java

示例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;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:14,代碼來源:OurConsole.java

示例7: do_setFont

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Changes the font and tabsize for the document. */
public final void do_setFont(String fontName, int fontSize, int tabSize) {
	if (tabSize < 1)
		tabSize = 1;
	else if (tabSize > 100)
		tabSize = 100;
	if (fontName.equals(this.font) && fontSize == this.fontSize && tabSize == this.tabSize)
		return;
	this.font = fontName;
	this.fontSize = fontSize;
	this.tabSize = tabSize;
	for (MutableAttributeSet s : all) {
		StyleConstants.setFontFamily(s, fontName);
		StyleConstants.setFontSize(s, fontSize);
	}
	do_reapplyAll();
	BufferedImage im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); // this
																				// is
																				// used
																				// to
																				// derive
																				// the
																				// tab
																				// width
	int gap = tabSize * im.createGraphics().getFontMetrics(new Font(fontName, Font.PLAIN, fontSize)).charWidth('X');
	TabStop[] pos = new TabStop[100];
	for (int i = 0; i < 100; i++) {
		pos[i] = new TabStop(i * gap + gap);
	}
	StyleConstants.setTabSet(tabset, new TabSet(pos));
	setParagraphAttributes(0, getLength(), tabset, false);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:33,代碼來源:OurSyntaxDocument.java

示例8: 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;
}
 
開發者ID:sxei,項目名稱:myqq,代碼行數:21,代碼來源:MyTextPane.java

示例9: 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:FreeCol,項目名稱:freecol,代碼行數:16,代碼來源:Utility.java

示例10: init

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/**
 * Description of the Method
 *
 * @param prop
 *            Description of the Parameter
 */
public void init(YassProperties prop) {
	String fontSizeString = prop.getProperty("lyrics-font-size");
	try {
		int i = Integer.parseInt(fontSizeString);
		if (i > 0) {
			fontSize = i;
		}
	} catch (Exception e) {
	}
	StyleConstants.setFontSize(notLongStyle, fontSize);
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:18,代碼來源:YassLyrics.java

示例11: 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:ModelWriter,項目名稱:Tarski,代碼行數:11,代碼來源:OurConsole.java

示例12: 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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:JViewPortBackingStoreImageTest.java


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