How to Earn Money ADFLY

Monday 20 February 2017

How Set Font In Java Program

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Simple extends JFrame{
JTextField tx;
Font f;
public Simple(){
setBounds(0,0,600,400);
setTitle("Simple Java Program");
setLayout(null);

f=new Font("Comic Sans MS",Font.BOLD+Font.ITALIC,20);

tx=new JTextField("Hello");
tx.setFont(f);
tx.setBounds(30,50,200,30);

add(tx);//add the button
setVisible(true);
}
public static void main(String args[]){
JFrame f=new Simple();
}
}

No comments:

Post a Comment