import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.GridLayout;
public class FontDemo8_21
{
	public static void main(String[] args) 
	{
		JFrame frame=new JFrame("颜色字体");
		JTextField td1=new JTextField("前景色红，背景色绿");
		JTextField td2=new JTextField("宋体，粗体，18号");
		td1.setForeground(Color.red);
		td1.setBackground(Color.green);
		Font font=new Font("宋体",Font.BOLD,18); 
		td2.setFont(font);		
		frame.setLayout(new GridLayout(2,1));
		frame.add(td1);
		frame.add(td2);
		frame.setSize(180,160);
		frame.setVisible(true);
	}
}