本文整理了Java中javax.swing.text.SimpleAttributeSet.addAttributes()
方法的一些代码示例,展示了SimpleAttributeSet.addAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleAttributeSet.addAttributes()
方法的具体详情如下:
包路径:javax.swing.text.SimpleAttributeSet
类名称:SimpleAttributeSet
方法名:addAttributes
暂无
代码示例来源:origin: stackoverflow.com
public SOExample() {
initComponents();
addText("This is my plain text", null);
//Retrieve existing attributes.
SimpleAttributeSet previousAttribs = new SimpleAttributeSet
(jtp.getInputAttributes()
.copyAttributes());
SimpleAttributeSet BOLD = new SimpleAttributeSet();
StyleConstants.setBold (BOLD, true);
StyleConstants.setForeground (BOLD, Color.BLUE);
//Merge new attributes with existing ones.
previousAttribs.addAttributes (BOLD);
//Insert the string and apply merged attributes.
addText ("This is my BLUE BOLD text", previousAttribs);
outputHTMLfile();
代码示例来源:origin: stackoverflow.com
public class ExtendedHTMLEditorKit extends HTMLEditorKit{
//.... other code here
public class MyHTMLFactory extends HTMLFactory{
//other code here
@Override
public View create(Element elem) {
if (isLayered(elem)){ //it means, it has position attribute
return new PositionedView(elem);
}
else
return super.create(elem);
}
boolean isLayered(Element elem){
SimpleAttributeSet sas = new SimpleAttributeSet(elem);
StyleSheet styles = (HTMLDocument elem.getDocument).getStyleSheet();
Tag tag = element.getAttributes().getAttribute(AttributeSet.NameAttribute);
sas.addAttributes(styleSheet.getRule(tag, element));
return sas.isDefined("position")
&& !sas.getAttribute("position").toString().equalsIgnorecase("static");
}
}
}
代码示例来源:origin: omegat-org/omegat
private AttributeSet makeAttributes(final int offset, final URI target) {
SimpleAttributeSet atts = new SimpleAttributeSet(doc.getCharacterElement(offset).getAttributes());
atts.addAttributes(LINK_ATTRIBUTES);
atts.addAttribute(ATTR_LINK, new IAttributeAction() {
@Override
public void execute() {
try {
Desktop.getDesktop().browse(target);
} catch (Exception e) {
JOptionPane.showConfirmDialog(null, e.getLocalizedMessage(),
OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE);
Log.log(e);
}
}
});
return atts;
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages
as = highlighting.get (ts.offset(), ts.offset() + t.length());
if (as != null) {
attributeSet.addAttributes(as);
endOffset1 = ts.offset() + t.length();
return;
内容来源于网络,如有侵权,请联系作者删除!