本文整理了Java中javax.swing.JTextPane.getStyle()
方法的一些代码示例,展示了JTextPane.getStyle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.getStyle()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:getStyle
暂无
代码示例来源:origin: stackoverflow.com
Style defaultStyle = jtp.getStyle(StyleContext.DEFAULT_STYLE);
doc.setCharacterAttributes(0, doc.getLength(), defaultStyle, false);
代码示例来源:origin: org.apache.uima/uimaj-tools
/**
* Sets the text pane.
*/
private void setTextPane() {
Style defaultStyle = this.textPane.getStyle(defaultStyleName);
// Style style = textPane.getStyle(typeName);
// if (style == null || defaultStyle == null) {
// System.out.println("Style is null.");
// }
Document doc = this.textPane.getDocument();
try {
doc.remove(0, doc.getLength());
doc.insertString(doc.getLength(), "This is what an ", defaultStyle);
doc.insertString(doc.getLength(), "annotation", this.currentStyle);
doc.insertString(doc.getLength(), " of type ", defaultStyle);
doc.insertString(doc.getLength(), this.currentTypeName, this.currentStyle);
doc.insertString(doc.getLength(), " will look like.", defaultStyle);
} catch (BadLocationException e) {
// assert(false);
}
this.textPane.repaint();
}
代码示例来源:origin: com.davidbracewell/hermes-core
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
rows.get(rowIndex)[columnIndex] = aValue;
if (columnIndex == 2) {
int start = (int) rows.get(rowIndex)[0];
int end = (int) rows.get(rowIndex)[1];
editorPane.getStyledDocument()
.setCharacterAttributes(start,
end - start,
editorPane.getStyle(((Tag) rows.get(rowIndex)[2]).name()),
true);
fireTableCellUpdated(rowIndex, columnIndex);
}
}
代码示例来源:origin: RPTools/maptool
style = pane.getStyle(match.group(1));
if (style == null)
throw new IllegalArgumentException("Unknown style: '" + match.group(1));
代码示例来源:origin: otros-systems/otroslogviewer
private void refreshView() {
LOGGER.info("refreshing view");
Style defaultStyle = textPane.getStyle(StyleContext.DEFAULT_STYLE);
String text = textPane.getText();
textPane.getStyledDocument().setCharacterAttributes(0, text.length(), defaultStyle, true);
try {
PropertyPatternMessageColorizer propertyPatternMessageColorize = createMessageColorizer();
if (propertyPatternMessageColorize.colorizingNeeded(text)) {
Collection<MessageFragmentStyle> colorize = propertyPatternMessageColorize.colorize(text);
for (MessageFragmentStyle mfs : colorize) {
textPane.getStyledDocument().setCharacterAttributes(mfs.getOffset(), mfs.getLength(), mfs.getStyle(), mfs.isReplace());
}
}
} catch (Exception e) {
LOGGER.error(String.format("Can't init PropertyPatternMessageColorizer:%s", e.getMessage()));
statusObserver.updateStatus(String.format("Error: %s", e.getMessage()), StatusObserver.LEVEL_ERROR);
}
}
代码示例来源:origin: com.davidbracewell/hermes-core
@Override
public void keyReleased(KeyEvent e) {
if (e.isControlDown() && e.getKeyChar() == '+') {
Font font = editorPane.getFont();
if (font.getSize() < 24) {
Font f2 = new Font(font.getName(), font.getStyle(), font.getSize() + 2);
editorPane.setFont(f2);
StyleConstants.setFontSize(editorPane.getStyle(StyleContext.DEFAULT_STYLE), f2.getSize());
}
} else if (e.isControlDown() && e.getKeyChar() == '-') {
Font font = editorPane.getFont();
if (font.getSize() > 12) {
Font f2 = new Font(font.getName(), font.getStyle(), font.getSize() - 2);
editorPane.setFont(f2);
}
}
savePreferences();
lines.setFont(new Font(Font.MONOSPACED, Font.PLAIN, editorPane.getFont().getSize()));
super.keyPressed(e);
}
});
代码示例来源:origin: tulskiy/musique
@Override
protected void done() {
try {
String result = get();
if (result != null) {
textPane.setText("");
StyledDocument doc = textPane.getStyledDocument();
doc.insertString(doc.getLength(), track.getTrackData().getArtist() + "\n", textPane.getStyle("artist"));
doc.insertString(doc.getLength(), track.getTrackData().getTitle() + "\n\n", textPane.getStyle("title"));
doc.insertString(doc.getLength(), Util.htmlToString(result), null);
textPane.setCaretPosition(0);
}
} catch (Exception ignored) {
}
}
代码示例来源:origin: stackoverflow.com
javax.swing.text.Style style = textpane.addStyle("Red", null);
StyleConstants.setForeground(style, Color.RED);
doc.setCharacterAttributes(0, 1, textpane.getStyle("Red"), true);
panel.add(textpane);
frame.add(panel);
代码示例来源:origin: tulskiy/musique
@Override
public void actionPerformed(ActionEvent e) {
Track track = player.getTrack();
try {
textPane.setText("");
StyledDocument doc = textPane.getStyledDocument();
doc.insertString(doc.getLength(), track.getTrackData().getArtist() + "\n", textPane.getStyle("artist"));
doc.insertString(doc.getLength(), track.getTrackData().getTitle() + "\n\n", textPane.getStyle("title"));
} catch (BadLocationException e1) {
e1.printStackTrace();
}
if (search != null && !search.isDone())
search.cancel(true);
search = new Search(textPane, track);
search.execute();
timer.stop();
}
});
代码示例来源:origin: stackoverflow.com
@Override
public void actionPerformed(ActionEvent actionEvent) {
doc.setCharacterAttributes(stringIndex, 1, textpane.getStyle("Red"), true);
stringIndex++;
try {
代码示例来源:origin: stackoverflow.com
end = life;
Style style = textPane.getStyle("negra");
代码示例来源:origin: stackoverflow.com
doc.setCharacterAttributes(position, 1, textPane.getStyle("Red"), true);
doc.setCharacterAttributes(position, 1, textPane.getStyle("Blue"), true);
代码示例来源:origin: com.davidbracewell/hermes-core
private void addTag(Tag tag) {
int start = editorPane.getSelectionStart();
int end = editorPane.getSelectionEnd();
if (annotationTableModel.spanHasAnnotation(start, end)) {
if (JOptionPane.showConfirmDialog(null, "Delete existing annotations on span?") == JOptionPane.OK_OPTION) {
annotationTableModel.annotations.overlapping(new Span(start, end)).forEach(a -> {
int r = annotationTableModel.find(a.start(), a.end());
annotationTableModel.removeRow(r);
});
} else {
return;
}
}
if (start == end) {
return;
}
dirty = true;
editorPane.getStyledDocument()
.setCharacterAttributes(start, end - start, editorPane.getStyle(tag.name()), true);
annotationTableModel.addRow(new Object[]{start, end, tag, editorPane.getSelectedText()});
}
代码示例来源:origin: stackoverflow.com
public void run() {
System.out.println("\t" + (System.currentTimeMillis() - start) + " ms - letter: " + TEXT.charAt(letterIndex));
doc.setCharacterAttributes(letterIndex, 1, textpane.getStyle("Red"), true);
代码示例来源:origin: stackoverflow.com
Style defaultStyle = jtp.getStyle(StyleContext.DEFAULT_STYLE);
doc.setCharacterAttributes(0, doc.getLength(), defaultStyle, false);
代码示例来源:origin: stackoverflow.com
start, len, textPane.getStyle("RED"), true);
代码示例来源:origin: com.davidbracewell/hermes-core
.setCharacterAttributes(start,
length,
editorPane.getStyle(((Tag) row[2]).name()),
true);
});
代码示例来源:origin: stackoverflow.com
textpane.getStyle("Red"), true);
代码示例来源:origin: stackoverflow.com
doc.insertString(0,"Artist\tAlbum\tGernre\tGreatest Hit\tRecord Lable\n",textPane.getStyle("large"));
doc.insertString(doc.getLength(),songs.get(j).getArtist() + "\t",textPane.getStyle("bold"));
doc.insertString(doc.getLength(),songs.get(j).getAlbum() + "\t",textPane.getStyle("bold"));
doc.insertString(doc.getLength(),songs.get(j).getGenre() + "\t",textPane.getStyle("bold"));
doc.insertString(doc.getLength(),songs.get(j).getHit() + "\t",textPane.getStyle("italic"));
doc.insertString(doc.getLength(),songs.get(j).getLable() + "\n",textPane.getStyle("regular"));
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
StyledDocument doc = (StyledDocument) textPane.getDocument();
Style normalStyle = textPane.getStyle("normal");
Style hyperlinkStyle = textPane.addStyle("hyperlink", normalStyle);
StyleConstants.setForeground(hyperlinkStyle, LINK_COLOR == null ? Color.BLUE : LINK_COLOR);
内容来源于网络,如有侵权,请联系作者删除!