I wrote this code and I wonder if you guys can help me figure out how to make my application close whenever i enter the name "Bob/BOB/bob" in text1.
public class Event extends JFrame {
    //create items
    private JTextField text1;
    private JTextField text2;
    private JTextField text3;
    private JPasswordField pass1;
    public Event(){
        super("The title");
        setLayout(new FlowLayout());
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        text1 = new JTextField(10);
        add(text1); 
        text2 = new JTextField("enter text here");
        add(text2);
        text3 = new JTextField("uneditbale", 15);
        text3.setEditable(false);
        add(text3); 
        pass1 = new JPasswordField("enter your password", 10);
        add(pass1);
        //create object
        thehandler handler = new thehandler();
        text1.addActionListener(handler);
        text2.addActionListener(handler);
        text3.addActionListener(handler);
        pass1.addActionListener(handler);
        //constructor Event ends
    }
    private class thehandler implements ActionListener{
        public void actionPerformed(ActionEvent event){
            String string = "";
            if(event.getSource()==text1)
                string=String.format("field 1: %s",event.getActionCommand());
            else if(event.getSource()==text2)
                string=String.format("field 2: %s",event.getActionCommand());
            else if(event.getSource()==text3)
                string=String.format("field 3: %s",event.getActionCommand());
            else if(event.getSource()==pass1)
                string=String.format("Password is : %s",event.getActionCommand());
            JOptionPane.showMessageDialog(null, string);
        }
    }
    public static void main(String[] args) {
        Event ev = new Event();
        ev.setSize(350, 100);
        ev.setVisible(true);
    }
}
 
     
     
     
     
     
    