Java 类javax.swing.plaf.basic.BasicTextPaneUI 实例源码
项目:incubator-netbeans
文件:CommentsPanel.java
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
}
项目:samebug-idea-plugin
文件:StyledMultilineLabel.java
@Override
public void updateUI() {
setUI(new BasicTextPaneUI());
updateColors();
}
项目:Desktop
文件:StickyNote.java
private void init() {
Color color = note.getColor();
ToFrontListener toFrontListener = new ToFrontListener();
// create text pane
text = new StickyNoteTextPane();
text.setText(note.getText());
text.setUI(new BasicTextPaneUI());
text.setBackground(color);
text.setFont(note.getFont());
text.setForeground(note.getFontColor());
text.addMouseListener(toFrontListener);
text.addPropertyChangeListener(this);
textMoveController = new MoveController(text, this);
textMoveController.addPropertyChangeListener(this);
// create scroll pane
int borderSize = ResizeController.RESIZE_THRESHOLD;
scroll = new JScrollPane() {
@Override
protected void paintComponent(java.awt.Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.fillRect(0, 0, getWidth(), getHeight());
super.paintComponent(g2d);
}
};
scroll.setBorder(BorderFactory.createEmptyBorder(0, borderSize, borderSize, borderSize));
scroll.setBackground(color);
scroll.setForeground(color);
scroll.setViewportView(text);
scroll.addMouseListener(toFrontListener);
scrollMoveController = new MoveController(scroll, this);
scrollResizeController = new ResizeController(scroll, this);
scrollMoveController.addPropertyChangeListener(this);
scrollResizeController.addPropertyChangeListener(this);
add(scroll, BorderLayout.CENTER);
// create the header
header = new StickyNoteHeader(this);
header.setFont(note.getFont());
header.setForeground(note.getFontColor());
header.setBackground(color);
header.addMouseListener(toFrontListener);
headerMoveController = new MoveController(header, this);
headerMoveController.addPropertyChangeListener(this);
add(header, BorderLayout.NORTH);
// window properties
setSize(note.getSize());
setAlwaysOnTop(note.isAlwaysOnTop());
setLocationRelativeTo(null);
// setLocation(point);
setVisible(note.isVisible());
}