Java - Caja de texto actualizable

 
Vista:

Caja de texto actualizable

Publicado por josejorr (1 intervención) el 17/04/2009 14:28:02
Necesito que el texto de una caja de texto se vaya actualizando en funcion de un bucle for.
El problema es que me presenta solo la informacion del ultimo valor que toma la variable del for en este caso el 5, me podrian decir como podria hacerlo?

public PruebaEtiqueta()
{
super( "Prueba de JLabel" );

// obtener panel de contenido y establecer su esquema
Container contenedor = getContentPane();
contenedor.setLayout( new FlowLayout() );


// constructor de JLabel con un argumento cadena, constructor de TextField ( Campo de Texto)

etiqueta = new JLabel( "Etiqueta con texto");
etiqueta.setToolTipText( "Esta es la etiqueta");
etiqueta.setText("TELEFONO:");
contenedor.add( etiqueta );
TextField telefono;
telefono= new TextField();
contenedor.add( telefono );

// Declaracion de variables

String telefono1 = new String( "111111111" );
String telefono2 = new String( "222222222" );
String telefono3 = new String( "333333333" );
String telefono4 = new String( "444444444" );
String telefono5 = new String( "555555555" );

for(int i=1; i<=5; i++) {

String tel = new String ("telefono"+Integer.toString(i));

Integer num = new Integer(tel);
String numero = new String (Integer.toString(num));
telefono.setText(numero);

}

setSize( 400, 170 ); // define tamaño ventana.
setVisible( true ); // Propiedad ventana visible.

}
// Fin Del Metodo PruebaEtiqueta

// fin del constructor

Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Caja de texto actualizable

Publicado por Eduardo (2 intervenciones) el 17/04/2009 22:17:44
La clase Thread, del paquete java.lang , cuenta con metodo que se emplea para retardar la ejecución de código es “void sleep(long retardo)”.

coloca
..........
..........
..........
Thread.sleep(3000) //Introduce un retardo de 3 segundos
telefono.setText(numero);
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar