in this part of the code which i'm using to search if an account number given by the user is in the vector.
what is the cause of the problem ?
thanks in advance.

if (ae.getSource() == b7) {
            boolean found = false;

            for (int i = 0; i < vector.size(); i++) {
                if (((Cuenta) vector.get(i)).obtenNumero() == Integer  
                        .parseInt(t1.getText())) {
                    found = true; // if found sets bool to true
                }
                if (found) { // if found shows the message
                    ta1.append("Si esta.\n");
                } else { // if not found shows the message
                    ta1.append("No esta.\n");
                }
                t1.setText("");
            }
        }

i'm getting this error

Exception in thread "AWT-EventQueue-1" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at AppletActividad2.actionPerformed(AppletActividad2.java:121)
    at java.awt.Button.processActionEvent(Unknown Source)
    at java.awt.Button.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

this is the complete code

import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

// <applet width="400" height="470" code="AppletActividad2"></applet>
public class AppletActividad2 extends Applet implements ActionListener {
    Label l1, l2, l3, l4;
    Button b1, b2, b3, b4, b5, b6, b7, b8;
    TextField t1, t2, t3;
    TextArea ta1;
    Vector vector;
    Panel p1, p2, p3;

    public AppletActividad2() {
        setBackground(Color.cyan);
        setForeground(Color.blue);
        l1 = new Label("Numero");
        l2 = new Label("Nombre");
        l3 = new Label("Saldo");
        l4 = new Label("Texto para ver Vector");
        t1 = new TextField(8);
        t2 = new TextField(20);
        t3 = new TextField(12);
        ta1 = new TextArea(10, 20);
        b1 = new Button("Añade");
        b2 = new Button("Muestra Vector");
        b3 = new Button("Limpia Vector");
        b4 = new Button("Limpia Campos");
        b5 = new Button("Borra Numero");
        b6 = new Button("Borra Todos");
        b7 = new Button("Buscar Numero");
        b8 = new Button("Arriba saldo");
        p1 = new Panel(new GridLayout(3, 2, 5, 5));
        p2 = new Panel(new FlowLayout());
        p3 = new Panel(new GridLayout(4, 2, 5, 5));
        setLayout(new GridLayout(3, 1, 5, 5));
        p1.add(l1);
        p1.add(t1);
        p1.add(l2);
        p1.add(t2);
        p1.add(l3);
        p1.add(t3);
        p2.add(l4);
        p2.add(ta1);
        p3.add(b1);
        p3.add(b2);
        p3.add(b3);
        p3.add(b4);
        p3.add(b5);
        p3.add(b6);
        p3.add(b7);
        p3.add(b8);
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
        b5.addActionListener(this);
        b6.addActionListener(this);
        b7.addActionListener(this);
        b8.addActionListener(this);
        vector = new Vector();
        add(p1);
        add(p2);
        add(p3);
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == b1) {
            int numero = Integer.parseInt(t1.getText());
            String nombre = t2.getText();
            double saldo = Double.parseDouble(t3.getText());
            vector.add(new Cuenta(numero, nombre, saldo));
            t1.setText("");
            t2.setText("");
            t3.setText("");
        }
        if (ae.getSource() == b2) {
            ta1.setText("");
            for (int i = 0; i < vector.size(); i++) {
                ta1.append("" + ((Cuenta) vector.get(i)).toString() + "\n");
            }
        }
        if (ae.getSource() == b3) {
            vector = new Vector();
        }
        if (ae.getSource() == b4) {
            t1.setText("");
            ta1.setText("");
        }
        // borra numero
        if (ae.getSource() == b5) {

            for (int i = 0; i < vector.size(); i++) {
                if (((Cuenta) vector.get(i)).obtenNumero() == Integer
                        .parseInt(t1.getText())) {
                    vector.remove(i);

                }
            }
            t1.setText("");
        }
        // borra todos
        if (ae.getSource() == b6) {
            vector.removeAll(vector);
        }
        // busca numero
        if (ae.getSource() == b7) {
            boolean found = false;

            for (int i = 0; i < vector.size(); i++) {
                if (((Cuenta) vector.get(i)).obtenNumero() == Integer
                        .parseInt(t1.getText())) {
                    found = true;
                }
                if (found) { // si lo encuentra
                    ta1.append("Si esta.\n");
                } else { // si no lo encuentra
                    ta1.append("No esta.\n");
                }
                t1.setText("");
            }
        }
        // arriba saldo
        if (ae.getSource() == b8) {
            boolean found = false;
            ta1.setText("");
            for (int i = 0; i < vector.size(); i++) {
                if (((Cuenta) vector.get(i)).obtenSaldo() > Double
                        .parseDouble(t3.getText())) {
                    ta1.append("" + ((Cuenta) vector.get(i)).toString() + "\n");
                    found = true;
                }
            }
            if (!found) {
                ta1.append("No se encontro ningun\n" +
                        " saldo mayor.\n");
            }
        }
    }
}

this is the class

public class Cuenta {
    private String nombre; // nombre del cliente
    private int numero; // numero de la cuenta
    private double saldo; // saldo de la cuenta

    // método para construir una cuenta vacía

    public Cuenta() {
        nombre = "";
        numero = 0;
        saldo = 0.0d;
    }

    // método para construir una cuenta con valores
    public Cuenta(int numero, String nombre, double saldo) {
        this.nombre = nombre;
        this.numero = numero;
        this.saldo = saldo;
    }

    // método que te dá el nombre de la cuenta
    public String obtenNombre() {
        return nombre;
    }

    // método que te dá el número de la cuenta
    public int obtenNumero() {
        return numero;
    }

    // método que te dá el saldo de una cuenta
    public double obtenSaldo() {
        return saldo;
    }

    // método que sirve para cambiar el valor del nombre
    public void cambiaNombre(String nombre) {
        this.nombre = nombre;
    }

    // método que sirve para cambiar el valor del saldo
    public void cambiaNumero(int numero) {
        this.numero = numero;
    }

    // método que sirve para cambiar el valor del saldo
    public void cambiaSaldo(double saldo) {
        this.saldo = saldo;
    }

    // metodo para depositar
    public void deposita(double cantidad) {
        cambiaSaldo(obtenSaldo() + cantidad);
    }

    // metodo para retirar
    public boolean retira(double cantidad) {
        if (cantidad <= obtenSaldo()) {
            cambiaSaldo(obtenSaldo() - cantidad);
            return true;
        }
        return false;
    }

    // metodo para regresar un String como objeto
    public String toString() {
        return obtenNumero() + " " + obtenNombre() + " " + obtenSaldo();
    }
}

already solved it
the problem was

 if (((Cuenta) vector.get(i)).obtenNumero() == Integer
.parseInt(t1.getText()))

so i replaced it to

int search = Integer.parseInt(t1.getText());

this is how that part of the code looks now and is working ok.

if (ae.getSource() == b7) {
            boolean found = false;
            int search = Integer.parseInt(t1.getText());
            for (int i = 0; i < vector.size(); i++) {
                // ta1.append("\nnumero " + ((Cuenta)
                // vector.get(i)).obtenNumero());
                if (((Cuenta) vector.get(i)).obtenNumero() == search) {
                    found = true;
                }
            }
            if (found) { // si lo encuentra
                ta1.append("Si esta.\n");
            } else { // si no lo encuentra
                ta1.append("No esta.\n");
            }
            t1.setText("");
        }

I hate it to tell you, but that wasn't per se the problem. the problem was that your value in the JTextField t1 wasn't filled in. at this point, if you forget to put a (valid) value there, being a numeric value (no decimals) and not bigger (or smaller) than the boundaries of an int, you'll still land the same problem.
you'll need to validate the value of that textfield before trying to make the conversion to a correct NumberFormat.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.