Java Code Examples for javax.swing.text.StyleConstants#setUnderline()
The following examples show how to use
javax.swing.text.StyleConstants#setUnderline() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JConsole.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
private AttributeSet setStyle( String fontFamilyName, int size, Color color, boolean bold, boolean italic, boolean underline ) { MutableAttributeSet attr = new SimpleAttributeSet(); if (color != null) { StyleConstants.setForeground(attr, color); } if (fontFamilyName != null) { StyleConstants.setFontFamily(attr, fontFamilyName); } if (size != -1) { StyleConstants.setFontSize(attr, size); } StyleConstants.setBold(attr, bold); StyleConstants.setItalic(attr, italic); StyleConstants.setUnderline(attr, underline); setStyle(attr); return getStyle(); }
Example 2
Source File: JConsole.java From beanshell with Apache License 2.0 | 6 votes |
private AttributeSet setStyle( String fontFamilyName, int size, Color color, boolean bold, boolean italic, boolean underline ) { MutableAttributeSet attr = new SimpleAttributeSet(); if (color!=null) StyleConstants.setForeground(attr, color); if (fontFamilyName!=null) StyleConstants.setFontFamily(attr, fontFamilyName); if (size!=-1) StyleConstants.setFontSize(attr, size); StyleConstants.setBold(attr, bold); StyleConstants.setItalic(attr, italic); StyleConstants.setUnderline(attr, underline); setStyle(attr); return getStyle(); }
Example 3
Source File: StackTraceColorizer.java From otroslogviewer with Apache License 2.0 | 6 votes |
protected void initStyles() { styleContext = new StyleContext(); Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setFontFamily(defaultStyle, "courier"); styleStackTrace = styleContext.addStyle("stackTrace", defaultStyle); StyleConstants.setBackground(styleStackTrace, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_BACKGROUND)); StyleConstants.setForeground(styleStackTrace, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_FOREGROUND)); stylePackage = styleContext.addStyle("stylePackage", styleStackTrace); styleClass = styleContext.addStyle("styleClass", stylePackage); StyleConstants.setForeground(styleClass, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_CLASS)); StyleConstants.setBold(styleClass, true); styleMethod = styleContext.addStyle("styleMethod", styleStackTrace); StyleConstants.setForeground(styleMethod, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_METHOD)); StyleConstants.setItalic(styleMethod, true); StyleConstants.setBold(styleMethod, true); styleFile = styleContext.addStyle("styleFile", styleStackTrace); StyleConstants.setForeground(styleFile, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_FLE)); StyleConstants.setUnderline(styleFile, true); styleCodeComment = styleContext.addStyle("styleCodeComment", defaultStyle); StyleConstants.setForeground(styleCodeComment, theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_COMMENT)); StyleConstants.setItalic(styleCodeComment, true); }
Example 4
Source File: JConsole.java From COMP6237 with BSD 3-Clause "New" or "Revised" License | 6 votes |
private AttributeSet setStyle( String fontFamilyName, int size, Color color, boolean bold, boolean italic, boolean underline ) { final MutableAttributeSet attr = new SimpleAttributeSet(); if (color != null) StyleConstants.setForeground(attr, color); if (fontFamilyName != null) StyleConstants.setFontFamily(attr, fontFamilyName); if (size != -1) StyleConstants.setFontSize(attr, size); StyleConstants.setBold(attr, bold); StyleConstants.setItalic(attr, italic); StyleConstants.setUnderline(attr, underline); setStyle(attr); return getStyle(); }
Example 5
Source File: StackTraceSupport.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 6
Source File: MyTextPane.java From myqq with MIT License | 5 votes |
/** * 获取某种字体 * @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; }
Example 7
Source File: TextPanelWithLinksDetector.java From ramus with GNU General Public License v3.0 | 5 votes |
private SimpleAttributeSet createLinkStyle() { SimpleAttributeSet linkStyle = new SimpleAttributeSet(); StyleConstants.setUnderline(linkStyle, true); StyleConstants.setBold(linkStyle, true); return linkStyle; }
Example 8
Source File: VersionPane.java From bigtable-sql with Apache License 2.0 | 5 votes |
/** * Renders the content. */ private void init() { String content = getContent(); setContentType("text/html"); StyledDocument doc = getStyledDocument(); SimpleAttributeSet s = new SimpleAttributeSet(); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); StyleConstants.setBold(s, true); try { doc.setParagraphAttributes(0,content.length(), s, false); doc.insertString(0, content, s); if (_showWebsite) { String webContent = Version.getWebSite(); SimpleAttributeSet w = new SimpleAttributeSet(); StyleConstants.setAlignment(w, StyleConstants.ALIGN_CENTER); StyleConstants.setUnderline(w, true); SimpleAttributeSet hrefAttr = new SimpleAttributeSet(); hrefAttr.addAttribute(HTML.Attribute.HREF, Version.getWebSite()); w.addAttribute(HTML.Tag.A, hrefAttr); doc.setParagraphAttributes(content.length(),webContent.length(), w, false); doc.insertString(content.length(), webContent, w); if (Desktop.isDesktopSupported()){ addMouseListener(this); addMouseMotionListener(this); } } } catch (Exception e) { s_log.error("init: Unexpected exception "+e.getMessage()); } setOpaque(false); }
Example 9
Source File: MWPaneFormatter.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Modify the underline attribute of a style. * * @param style Style to be modified. * @param config Configuration. * @param configStyle Configuration of the style. */ private static void formatStyleUnderline( Style style, Configuration config, ConfigurationValueStyle.StyleProperties configStyle) { StyleConstants.setUnderline( style, configStyle.getUnderline()); }
Example 10
Source File: ResourcePanel.java From AML-Project with Apache License 2.0 | 5 votes |
public ResourcePanel(Dimension max, Dimension min) { super("Resource Panel",false,false,false,false); this.setMaximumSize(max); this.setPreferredSize(min); desc = new JTextPane(); desc.setEditable(false); UIDefaults defaults = new UIDefaults(); defaults.put("TextPane[Enabled].backgroundPainter", AMLColor.WHITE); desc.putClientProperty("Nimbus.Overrides", defaults); desc.putClientProperty("Nimbus.Overrides.InheritDefaults", true); desc.setBackground(AMLColor.WHITE); doc = desc.getStyledDocument(); def = StyleContext.getDefaultStyleContext(). getStyle(StyleContext.DEFAULT_STYLE); bold = doc.addStyle("bold", def); StyleConstants.setBold(bold, true); s = doc.addStyle("source", def); StyleConstants.setBold(s, true); StyleConstants.setForeground(s, AMLColor.BLUE); t = doc.addStyle("target", def); StyleConstants.setBold(t, true); StyleConstants.setForeground(t, AMLColor.BROWN); u = doc.addStyle("uri", def); StyleConstants.setUnderline(u, true); setContentPane(desc); pack(); setVisible(true); refresh(); }
Example 11
Source File: SummaryCellRenderer.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 12
Source File: StyleProperties.java From otroslogviewer with Apache License 2.0 | 4 votes |
public static Style getStyle(Theme.Type themeType,StyleContext styleContext, DataConfiguration styleConfig, String styleName, int group) { Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE)); final String groupSuffix; if (group <= 0) { groupSuffix = ""; } else { groupSuffix = "." + group; } String fontFamily = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, ""); if (fontFamily.trim().length() > 0) { StyleConstants.setFontFamily(style, styleConfig.getString(PROP_FONT_FAMILY + groupSuffix)); } if (styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "").trim().length() > 0) { StyleConstants.setFontSize(style, styleConfig.getInt(PROP_FONT_SIZE + groupSuffix)); } if (styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "").trim().length() > 0) { StyleConstants.setBold(style, styleConfig.getBoolean(PROP_FONT_BOLD + groupSuffix)); } if (styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "").trim().length() > 0) { StyleConstants.setItalic(style, styleConfig.getBoolean(PROP_FONT_ITALIC + groupSuffix)); } if (styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "").trim().length() > 0) { StyleConstants.setUnderline(style, styleConfig.getBoolean(PROP_FONT_UNDERLINE + groupSuffix)); } String theme; if (themeType.equals(Theme.Type.Light)) { theme = "light"; } else { theme = "dark"; } if (styleConfig.getString(PROP_BACKGROUND + groupSuffix + "." + theme,"").trim().length() > 0) { StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix + "." + theme, null)); } else if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) { StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix)); } if (styleConfig.getString(PROP_FOREGROUND + groupSuffix + "." + theme,"").trim().length() > 0) { StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix + "." + theme, null)); } else if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) { StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix)); } return style; }