List of usage examples for javax.swing.text StyleConstants setForeground
public static void setForeground(MutableAttributeSet a, Color fg)
From source file:org.quackbot.gui.GUIConsoleAppender.java
public void init() { //Init styles for (JTextPane curPane : ImmutableList.of(gui.BerrorLog, gui.CerrorLog)) { StyledDocument doc = curPane.getStyledDocument(); doc.addStyle("Normal", null); StyleConstants.setForeground(doc.addStyle("Class", null), Color.blue); StyleConstants.setForeground(doc.addStyle("Error", null), Color.red); //BotSend gets a better shade of orange than Color.organ gives StyleConstants.setForeground(doc.addStyle("BotSend", null), new Color(255, 127, 0)); //BotRecv gets a better shade of green than Color.green gives StyleConstants.setForeground(doc.addStyle("BotRecv", null), new Color(0, 159, 107)); StyleConstants.setBold(doc.addStyle("Server", null), true); StyleConstants.setItalic(doc.addStyle("Thread", null), true); StyleConstants.setItalic(doc.addStyle("Level", null), true); }//from w w w.ja va 2 s .c o m log.debug("Inited GUILogAppender, processing any saved messages"); synchronized (initMessageQueue) { inited = true; while (!initMessageQueue.isEmpty()) append(initMessageQueue.poll()); } }
From source file:org.smart.migrate.ui.ImportThread.java
private void addStylesToDocument(StyledDocument doc) { //Initialize some styles. Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "SansSerif"); Style s = doc.addStyle("italic", regular); StyleConstants.setItalic(s, true); s = doc.addStyle("bold", regular); StyleConstants.setBold(s, true); s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 10); s = doc.addStyle("large", regular); StyleConstants.setFontSize(s, 16); s = doc.addStyle("icon", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); s = doc.addStyle("info", regular); StyleConstants.setForeground(s, Color.blue); s = doc.addStyle("error", regular); StyleConstants.setForeground(s, Color.red); s = doc.addStyle("warning", regular); StyleConstants.setForeground(s, Color.orange); s = doc.addStyle("gray", regular); StyleConstants.setForeground(s, Color.gray); s = doc.addStyle("success", regular); StyleConstants.setForeground(s, Color.green); }
From source file:org.spoutcraft.launcher.skin.ConsoleFrame.java
/** * Construct the frame.//w w w .j a v a 2s . c o m * * @param numLines number of lines to show at a time * @param colorEnabled true to enable a colored console * @param trackProc process to track * @param killProcess true to kill the process on console close */ public ConsoleFrame(int numLines, boolean colorEnabled, final Process trackProc, final boolean killProcess) { super("Console"); this.numLines = numLines; this.colorEnabled = colorEnabled; this.trackProc = trackProc; this.highlightedAttributes = new SimpleAttributeSet(); StyleConstants.setForeground(highlightedAttributes, Color.BLACK); StyleConstants.setBackground(highlightedAttributes, Color.YELLOW); this.errorAttributes = new SimpleAttributeSet(); StyleConstants.setForeground(errorAttributes, new Color(200, 0, 0)); this.infoAttributes = new SimpleAttributeSet(); StyleConstants.setForeground(infoAttributes, new Color(200, 0, 0)); this.debugAttributes = new SimpleAttributeSet(); StyleConstants.setForeground(debugAttributes, Color.DARK_GRAY); setSize(new Dimension(650, 400)); buildUI(); Compatibility.setIconImage(this, Toolkit.getDefaultToolkit().getImage(LoginFrame.spoutcraftIcon)); if (trackProc != null) { track(trackProc); } addMouseListener(this); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent event) { if (trackProc != null && killProcess) { trackProc.destroy(); if (loggerHandler != null) { rootLogger.removeHandler(loggerHandler); } event.getWindow().dispose(); } } }); }
From source file:org.thelq.stackexchange.dbimport.gui.GUILogAppender.java
public void init() { //Configure logger loggerText = gui.getLoggerText();//from w w w. j ava 2s . c om loggerStyle = loggerText.getStyledDocument(); loggerStyle.addStyle("Normal", null); StyleConstants.setForeground(loggerStyle.addStyle("Class", null), Color.blue); StyleConstants.setForeground(loggerStyle.addStyle("Error", null), Color.red); StyleConstants.setItalic(loggerStyle.addStyle("Thread", null), true); StyleConstants.setItalic(loggerStyle.addStyle("Level", null), true); log.debug("Inited GUILogAppender, processing any saved messages"); synchronized (initMessageQueue) { inited = true; while (!initMessageQueue.isEmpty()) append(initMessageQueue.poll()); } }
From source file:pl.otros.logview.gui.message.pattern.StyleProperties.java
public static Style getStyle(StyleContext styleContext, DataConfiguration styleConfig, String styleName, int group) { Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE)); String groupSuffix = "." + group; if (group <= 0) { groupSuffix = ""; }/*from ww w. j a v a2s . c o m*/ 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)); } if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) { StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix)); } if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) { StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix)); } return style; }
From source file:pl.otros.logview.gui.message.update.LogDataFormatter.java
public LogDataFormatter(LogData logData, // DateFormat dateFormat, // MessageUpdateUtils messageUtils, // PluginableElementsContainer<MessageColorizer> colorizersContainer, // PluginableElementsContainer<MessageFormatter> formattersContainer, // CancelStatus cancelStatus, int maximumMessageSize) { this.ld = logData; this.dateFormat = dateFormat; this.messageUtils = messageUtils; this.colorizersContainer = colorizersContainer; this.formattersContainer = formattersContainer; this.cancelStatus = cancelStatus; this.maximumMessageSize = maximumMessageSize; sc = new StyleContext(); defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); mainStyle = sc.addStyle("MainStyle", defaultStyle); StyleConstants.setFontSize(mainStyle, 12); StyleConstants.setForeground(mainStyle, Color.BLACK); classMethodStyle = sc.addStyle("classMethod", null); StyleConstants.setFontFamily(classMethodStyle, "monospaced"); StyleConstants.setForeground(classMethodStyle, Color.BLUE); boldArialStyle = sc.addStyle("note", mainStyle); StyleConstants.setFontFamily(boldArialStyle, "arial"); StyleConstants.setBold(boldArialStyle, true); propertyNameStyle = sc.addStyle("propertyValue", classMethodStyle); StyleConstants.setForeground(propertyNameStyle, new Color(0, 0, 128)); propertyValueStyle = sc.addStyle("propertyValue", classMethodStyle); StyleConstants.setForeground(propertyNameStyle, new Color(0, 128, 0)); }
From source file:pl.otros.logview.gui.message.update.LogDataFormatter.java
private Style getStyleForMarkerColor(MarkerColors markerColors) { String styleName = "MarkerColor" + markerColors.name(); Style style = sc.getStyle(styleName); if (style == null) { style = sc.addStyle(styleName, mainStyle); StyleConstants.setForeground(style, markerColors.getForeground()); StyleConstants.setBackground(style, markerColors.getBackground()); }/*w ww. j a va2 s. c o m*/ return style; }
From source file:pl.otros.logview.gui.MessageDetailListener.java
public MessageDetailListener(JTable table, JTextPane logDetailTextArea, LogDataTableModel dataTableModel, SimpleDateFormat dateFormat, PluginableElementsContainer<MessageFormatter> formattersContainer, PluginableElementsContainer<MessageColorizer> colorizersContainer) { super();//from w w w .j a va2 s. com this.table = table; this.logDetailTextArea = logDetailTextArea; this.dataTableModel = dataTableModel; this.dateFormat = dateFormat; this.formattersContainer = formattersContainer; this.colorizersContainer = colorizersContainer; sc = new StyleContext(); defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); mainStyle = sc.addStyle("MainStyle", defaultStyle); StyleConstants.setFontSize(mainStyle, 12); StyleConstants.setForeground(mainStyle, Color.BLACK); classMethodStyle = sc.addStyle("classMethod", null); StyleConstants.setFontFamily(classMethodStyle, "monospaced"); StyleConstants.setForeground(classMethodStyle, Color.BLUE); noteStyle = sc.addStyle("note", mainStyle); StyleConstants.setFontFamily(noteStyle, "arial"); StyleConstants.setBold(noteStyle, true); formattersContainer.addListener(new PluginableElementEventListenerImplementation<MessageFormatter>()); colorizersContainer.addListener(new PluginableElementEventListenerImplementation<MessageColorizer>()); }
From source file:plugin.notes.gui.NotesView.java
private void colorButtonActionPerformed() { //GEN-FIRST:event_colorButtonActionPerformed AttributeSet as = editor.getCharacterAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet(as); Color newColor = JColorChooser.showDialog(GMGenSystem.inst, "Choose Text Color", editor.getStyledDocument().getForeground(as)); if (newColor != null) { StyleConstants.setForeground(sas, newColor); editor.setCharacterAttributes(sas, true); }// www .j a v a2 s. co m editor.repaint(); }
From source file:simplealbum.mvc.autocomplete.DController.java
void changeSeeker(Seeker seeker) { view.setTitle(seeker.getTitle());//from ww w .j ava2 s. c o m // jTextPane.setText(""); TODO model.emptyList(); model.setSeeker(seeker); request(); List<String> colors = seeker.getColors(); styles = new Style[colors.size()]; StyleContext sc = new StyleContext(); for (int i = 0; i < colors.size(); i++) { styles[i] = sc.addStyle((String) colors.get(i), sc.getStyle(StyleContext.DEFAULT_STYLE)); StyleConstants.setForeground(styles[i], ColorUtils.getColorByName(colors.get(i))); StyleConstants.setBold(styles[i], true); } colorInputText(); filter = seeker.getFilter(); }