import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
public DetailsPanel() {
initComponents2();
HTMLEditorKit htmlkit = new HTMLEditorKitEx();
// override the Swing default CSS to make the HTMLEditorKit use the
// same font as the rest of the UI.
// XXX the style sheet is shared by all HTMLEditorKits. We must
// detect if it has been tweaked by ourselves or someone else
// (code completion javadoc popup for example) and avoid doing the
// same thing again
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();
css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
}
setEditorKit(htmlkit);
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent hlevt) {
if (EventType.ACTIVATED == hlevt.getEventType()) {
if (hlevt.getURL () != null) {
Utilities.showURL(hlevt.getURL());
}
}
}
});
setEditable(false);
setPreferredSize(new Dimension(300, 80));
RP.post(new Runnable() {
@Override
public void run() {
getAccessibleContext ().setAccessibleName (
NbBundle.getMessage (DetailsPanel.class, "ACN_DetailsPanel")); // NOI18N
}
});
putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
}