FocusTraversalPolicy
Hello,
I made a little program that use the FocusTraversalPolicy but i can't run it because i get an error.
can someone help me and give an answer why i get this error.
My program:
import java.awt.*;
public class Movebetween extends Frame {
TextField [] textin=new TextField[4];
TextField t1,t2,t3,t4;
static ControlFoc newPolicy;
public Movebetween (String caption)
{
newPolicy=new ControlFoc();
Panel p=new Panel();
for (int i=0;i < textin.length;i++)
{
textin=new TextField(30);
}
p.setLayout(new FlowLayout());
for (int i=0;i < textin.length;i++)
{
p.add(textin);
}
add(p);
pack();
p.setFocusTraversalPolicy(newPolicy);
setVisible(true);
}
public static void main (String[] args)
{
Movebetween b=new Movebetween("Checking Focus");
}
}
class ControlFoc extends FocusTraversalPolicy
{
public Component getComponentAfter (Container c,Component aComponent)
{
if (aComponent.equals(textin[0]))
return textin[2];
}
public Component getComponentBefore (Container c,Component t2)
{
return t2;
}
public Component getDefaultComponent (Container focusCycleRoot)
{
return textin[0];
}
public Component getFirstComponent(Container focusCycleRoot) {
return focusCycleRoot;
}
/*public Component getInitialComponent (Container focusCycleRoot)
{
return t2;
}*/
public Component getLastComponent (Container focusCycleRoot)
{
return textin[3];
}
}
the problem in the rountine:getComponentAfter,getDefaultComponent,getLastComponent
The error seems to be realted to that that i didn't define the array textin of the textfield ,and that not clear to me ,because i define it.
thanks in advance.

