i try create a window but i got the following error Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at CreateProject.Window.main(Window.java:20) enter code here
public static void main(String[] args) {
JFrame frame = new JFrame("gtrged");
JLabel[] labels=new JLabel[6];
for (int i=0;i<10;i++)
{
labels[i]=new JLabel("Column" + i);
}
JTextField[] txt = new JTextField[3];
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints cst = new GridBagConstraints();
JScrollBar vbar=new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 500);
int f=0;
for(int i =0 ; i<6 ;i++)
{
cst.fill = GridBagConstraints.HORIZONTAL;
cst.gridx = 0;
cst.gridy = f;//
cst.gridwidth = 2;
panel.add(labels[i],cst);
for(int j=0 ; j<3 ; j++)
{ f=f+1;
int ks=0;
cst.fill = GridBagConstraints.HORIZONTAL;
cst.gridx = 0;
cst.gridy = f;//
cst.gridwidth = 2;
panel.add(txt[ks],cst);
ks++;
}
f=f+1;
}
frame.getContentPane().add(vbar, BorderLayout.EAST);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1300,700);
frame.getContentPane().add(panel);
frame.setVisible(true);
}