下面列出了怎么用javax.swing.plaf.basic.BasicTextPaneUI的API类实例代码及写法,或者点击链接到github查看源代码。
private void setupTextPane(final JTextPane textPane, String comment) {
if( UIUtils.isNimbus() ) {
textPane.setUI( new BasicTextPaneUI() );
}
textPane.setText(comment);
Caret caret = textPane.getCaret();
if (caret instanceof DefaultCaret) {
((DefaultCaret)caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
// attachments
if (!attachmentIds.isEmpty()) {
AttachmentHyperlinkSupport.Attachement a = AttachmentHyperlinkSupport.findAttachment(comment, attachmentIds);
if (a != null) {
String attachmentId = a.id;
if (attachmentId != null) {
int index = attachmentIds.indexOf(attachmentId);
if (index != -1) {
BugzillaIssue.Attachment attachment = attachments.get(index);
AttachmentLink attachmentLink = new AttachmentLink(attachment);
HyperlinkSupport.getInstance().registerLink(textPane, new int[] {a.idx1, a.idx2}, attachmentLink);
} else {
Bugzilla.LOG.log(Level.WARNING, "couldn''t find attachment id in: {0}", comment); // NOI18N
}
}
}
}
// pop-ups
textPane.setComponentPopupMenu(commentsPopup);
textPane.setBackground(blueBackground);
textPane.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
textPane.setEditable(false);
textPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleName")); // NOI18N
textPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleDescription")); // NOI18N
}