本文整理汇总了Java中javax.swing.text.StyleConstants.setUnderline方法的典型用法代码示例。如果您正苦于以下问题:Java StyleConstants.setUnderline方法的具体用法?Java StyleConstants.setUnderline怎么用?Java StyleConstants.setUnderline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.StyleConstants
的用法示例。
在下文中一共展示了StyleConstants.setUnderline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: underlineStacktraces
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private static void underlineStacktraces(StyledDocument doc, JTextPane textPane, List<StackTracePosition> stacktraces, String comment) {
Style defStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style hlStyle = doc.addStyle("regularBlue-stacktrace", defStyle); // NOI18N
hlStyle.addAttribute(HyperlinkSupport.STACKTRACE_ATTRIBUTE, new StackTraceAction());
StyleConstants.setForeground(hlStyle, UIUtils.getLinkColor());
StyleConstants.setUnderline(hlStyle, true);
int last = 0;
textPane.setText(""); // NOI18N
for (StackTraceSupport.StackTracePosition stp : stacktraces) {
int start = stp.getStartOffset();
int end = stp.getEndOffset();
if (last < start) {
insertString(doc, comment, last, start, defStyle);
}
last = start;
// for each line skip leading whitespaces (look bad underlined)
boolean inStackTrace = (comment.charAt(start) > ' ');
for (int i = start; i < end; i++) {
char ch = comment.charAt(i);
if ((inStackTrace && ch == '\n') || (!inStackTrace && ch > ' ')) {
insertString(doc, comment, last, i, inStackTrace ? hlStyle : defStyle);
inStackTrace = !inStackTrace;
last = i;
}
}
if (last < end) {
insertString(doc, comment, last, end, inStackTrace ? hlStyle : defStyle);
}
last = end;
}
try {
doc.insertString(doc.getLength(), comment.substring(last), defStyle);
} catch (BadLocationException ex) {
Support.LOG.log(Level.SEVERE, null, ex);
}
}
示例2: getFontAttribute
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* 获取某种字体
* @param name 字体名称
* @param size 字体大小
* @param color 字体颜色
* @param bold 是否加粗
* @param underline 是否加下划线
* @return 返回获取的字体
*/
public static SimpleAttributeSet getFontAttribute(String name, int size, Color color,
boolean bold, boolean underline)
{
SimpleAttributeSet attribute = new SimpleAttributeSet();
StyleConstants.setFontFamily(attribute, name);
StyleConstants.setFontSize(attribute, size);
StyleConstants.setForeground(attribute, color);
StyleConstants.setBold(attribute, bold);
StyleConstants.setUnderline(attribute, underline);
return attribute;
}
示例3: createIssueHyperlinkStyle
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private Style createIssueHyperlinkStyle (JTextPane textPane, Style normalStyle) {
Style issueHyperlinkStyle = textPane.addStyle("issuehyperlink", normalStyle); //NOI18N
StyleConstants.setForeground(issueHyperlinkStyle, LINK_COLOR == null ? Color.BLUE : LINK_COLOR);
StyleConstants.setUnderline(issueHyperlinkStyle, true);
return issueHyperlinkStyle;
}
示例4: setUnderline
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public TextAttribute setUnderline(boolean underline)
{
StyleConstants.setUnderline(this, underline);
return this;
}