本文整理汇总了Java中javax.swing.text.html.HTMLDocument.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLDocument.getElement方法的具体用法?Java HTMLDocument.getElement怎么用?Java HTMLDocument.getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.html.HTMLDocument
的用法示例。
在下文中一共展示了HTMLDocument.getElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateHTML
import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
public void generateHTML() throws BadLocationException, IOException {
StringReader stringReader = new StringReader(HTML_TEMPLATE);
HTMLEditorKit htmlKit = new HTMLEditorKit();
HTMLDocument html = (HTMLDocument)htmlKit.createDefaultDocument();
htmlKit.read(stringReader, html, 0);
Element licenseList = html.getElement("licenses");
Element intro = html.getElement("my-account");
String introText = I18N.getGUILabel("manage_licenses.intro", new Object[0]);
html.setInnerHTML(intro, introText);
DateFormat format = DateFormat.getDateTimeInstance(2, 3);
Iterator css = this.licenses.iterator();
while(css.hasNext()) {
License backgroundURL = (License)css.next();
String productName = LicenseTools.translateProductName(backgroundURL);
String productEdition = LicenseTools.translateProductEdition(backgroundURL);
String expiration = I18N.getGUILabel("manage_licenses.perpetual_license", new Object[0]);
if(backgroundURL.getExpirationDate() != null) {
expiration = I18N.getGUILabel("manage_licenses.valid_until", new Object[]{format.format(backgroundURL.getExpirationDate())});
}
String annotations = null;
if(backgroundURL.getAnnotations() != null && !backgroundURL.getAnnotations().trim().isEmpty()) {
annotations = I18N.getGUILabel("manage_licenses.annotations", new Object[]{backgroundURL.getAnnotations()});
}
String licenseUser = null;
if(backgroundURL.getLicenseUser().getName() != null && !backgroundURL.getLicenseUser().getName().trim().isEmpty()) {
licenseUser = I18N.getGUILabel("manage_licenses.registered_to", new Object[]{backgroundURL.getLicenseUser().getName()});
}
StringBuffer entry = new StringBuffer();
entry.append("<tr><td>" + Ionicon.ARROW_RIGHT_B.getHtml() + "</td><td>");
entry.append(String.format("<strong>%s %s</strong>", new Object[]{productName, productEdition}));
if(licenseUser != null) {
entry.append(String.format("<br />%s", new Object[]{licenseUser}));
}
if(annotations != null) {
entry.append(String.format("<br />%s", new Object[]{annotations}));
}
entry.append(String.format("<br />%s", new Object[]{expiration}));
entry.append("</td></tr>");
html.insertBeforeEnd(licenseList, entry.toString());
}
StyleSheet css1 = html.getStyleSheet();
String backgroundURL1 = Tools.getResource("license/dialog/license_dialog_background.png").toString();
css1.addRule("body {background-image: url(\'" + backgroundURL1 + "\');}");
this.setDocument(html);
}