How to set foreground color of JTextField's text - Java Swing

Java examples for Swing:JTextField

Description

How to set foreground color of JTextField's text

Demo Code

 
import java.awt.Color;
import java.awt.FlowLayout;
 
import javax.swing.JApplet;
import javax.swing.JTextField;
 
public class Main {
       //  w w  w.ja va 2  s  .com
        public void init(){
                JTextField field = new JTextField("JTextField Foreground Color Example",20);
               
                Color color = Color.RED;
               
                field.setForeground(color);
        }
}

Related Tutorials