Example usage for javax.swing.text JTextComponent setCaretColor

List of usage examples for javax.swing.text JTextComponent setCaretColor

Introduction

In this page you can find the example usage for javax.swing.text JTextComponent setCaretColor.

Prototype

@BeanProperty(preferred = true, description = "the color used to render the caret")
public void setCaretColor(Color c) 

Source Link

Document

Sets the current color used to render the caret.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextComponent c = new JTextArea();
    c.getCaretPosition();//from   ww  w . j a  v a  2  s.c  o m
    if (c.getCaretPosition() < c.getDocument().getLength()) {
        char ch = c.getText(c.getCaretPosition(), 1).charAt(0);
    }
    // Set the caret color
    c.setCaretColor(Color.red);
}