List of usage examples for javax.swing JTextArea setSelectedTextColor
@BeanProperty(preferred = true, description = "color used to render selected text") public void setSelectedTextColor(Color c)
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); }