javax.swing.text.SimpleAttributeSet.addAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(71)

本文整理了Java中javax.swing.text.SimpleAttributeSet.addAttributes()方法的一些代码示例,展示了SimpleAttributeSet.addAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleAttributeSet.addAttributes()方法的具体详情如下:
包路径:javax.swing.text.SimpleAttributeSet
类名称:SimpleAttributeSet
方法名:addAttributes

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;

相关文章