Limpar todos os campos TextField de um JFrame

1 resposta
B

Olá.

Como faço para limpar todos o JTextField de um JFrame com o laço?

for (int i=0; i<this.getComponnentCount(); i++)

if (this.getComponnent(i) == JTextField)

thisgetComponnent(i).setText(null);

…algo assim.

[]s!

1 Resposta

B

…respondendo:

Para Limpar todos os campos (J)TextField:

private void limpaCampos()
{

for (int i=0; i&lt; jPanel1.getComponentCount(); i++) {
        if (this.jPanel1.getComponent(i) instanceof javax.swing.JTextField) {
            javax.swing.JTextField x = (javax.swing.JTextField) jPanel1.getComponent(i);
            x.setText(null);
        }
    }
}

…quem procura acha =D

[/b]

Criado 29 de abril de 2007
Ultima resposta 29 de abr. de 2007
Respostas 1
Participantes 1