Hi,
In my program i have 6 arrays of checkboxes each array has 6 checkboxes
I want to add an Action Listener to each array of checkboxes, and I do not know how to do it, could anyone give me an example pleaseCode:// declaring the arrays JCheckBox[] pre = new JCheckBox[7]; JCheckBox[] expr = new JCheckBox[7]; JCheckBox[] mot = new JCheckBox[7]; JCheckBox[] res = new JCheckBox[7]; JCheckBox[] dyn = new JCheckBox[7]; JCheckBox[] appr = new JCheckBox[7]; // initialising the checkboxes for (int j=0 ; j<=6 ; j++){ pre[j] = new JCheckBox("0"+j); expr[j] = new JCheckBox("1"+j); mot[j] = new JCheckBox("2"+j); res[j] = new JCheckBox("3"+j); dyn[j] = new JCheckBox("4"+j); appr[j] = new JCheckBox("5"+j); } int top=170; int left=10; for(int x=0;x<=6;x++){ jPanel2.add(pre[x], new XYConstraints(top+x*40, left, 30, 20)); jPanel2.add(expr[x], new XYConstraints(top+x*40, left+20, 30, 18)); jPanel2.add(mot[x], new XYConstraints(top+x*40, left+40, 30, 18)); jPanel2.add(res[x], new XYConstraints(top+x*40, left+60, 30, 18)); jPanel2.add(dyn[x], new XYConstraints(top+x*40, left+80, 30, 18)); jPanel2.add(appr[x], new XYConstraints(top+x*40, left+100, 28, 19)); }
Your help is appreciated, many thanks in advance




Reply With Quote