Array de textField
Publicado por joseba (33 intervenciones) el 05/03/2002 05:01:51
Quiero crear un array de textfield y lo hago asi:
import java.awt.*;
import com.borland.jbcl.layout.*;
import com.borland.jbcl.control.*;
public class Prueba2 extends Frame {
XYLayout xYLayout1 = new XYLayout();
public int y=0;
TextField prueba[] = new TextField[2];
public Prueba2() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setBackground(Color.lightGray);
this.setLayout(xYLayout1);
for ( int i = 0;i<2;i++)
{
prueba[i].setName("prueba" + i);
prueba[i].setText("");
}
for (int i=0;i<2;i++)
{
this.add(prueba[0], new XYConstraints(31, 22, 194, 36));
this.add(prueba[1], new XYConstraints(31, 56, 194, 36));
}
}
}
Lo q pasa es q al llamarle para visualizarlo me da el siguiente problema:
java.lang.NullPointerException
at jbInit
at init
at programa.
Programa es la clase q tiene el maun y donde le llamo al frame.
Gracias.
import java.awt.*;
import com.borland.jbcl.layout.*;
import com.borland.jbcl.control.*;
public class Prueba2 extends Frame {
XYLayout xYLayout1 = new XYLayout();
public int y=0;
TextField prueba[] = new TextField[2];
public Prueba2() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setBackground(Color.lightGray);
this.setLayout(xYLayout1);
for ( int i = 0;i<2;i++)
{
prueba[i].setName("prueba" + i);
prueba[i].setText("");
}
for (int i=0;i<2;i++)
{
this.add(prueba[0], new XYConstraints(31, 22, 194, 36));
this.add(prueba[1], new XYConstraints(31, 56, 194, 36));
}
}
}
Lo q pasa es q al llamarle para visualizarlo me da el siguiente problema:
java.lang.NullPointerException
at jbInit
at init
at programa.
Programa es la clase q tiene el maun y donde le llamo al frame.
Gracias.
Valora esta pregunta


0