I am working on a project in Java Swing. Now there is a text field for user name. I want to validate that text field so that user **can't enter digits or special character or blank or space**. In short I want a restriction such that user can't enter anything other than alphabets. The database is MS Access and table name is "test" and there is only one column named "sname". As I am a beginner, simpler techniques will be appreciated.Thanks in advance.

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

public class Ex_test extends JFrame implements ActionListener
{
    public static void main(String[] args) 
    {
        Ex_test ob=new Ex_test();
    }
    JTextField tf1;
    JButton b1;
    int num1;
    public Ex_test()
    {
    super("test");
    setLayout(new FlowLayout());

    tf1=new JTextField(20);
    add(tf1);

    b1=new JButton("ok");
    add(b1);

    setSize(500,500);
    setVisible(true);

    b1.addActionListener(this);

    }
    public void actionPerformed(ActionEvent ae)
    {
        if (ae.getActionCommand()=="ok")
        {   
            try
            {   
                String str=tf1.getText();
                Connection con;
                PreparedStatement ps;
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con=DriverManager.getConnection("jdbc:odbc:test");
                ps=con.prepareStatement("insert into test values('"+str+"')");
                ps.executeUpdate();
                con.close();
                ps.close();
                JOptionPane.showMessageDialog(null,"DATA SUBMITTED SUCCESSFULLY.");
            }
            catch (Exception e)
            {
                JOptionPane.showMessageDialog(null,"Exception Occurred.");
            }

        }
    }
}

```