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


Java StyleConstants.setComponent方法代碼示例

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


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

示例1: logDivider

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Write a horizontal separator into the log window. */
public void logDivider() {
	if (log == null)
		return;
	clearError();
	StyledDocument doc = log.getStyledDocument();
	Style dividerStyle = doc.addStyle("bar", styleRegular);
	JPanel jpanel = new JPanel();
	jpanel.setBackground(Color.LIGHT_GRAY);
	jpanel.setPreferredSize(new Dimension(300, 1)); // 300 is arbitrary,
													// since it will
													// auto-stretch
	StyleConstants.setComponent(dividerStyle, jpanel);
	reallyLog(".", dividerStyle); // Any character would do; "." will be
									// replaced by the JPanel
	reallyLog("\n\n", styleRegular);
	log.setCaretPosition(doc.getLength());
	lastSize = doc.getLength();
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:20,代碼來源:SwingLogPanel.java

示例2: appendRequiredAbility

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
public void appendRequiredAbility(StyledDocument doc, String key, boolean value) {
    final Specification spec = getSpecification();
    try {
        doc.insertString(doc.getLength(), Messages.getName(key),
                         doc.getStyle("regular"));
        List<JButton> requiredTypes
             = transform(spec.getTypesProviding(key, value), alwaysTrue(),
                 t -> {
                     JButton typeButton = getButton(t);
                     typeButton.addActionListener(this);
                     return typeButton;
                 });
        JButton rt = first(requiredTypes);
        if (rt != null) {
            doc.insertString(doc.getLength(), " (",
                             doc.getStyle("regular"));
            StyleConstants.setComponent(doc.getStyle("button"), rt);
            doc.insertString(doc.getLength(), " ", doc.getStyle("button"));
            for (int index = 1; index < requiredTypes.size(); index++) {
                JButton button = requiredTypes.get(index);
                doc.insertString(doc.getLength(), " / ",
                                 doc.getStyle("regular"));
                StyleConstants.setComponent(doc.getStyle("button"), button);
                doc.insertString(doc.getLength(), " ",
                                 doc.getStyle("button"));
            }
            doc.insertString(doc.getLength(), ")",
                             doc.getStyle("regular"));
        }
        doc.insertString(doc.getLength(), "\n", doc.getStyle("regular"));
    } catch (BadLocationException ble) {
        logger.log(Level.WARNING, "Insert fail", ble);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:35,代碼來源:ColopediaGameObjectTypePanel.java

示例3: insertColonyButtons

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
private void insertColonyButtons(StyledDocument doc, List<Colony> colonies) throws Exception {
    for (Colony colony : colonies) {
        StyleConstants.setComponent(doc.getStyle("button"), createColonyButton(colony, false));
        doc.insertString(doc.getLength(), " ", doc.getStyle("button"));
        doc.insertString(doc.getLength(), ", ", doc.getStyle("regular"));
    }
    doc.remove(doc.getLength() - 2, 2);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:9,代碼來源:ReportRequirementsPanel.java

示例4: insertMessage

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
private void insertMessage(StyledDocument document, ModelMessage message,
                           Player player) throws BadLocationException {
    for (Object o : message.splitLinks(player)) {
        if (o instanceof String) {
            document.insertString(document.getLength(), (String)o,
                                  document.getStyle("regular"));
        } else if (o instanceof JButton) {
            JButton b = (JButton)o;
            b.addActionListener(this);
            StyleConstants.setComponent(document.getStyle("button"), b);
            document.insertString(document.getLength(), " ",
                                  document.getStyle("button"));
        }
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:16,代碼來源:ReportTurnPanel.java

示例5: logDivider

import javax.swing.text.StyleConstants; //導入方法依賴的package包/類
/** Write a horizontal separator into the log window. */
public void logDivider() {
    if (log==null) return;
    clearError();
    StyledDocument doc = log.getStyledDocument();
    Style dividerStyle = doc.addStyle("bar", styleRegular);
    JPanel jpanel = new JPanel();
    jpanel.setBackground(Color.LIGHT_GRAY);
    jpanel.setPreferredSize(new Dimension(300,1)); // 300 is arbitrary, since it will auto-stretch
    StyleConstants.setComponent(dividerStyle, jpanel);
    reallyLog(".", dividerStyle); // Any character would do; "." will be replaced by the JPanel
    reallyLog("\n\n", styleRegular);
    log.setCaretPosition(doc.getLength());
    lastSize = doc.getLength();
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:16,代碼來源:SwingLogPanel.java


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