本文整理匯總了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;
}