Java JTextPane getForegroundColor(JTextPane textPane)

Here you can find the source of getForegroundColor(JTextPane textPane)

Description

Returns the current foreground color.

License

Apache License

Declaration

public static Color getForegroundColor(JTextPane textPane) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Color;

import javax.swing.JTextPane;

import javax.swing.text.StyleConstants;

public class Main {
    /**/*from  w w  w . j a v a2  s  . co  m*/
     * Returns the current foreground color.
     */
    public static Color getForegroundColor(JTextPane textPane) {
        Color color = (Color) (textPane.getInputAttributes()
                .getAttribute(StyleConstants.Foreground));
        if (color == null) {
            color = new Color(0, 0, 0);
        }
        return color;
    }
}

Related

  1. applyRegex(String regex, JTextPane pane, Color highlightColor)
  2. centerText(JTextPane pane)
  3. createJTextPane(String text, Color backgroundColor)
  4. createTextPaneScrollPane(JTextPane textPane)
  5. getFontFamily(JTextPane textPane)
  6. insertStyledString(JTextPane textPane, String text, SimpleAttributeSet attrSet, Color background, Color foreground, String fontFamily, int fontSize, boolean bold, boolean italic, boolean underline, boolean strikeThrough, Boolean superscript)
  7. isSelectionBold(JTextPane textPane)
  8. overrideStyle(String styleName, JTextPane textPane, Style newStyle)
  9. saveFile(JTextPane txt)