Code:
import java.awt.Color;
import java.awt.FlowLayout;
 
import javax.swing.JApplet;
import javax.swing.JTextField;

public class FgEx extends JApplet{
       
        public void init(){
               
                this.getContentPane().setLayout(new FlowLayout());
 
                JTextField field123 = new JTextField("Foreground Color Example", 20);
               
                Color color123 = Color.RED;
               
                field123.setForeground(color123);
 
                add(field);
        }
}