import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
class Dic  
{
	public long fac(long theNumber)
	{
		long result = theNumber;
		for (long i = theNumber - 1 ;i>=1 ;i-- ) 
		{
			result=result*i ; }
			return result ;
		}
}
public class yu2 extends Frame {
	private TextField t1,t2;
	private Font f1;
	private Button b1;
	private Panel p1;
	private Dic d1;

	public yu2() {
		super ("fac form");

		d1 = new Dic() ;
		f1 = new Font ("SansSerif",Font.BOLD,16);
		t1 = new TextField (5) ; t1.setFont(f1);
		t2 = new TextField (5) ; t2.setFont(f1) ;

		b1 = new Button("เติมเลย") ; b1.setFont(f1);
		b1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				long d ;

				d = Long.parseLong(t1.getText());
				t2.setText(Long.toString(d1.fac(d)));

				validate() ;
			}
		});

		p1 = new Panel();
		p1.setLayout(new FlowLayout());

		p1.add(t1);
		p1.add(t2);
		p1.add(b1);
		add(p1);

		addWindowListener (new WindowAdapter() {
			public void windowClosing(WindowEvent we){
				setVisible(false);
				dispose();
				System.exit(0);
			}
		});
	}
public static void main(String args[]){
	yu2 u = new yu2() ;
	u.setSize(300,300);
	u.setVisible(true);
	}
}


