Set Background Color of JTextField - Java Swing

Java examples for Swing:JTextField

Description

Set Background Color of JTextField

Demo Code


import java.awt.Color;
import java.awt.FlowLayout;
 
import javax.swing.JApplet;
import javax.swing.JTextField;
 
public class Main {
        public void init(){
                JTextField field = new JTextField("JTextField Background Color Example",20);
                Color color = Color.GRAY;
                field.setBackground(color);
        }/*from www. j a v  a 2 s  .  c om*/
}

Related Tutorials