本文整理汇总了Java中javax.swing.JTextPane.setComponentPopupMenu方法的典型用法代码示例。如果您正苦于以下问题:Java JTextPane.setComponentPopupMenu方法的具体用法?Java JTextPane.setComponentPopupMenu怎么用?Java JTextPane.setComponentPopupMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextPane
的用法示例。
在下文中一共展示了JTextPane.setComponentPopupMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupTextPane
import javax.swing.JTextPane; //导入方法依赖的package包/类
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
}