import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.geom.*;


public class  TextField extends JApplet implements ActionListener 
{
  Container c;
  JPanel inputPanel;
  JButton b;
  JTextField t;
  String s="ali veli 49 elli";
  int kirmizi,yesil,mavi;
  public Color renk;
  
  	              public static String terscevir(String source) 
	              { int i, len = source.length(); 
                    StringBuffer dest = new StringBuffer(len); 
                    for (i = (len - 1); i >= 0; i--) { 
                      dest.append(source.charAt(i)); } 
                  return dest.toString(); }
 
  public void init()
  {    
	b=new JButton("yazıyı tersine çevirin" );
	t=new JTextField(s);
	t.setFont(new Font("Serif",Font.BOLD,24));	
    c=getContentPane();
    c.setLayout(new BorderLayout());
    inputPanel=new JPanel();
    inputPanel.add(new JScrollPane(t));
    c.add(b,BorderLayout.NORTH);
    c.add(t,BorderLayout.CENTER);
    b.addActionListener(this);
  }


public void actionPerformed( ActionEvent e)
{
// yazıyı ters çevir	
	 if(e.getSource()==b)
        {t.setText(terscevir(t.getText())); }
//tesadüfi renk belirle düğmeye her basılışta rengi değiştir.	
kirmizi=(int)(255.0*Math.random());
yesil  =(int)(255.0*Math.random());
mavi   =(int)(255.0*Math.random());
renk=new Color(kirmizi,yesil,mavi);
t.setBackground(renk);
}

    public static void main(String s[])
    {
        JFrame f = new JFrame("JTextField kontrol programı");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new TextField();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(545,400));
        f.setVisible(true);
    }
}





