JAVA - How To Change A JTextField Font Color, Name, Style, And Size In Java
Source Code:
package JavaDB_001;
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
public class Project extends JFrame{
public Project(){
super("Change JTextField Font Name, Style, Size, Color");
//"Verdana" = font name;
//Font.BOLD = font style, You Can Also Put An Int;
// 30 = size;
Font f = new Font("Verdana",Font.BOLD,30);
JTextField tf = new JTextField(60);
//set the font to the JTextField
tf.setFont(f);
//change a JTextField font color
tf.setForeground(Color.red);
tf.setBounds(80,20,250,50);
add(tf);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(400,200);
setVisible(true);
}
public static void main(String[] args){
new Project();
}
}
///////////////////////OUTPUT:
Download Projects Source Code