Example usage for javax.swing JTextArea setSelectedTextColor

List of usage examples for javax.swing JTextArea setSelectedTextColor

Introduction

In this page you can find the example usage for javax.swing JTextArea setSelectedTextColor.

Prototype

@BeanProperty(preferred = true, description = "color used to render selected text")
public void setSelectedTextColor(Color c) 

Source Link

Document

Sets the current color used to render the selected text.

Usage

From source file:Main.java

public static void main(String args[]) {
    JTextArea textArea = new JTextArea();

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    DefaultCaret caret = new DefaultCaret() {
        @Override/*  w w w.j a  v  a 2s . c o m*/
        public boolean isSelectionVisible() {
            return true;
        }
    };
    textArea.setCaret(caret);
    textArea.setFont(new java.awt.Font("Miriam Fixed", 0, 13));

    Color color = Color.BLUE;
    // textArea.setBackground(color);
    textArea.setSelectedTextColor(color);
    f.getContentPane().add(new JScrollPane(textArea));
    f.pack();
    f.setVisible(true);
}