当前位置: 首页>>代码示例>>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;未经允许,请勿转载。