trying to make the checklist add up

I am designing a prototype of a learning style which has 12 question and 5 checkboxs and a user will only need to check two out the 5 checkboxs, and then it add up the results of how many A, B, C, D or E's that was checked i dont know how i'm goin to that here is a piece of code i wrote can you please help me thankx.

[code]

pls take a look at this code run it and i'll tell you what it's suppose to do.. [code]

import java.applet.Applet;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.InputEvent;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.KeyEvent;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import javax.swing.JFileChooser;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.KeyStroke;

public class CheckPanel extends Applet{

CheckboxPanel panel1, panel2, panel3, panel4;

ItemListener iListener;

boolean state;

/*protected JFileChooser m_chooser;

//protected File m_currentFile;

//JMenuBar menuBar = createMenuBar();

//void JMenuBar(menuBar);

//m_chooser = new JFileChooser();

//try {

File dir = (new File (".")).getCanonicalFile();

m_chooser.setCurrentDirectory(dir);

} catch (IOException ex){}

updateEditor();

newDocument();

WindowListener wndCloser = new WindowAdapter(){

public void windowClosing(WindowEvent e){

if (!promptToSave())

return;

System.exit(0);

}

};

addWindowListener(wndCloser);

}

protected JMenuBar createMenuBar(){

final JMenuBar menuBar = new JMenuBar();

JMenu mFile = new JMenu("File");

mFile.setMnemonic('f');

JMenuItem item = new JMenuItem("New");

item.setMnemonic('n');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

ActionListener lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean promptToSave;

if (!promptToSave);

return;

newDocument();

}

private void newDocument() {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Open...");

item.setMnemonic('o');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean promptToSave;

if (!promptToSave);

return;

openDocument();

}

private void openDocument() {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Save");

item.setMnemonic('s');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean m_textChanged;

if (!m_textChanged)

return ;

saveFile(false);

}

private void saveFile(boolean b) {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Save As..");

item.setMnemonic('a');

lst = new ActionListener(){

public void actionperformed(ActionEvent e){

saveFile(true);

}

private void saveFile(boolean b) {

// TODO Auto-generated method stub

}

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

mFile.addSeparator();

item = new JMenuItem("Exit");

item.setMnemonic('x');

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

System.exit(0);

}

};

item.addActionListener(lst);

mFile.add(item);

menuBar.add(mFile);

return menuBar;

}*/

//isSelected = new Checkbox();

public void init(){

setLayout(new BorderLayout());

setBounds (20, 30, 300, 180);

Panel headerPanel = new Panel();

headerPanel.setLayout(new GridLayout(2,1));

Label lblHeader = new Label("QUIZ 02 Learning Style");

headerPanel.add(lblHeader);

lblHeader = new Label("This quiz..");

Label lblHeader1 = new Label("Please tick two checkboxes for each question...");

headerPanel.add(lblHeader1);

//lblHeader1 = new Label();

headerPanel.add(lblHeader);

add(headerPanel, BorderLayout.NORTH);

//setLayout(new GridLayout(3,1));

panel1 =new CheckboxPanel();

add(panel1, BorderLayout.CENTER);

/*

panel2 = new CheckboxPanel();

add(panel2);

panel3 =new CheckboxPanel();

add(panel3);

panel4 =new CheckboxPanel();

add(panel4);

*/

}

public static final long serialVersionUID = 1L;

Checkbox check1, check2, check3, check4, check5;

void CheckboxPanel(){

setLayout(new GridLayout(4,1));

setBackground(Color.gray);

check1 = new Checkbox("1");

add(check1);

//isSelected = new Checkbox();

check1.addItemListener((ItemListener) this);

getContentPane().add(check1);// set checked state of box

check2 = new Checkbox("2");

add(check2);

check2.addItemListener((ItemListener) this);

getContentPane().add(check2);

check3 = new Checkbox("3");

add(check3);

check3.addItemListener((ItemListener) this);

getContentPane().add(check3);

check4 = new Checkbox("4");

add(check4);

check4.addItemListener((ItemListener) this);

getContentPane().add(check4);

//check5 = new Checkbox("5");

//add(check5);

}

public void itemStateChanged(ItemEvent e) {

int index = 0;

char a = '-';

Object source = e.getItemSelectable();

if (source == check1) {

index = 0;

a = 'a';

} else if (source == check2) {

index = 1;

a = 'b';

} else if (source == check3) {

index = 2;

a = 'c';

} else if (source == check4) {

index = 3;

a = 'd';

}

if (e.getStateChange() == ItemEvent.DESELECTED) {

a = '-';

}

//choices.setCharAt(index, a);

//System.out.println("hello");

}

private File newFile(String data) throws IOException {

// TODO Auto-generated method stub

File newfile = newFile("I:\\ouput.txt");

System.out.println("DATA? - " + data);

FileOutputStream fos = new FileOutputStream(newfile);

fos.write(data.getBytes());

fos.close();

JOptionPane.showMessageDialog(null, "Save File");

return null;

}

private Container getContentPane() {

// TODO Auto-generated method stub

return null;

}

}

import java.awt.*;

//import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ComponentListener;

//import java.awt.event.InputEvent;

import java.awt.event.ItemListener;

//import java.awt.event.KeyEvent;

//import java.io.File;

//import java.lang.reflect.Array;

import javax.swing.JButton;

//import javax.swing.JDialog;

import javax.swing.JMenuBar;

//import javax.swing.*;

//import javax.swing.event.*;

//import javax.swing.JToggleButton;

public class CheckboxPanel extends Panel{

ItemListener iListener;

boolean state;

Button button1;

// public static Object newInstance(Class componentType,

//int length){

// }

/**

*

*

*/

public static final long serialVersionUID = 1L;

//public static final char k = 0;

Checkbox[] check = new Checkbox[61];

//Checkbox check1, check2, check3, check4, check5 , check6 ,check7 ,check8 ,check9 ,check10 ,check11 ,check12 ,check13 ,

//check14 ,check15 ,check16 ,check17 ,check18 ,check19 ,check20 ,check21 ,check22 ,check23 ,check24 ,check25 ,check26 ,

//check27 ,check28 ,check29 ,check30 ,check31 ,check32 ,check33 ,check34 ,check35 ,check36 ,check37 ,check38 ,check39 ,

//check40 ,check41 ,check42 ,check43 ,check44 ,check45 ,check46 ,check47 ,check48 ,check49 ,check50 ,check51 ,check52 ,

//check53 ,check54 ,check55 ,check56 ,check57 ,check58 ,check59 ,check60,

//isSelected = new Checkbox();

protected int group1,group2,group3,group4,group5,group6,group7,group8,group9,group10,group11,group12,group13,group14,group15;

//int[] CheckBox = {k};

//Array.newInstance(private Checkbox check6;

// state of checkbox

CheckboxPanel(){

setLayout(new GridLayout(4,4));

setBackground(Color.gray);

/* Question 1 layout panel */

// Create a panel for the question and answers

Panel question1Panel = new Panel();

question1Panel.setLayout(new GridLayout(1, 2));

// Create a label for the question number

Label lbl = new Label("1");

// Add it to the question panel so it appears on the right

question1Panel.add(lbl);

// Add a panel for the answers to the question

Panel answer1Panel = new Panel();

// Use a grid layout of 4 rows by 1 column

answer1Panel.setLayout(new GridLayout(4,1));

//CheckBox.addActionListener(new ActionListener(){

//public void actionPerformed(ActionEvent ae)

//{

// System.out.println("check box state"+check.getState());

// }

check[1] = new Checkbox("A. Imaginative");

answer1Panel.add(check[1]);

//check1.addItemListener(iListener);

//state = check1.isSeleted() ; // tells whether box is checked

//check1.setSelected(state);

//getContentPane().add(check1);// set checked state of box

check[2] = new Checkbox("B. Investigative");

answer1Panel.add(check[2]);

//check1.addItemListener(iListener);

//state = check1.isSeleted() ; // tells whether box is checked

//check1.setSelected(state);

//getContentPane().add(check1);// set checked state of box

check[3] = new Checkbox("C. Realistic");

answer1Panel.add(check[3]);

check[4] = new Checkbox("D. Analytical");

answer1Panel.add(check[4]);

question1Panel.add(answer1Panel);

add(question1Panel);

/* Question 2 layout panel */

Panel question2Panel = new Panel();

question2Panel.setLayout(new GridLayout(1,2));

lbl = new Label("2");

question2Panel.add(lbl);

Panel answer2Panel = new Panel();

answer2Panel.setLayout(new GridLayout(4,1));

check[5] = new Checkbox("A. Organized");

answer2Panel.add(check[5]);

check[6]= new Checkbox("B. Adaptable");

answer2Panel.add(check[6]);

check[7] = new Checkbox("C. Critical");

answer2Panel.add(check[7]);

check[8] = new Checkbox("D. Inquisitive");

answer2Panel.add(check[8]);

question2Panel.add(answer2Panel);

add(question2Panel);

/* Question 3 layout panel*/

Panel question3Panel= new Panel();

question3Panel.setLayout(new GridLayout(1,2));

lbl = new Label("3");

question3Panel.add(lbl);

Panel answer3Panel = new Panel();

answer3Panel.setLayout(new GridLayout(4,1));

check[9] = new Checkbox("A. Debating");

answer3Panel.add(check[9]);

check[10] = new Checkbox("B.Getting to the point");

answer3Panel.add(check[10]);

check[11] = new Checkbox("C. Creating");

answer3Panel.add(check[11]);

check[12] = new Checkbox("D. Relating");

answer3Panel.add(check[12]);

question3Panel.add(answer3Panel);

add(question3Panel);

/* Question 4 layout panel*/

Panel question4Panel= new Panel();

question4Panel.setLayout(new GridLayout(1,2));

lbl = new Label("4");

question4Panel.add(lbl);

Panel answer4Panel = new Panel();

answer4Panel.setLayout(new GridLayout(4,1));

check[13] = new Checkbox("A. Personal");

answer4Panel.add(check[13]);

check[14] = new Checkbox("B. Practical");

answer4Panel.add(check[14]);

check[15] = new Checkbox("C. Academic");

answer4Panel.add(check[15]);

check[16] = new Checkbox("D. Adventurous");

answer4Panel.add(check[16]);

question4Panel.add(answer4Panel);

add(question4Panel);

/* Question 5 layout panel*/

Panel question5Panel= new Panel();

question5Panel.setLayout(new GridLayout(1,2));

lbl = new Label("5");

question5Panel.add(lbl);

Panel answer5Panel = new Panel();

answer5Panel.setLayout(new GridLayout(4,1));

check[17] = new Checkbox("A. Presice");

answer5Panel.add(check[17]);

check[18 ]= new Checkbox("B. Flexible");

answer5Panel.add(check[18]);

check[19] = new Checkbox("C. Systematic");

answer5Panel.add(check[19]);

check[20] = new Checkbox("D. Inventive");

answer5Panel.add(check[20]);

question5Panel.add(answer5Panel);

add(question5Panel);

/* Question 6 layout panel*/

Panel question6Panel= new Panel();

question6Panel.setLayout(new GridLayout(1,2));

lbl = new Label("6");

question6Panel.add(lbl);

Panel answer6Panel = new Panel();

answer6Panel.setLayout(new GridLayout(4,1));

check[21] = new Checkbox("A. Sharing");

answer6Panel.add(check[21]);

check[22]= new Checkbox("B. Orderly");

answer6Panel.add(check[22]);

check[23] = new Checkbox("C. Sensible");

answer6Panel.add(check[23]);

check[24] = new Checkbox("D. Independent");

answer6Panel.add(check[24]);

question6Panel.add(answer6Panel);

add(question6Panel);

/* Question 7 layout panel*/

Panel question7Panel= new Panel();

question7Panel.setLayout(new GridLayout(1,2));

lbl = new Label("7");

question7Panel.add(lbl);

Panel answer7Panel = new Panel();

answer7Panel.setLayout(new GridLayout(4,1));

check[25] = new Checkbox("A. Competitive");

answer7Panel.add(check[25]);

check[26] = new Checkbox("B. Perfectionist");

answer7Panel.add(check[26]);

check[27] = new Checkbox("C. Cooperative");

answer7Panel.add(check[27]);

check[28] = new Checkbox("D. Logical");

answer7Panel.add(check[28]);

question7Panel.add(answer7Panel);

add(question7Panel);

/* Question 8 layout panel*/

Panel question8Panel= new Panel();

question8Panel.setLayout(new GridLayout(1,2));

lbl = new Label("8");

question8Panel.add(lbl);

Panel answer8Panel = new Panel();

answer8Panel.setLayout(new GridLayout(4,1));

check[29] = new Checkbox("A. Intellectual");

answer8Panel.add(check[29]);

check[30] = new Checkbox("B. Sensitive");

answer8Panel.add(check[30]);

check[31] = new Checkbox("C. Hard-working");

answer8Panel.add(check[31]);

check[32] = new Checkbox("D. Risk-taking");

answer8Panel.add(check[32]);

question8Panel.add(answer8Panel);

add(question8Panel);

/* Question 9 layout panel*/

Panel question9Panel= new Panel();

question9Panel.setLayout(new GridLayout(1,2));

lbl = new Label("9");

question9Panel.add(lbl);

Panel answer9Panel = new Panel();

answer9Panel.setLayout(new GridLayout(4,1));

check[33] = new Checkbox("A. Reader");

answer9Panel.add(check[33]);

check[34] = new Checkbox("B. People person");

answer9Panel.add(check[34]);

check[35] = new Checkbox("C. Problem solver");

answer9Panel.add(check[35]);

check[36] = new Checkbox("D. Planner");

answer9Panel.add(check[36]);

question9Panel.add(answer9Panel);

add(question9Panel);

/* Question 10 layout panel*/

Panel question10Panel= new Panel();

question10Panel.setLayout(new GridLayout(1,2));

lbl = new Label("10");

question10Panel.add(lbl);

Panel answer10Panel = new Panel();

answer10Panel.setLayout(new GridLayout(4,1));

check[37] = new Checkbox("A. Memorize");

answer10Panel.add(check[37]);

check[38] = new Checkbox("B. Associate");

answer10Panel.add(check[38]);

check[39] = new Checkbox("C. Think-through");

answer10Panel.add(check[39]);

check[40] = new Checkbox("D. Originate");

answer10Panel.add(check[40]);

question10Panel.add(answer10Panel);

add(question10Panel);

/* Question 11 layout panel*/

Panel question11Panel= new Panel();

question11Panel.setLayout(new GridLayout(1,2));

lbl = new Label("11");

question11Panel.add(lbl);

Panel answer11Panel = new Panel();

answer11Panel.setLayout(new GridLayout(4,1));

check[41] = new Checkbox("A. Changer");

answer11Panel.add(check[41]);

check[42] = new Checkbox("B. Judger");

answer11Panel.add(check[42]);

check[43] = new Checkbox("C. Spontaneous");

answer11Panel.add(check[43]);

check[44] = new Checkbox("D. Wants direction");

answer11Panel.add(check[44]);

question11Panel.add(answer11Panel);

add(question11Panel);

/* Question 12 layout panel*/

Panel question12Panel= new Panel();

question12Panel.setLayout(new GridLayout(1,2));

lbl = new Label("12");

question12Panel.add(lbl);

Panel answer12Panel = new Panel();

answer12Panel.setLayout(new GridLayout(4,1));

check[45] = new Checkbox("A. Communicating");

answer12Panel.add(check[45]);

check[46] = new Checkbox("B. Discovering");

answer12Panel.add(check[46]);

check[47] = new Checkbox("C. Caring");

answer12Panel.add(check[47]);

check[48] = new Checkbox("D. Examining");

answer12Panel.add(check[48]);

question12Panel.add(answer12Panel);

add(question12Panel);

/* Question 13 layout panel*/

Panel question13Panel= new Panel();

question13Panel.setLayout(new GridLayout(1,2));

lbl = new Label("13");

question13Panel.add(lbl);

Panel answer13Panel = new Panel();

answer13Panel.setLayout(new GridLayout(4,1));

check[49] = new Checkbox("A. Challenging");

answer13Panel.add(check[49]);

check[50] = new Checkbox("B. Practicing");

answer13Panel.add(check[50]);

check[51] = new Checkbox("C. Caring");

answer13Panel.add(check[51]);

check[52] = new Checkbox("D. Examining");

answer13Panel.add(check[52]);

question13Panel.add(answer13Panel);

add(question13Panel);

/* Question 14 layout panel*/

Panel question14Panel= new Panel();

question13Panel.setLayout(new GridLayout(1,2));

lbl = new Label("14 ");

question14Panel.add(lbl);

Panel answer14Panel = new Panel();

answer14Panel.setLayout(new GridLayout(4,1));

check[53] = new Checkbox("A. Completing work");

answer14Panel.add(check[53]);

check[54] = new Checkbox("B. Seeing possibilities");

answer14Panel.add(check[54]);

check[55] = new Checkbox("C. Gaining ideas");

answer14Panel.add(check[55]);

check[56] = new Checkbox("D. Interpreting");

answer14Panel.add(check[56]);

question14Panel.add(answer14Panel);

add(question14Panel);

/* Question 15 layout panel*/

Panel question15Panel= new Panel();

question15Panel.setLayout(new GridLayout(1,2));

lbl = new Label("15");

question15Panel.add(lbl);

Panel answer15Panel = new Panel();

answer15Panel.setLayout(new GridLayout(4,1));

check[57] = new Checkbox("A. Doing");

answer15Panel.add(check[57]);

check[58] = new Checkbox("B. Feeling");

answer15Panel.add(check[58]);

check[59] = new Checkbox("C. Thinking");

answer15Panel.add(check[59]);

check[60] = new Checkbox("D. Experimenting");

answer15Panel.add(check[60]);

question15Panel.add(answer15Panel);

add(question15Panel);

/*class ToggleButton extends JFrame{

public ToggleButton(){

super("ToggleButton");

getContentPane().setLayout(new FlowLayout());

ButtonGroup buttonGroup =new ButtonGroup();

char ch = (char) ('1'+ k);

for (int k=0; k<4; k++){

JToggleButton button = new JToggleButton("Button"+ch, k==0);

button.setMnemonic(ch);

button.setEnabled(k<3);

button.setToolTipText("This is button"+ ch);

getContentPane().add(button);

buttonGroup.add(button);

}

//pack();

}

}*/

JButton button1 = new JButton("SUBMIT");

//Object BOX_TITLE;

//JDialog dialog = Panel.createDialog(Dialog.this, BOX_TITLE);

//dialog.show();

add(button1);

addComponentListener((ComponentListener) iListener);

ActionListener al = new ActionListener(){

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

if (check[1].getState()== true){

group1 = group1 +1;

}

if (check[2].getState()== true){

group1 = group1 +1;

}

if (check[3].getState()== true){

group1 = group1 +1;

}

if (check[4].getState()== true){

group1 = group1 +1;

}

if (check[5].getState()== true){

group2 = group2 +1;

}

if (check[6].getState()== true){

group2 = group2 +1;

}

if (check[7].getState()== true){

group2 = group2 +1;

}

if (check[8].getState()== true){

group2 = group2 +1;

}

if (check[9].getState()== true){

group3 = group3 +1;

}

if (check[10].getState()== true){

group3 = group3 +1;

}

if (check[11].getState()== true){

group3 = group3 +1;

}

if (check[12].getState()== true){

group3 = group3 +1;

}

if (check[13].getState()== true){

group4 = group4 +1;

}

if (check[14].getState()== true){

group4 = group4 +1;

}

if (check[15].getState()== true){

group4 = group4 +1;

}

if (check[16].getState()== true){

group4 = group4 +1;

}

if (check[17].getState()== true){

group5 = group5 +1;

}

if (check[18].getState()== true){

group5 = group5 +1;

}

if (check[19].getState()== true){

group5 = group5 +1;

}

if (check[20].getState()== true){

group5 = group5 +1;

}

if (check[21].getState()== true){

group6 = group6 +1;

}

if (check[22].getState()== true){

group6 = group6 +1;

}

if (check[23].getState()== true){

group6 = group6 +1;

}

if (check[24].getState()== true){

group6 = group6 +1;

}

if (check[25].getState()== true){

group7 = group7 +1;

}

if (check[26].getState()== true){

group7 = group7 +1;

}

if (check[27].getState()== true){

group7 = group7 +1;

}

if (check[28].getState()== true){

group7 = group7 +1;

}

if (check[29].getState()== true){

group8 = group8 +1;

}

if (check[30].getState()== true){

group8 = group8 +1;

}

if (check[31].getState()== true){

group8 = group8 +1;

}

if (check[32].getState()== true){

group8 = group8 +1;

}

if (check[33].getState()== true){

group9 = group9 +1;

}

if (check[34].getState()== true){

group9 = group9 +1;

}

if (check[35].getState()== true){

group9 = group9 +1;

}

if (check[36].getState()== true){

group9 = group9 +1;

}

if (check[37].getState()== true){

group10 = group10 +1;

}

if (check[38].getState()== true){

group10 = group10 +1;

}

if (check[39].getState()== true){

group10 = group10 +1;

}

if (check[40].getState()== true){

group10 = group10 +1;

}

if (check[41].getState()== true){

group11 = group11 +1;

}

if (check[42].getState()== true){

group11 = group11 +1;

}

if (check[43].getState()== true){

group11 = group11 +1;

}

if (check[44].getState()== true){

group11 = group11 +1;

}

if (check[45].getState()== true){

group12 = group12 +1;

}

if (check[46].getState()== true){

group12 = group12 +1;

}

if (check[47].getState()== true){

group12 = group12 +1;

}

if (check[48].getState()== true){

group12 = group12 +1;

}

if (check[49].getState()== true){

group13 = group13 +1;

}

if (check[50].getState()== true){

group13 = group13 +1;

}

if (check[51].getState()== true){

group13 = group13 +1;

}

if (check[52].getState()== true){

group13 = group13 +1;

}

if (check[53].getState()== true){

group14 = group14 +1;

}

if (check[54].getState()== true){

group14 = group14 +1;

}

if (check[55].getState()== true){

group14 = group14 +1;

}

if (check[56].getState()== true){

group14 = group14 +1;

}

if (check[57].getState()== true){

group15 = group15 +1;

}

if (check[58].getState()== true){

group15 = group15 +1;

}

if (check[59].getState()== true){

group15 = group15 +1;

}

if (check[60].getState()== true){

group15 = group15 +1;

}

System.out.println(check[1].getState());

System.out.println(check[2].getState());

System.out.println(check[3].getState());

System.out.println(check[4].getState());

System.out.println(check[5].getState());

System.out.println(check[6].getState());

System.out.println(check[7].getState());

System.out.println(check[8].getState());

System.out.println(check[9].getState());

System.out.println(check[10].getState());

System.out.println(check[11].getState());

System.out.println(check[12].getState());

System.out.println(check[13].getState());

System.out.println(check[14].getState());

System.out.println(check[15].getState());

System.out.println(check[16].getState());

System.out.println(check[17].getState());

System.out.println(check[18].getState());

System.out.println(check[19].getState());

System.out.println(check[20].getState());

System.out.println(check[21].getState());

System.out.println(check[22].getState());

System.out.println(check[23].getState());

System.out.println(check[24].getState());

System.out.println(check[25].getState());

System.out.println(check[26].getState());

System.out.println(check[27].getState());

System.out.println(check[28].getState());

System.out.println(check[29].getState());

System.out.println(check[30].getState());

System.out.println(check[31].getState());

System.out.println(check[32].getState());

System.out.println(check[33].getState());

System.out.println(check[34].getState());

System.out.println(check[35].getState());

System.out.println(check[36].getState());

System.out.println(check[37].getState());

System.out.println(check[38].getState());

System.out.println(check[39].getState());

System.out.println(check[40].getState());

System.out.println(check[41].getState());

System.out.println(check[42].getState());

System.out.println(check[43].getState());

System.out.println(check[44].getState());

System.out.println(check[45].getState());

System.out.println(check[46].getState());

System.out.println(check[47].getState());

System.out.println(check[48].getState());

System.out.println(check[49].getState());

System.out.println(check[50].getState());

System.out.println(check[51].getState());

System.out.println(check[52].getState());

System.out.println(check[53].getState());

System.out.println(check[54].getState());

System.out.println(check[55].getState());

System.out.println(check[56].getState());

System.out.println(check[57].getState());

System.out.println(check[58].getState());

System.out.println(check[59].getState());

System.out.println(check[60].getState());

}

};

button1.addActionListener(al);

}

private JMenuBar createMenuBar() {

// TODO Auto-generated method stub

return null;

}

//button1.addActionListener(al);

}

[28810 byte] By [desainta] at [2007-11-27 8:59:21]
# 1
1) http://forum.java.sun.com/help.jspa?sec=formatting2) It's too long for reading anyway3) I'm not going to run anything4) Consider finding out what a "data model" isand why people might use it, instead of keeping all the data in the widgets.
CeciNEstPasUnProgrammeura at 2007-7-12 21:26:38 > top of Java-index,Java Essentials,New To Java...
# 2

am designing a prototype of a learning style which has 12 question and 5 checkboxs and a user will only need to check two out the 5 checkboxs, and then it add up the results of how many A, B, C, D or E's that was checked i dont know how i'm goin to that here is a piece of code i wrote can you please help me thankx. pls take a look at this code run it and i'll tell you what it's suppose to do.. [code]

[code]

import java.applet.Applet;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.InputEvent;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.KeyEvent;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import javax.swing.JFileChooser;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.KeyStroke;

public class CheckPanel extends Applet{

CheckboxPanel panel1, panel2, panel3, panel4;

ItemListener iListener;

boolean state;

/*protected JFileChooser m_chooser;

//protected File m_currentFile;

//JMenuBar menuBar = createMenuBar();

//void JMenuBar(menuBar);

//m_chooser = new JFileChooser();

//try {

File dir = (new File (".")).getCanonicalFile();

m_chooser.setCurrentDirectory(dir);

} catch (IOException ex){}

updateEditor();

newDocument();

WindowListener wndCloser = new WindowAdapter(){

public void windowClosing(WindowEvent e){

if (!promptToSave())

return;

System.exit(0);

}

};

addWindowListener(wndCloser);

}

protected JMenuBar createMenuBar(){

final JMenuBar menuBar = new JMenuBar();

JMenu mFile = new JMenu("File");

mFile.setMnemonic('f');

JMenuItem item = new JMenuItem("New");

item.setMnemonic('n');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

ActionListener lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean promptToSave;

if (!promptToSave);

return;

newDocument();

}

private void newDocument() {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Open...");

item.setMnemonic('o');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean promptToSave;

if (!promptToSave);

return;

openDocument();

}

private void openDocument() {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Save");

item.setMnemonic('s');

item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

boolean m_textChanged;

if (!m_textChanged)

return ;

saveFile(false);

}

private void saveFile(boolean b) {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

item = new JMenuItem("Save As..");

item.setMnemonic('a');

lst = new ActionListener(){

public void actionperformed(ActionEvent e){

saveFile(true);

}

private void saveFile(boolean b) {

// TODO Auto-generated method stub

}

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

}

};

item.addActionListener(lst);

mFile.add(item);

mFile.addSeparator();

item = new JMenuItem("Exit");

item.setMnemonic('x');

lst = new ActionListener(){

public void actionPerformed(ActionEvent e){

System.exit(0);

}

};

item.addActionListener(lst);

mFile.add(item);

menuBar.add(mFile);

return menuBar;

}*/

//isSelected = new Checkbox();

public void init(){

setLayout(new BorderLayout());

setBounds (20, 30, 300, 180);

Panel headerPanel = new Panel();

headerPanel.setLayout(new GridLayout(2,1));

Label lblHeader = new Label("QUIZ 02 Learning Style");

headerPanel.add(lblHeader);

lblHeader = new Label("This quiz..");

Label lblHeader1 = new Label("Please tick two checkboxes for each question...");

headerPanel.add(lblHeader1);

//lblHeader1 = new Label();

headerPanel.add(lblHeader);

add(headerPanel, BorderLayout.NORTH);

//setLayout(new GridLayout(3,1));

panel1 =new CheckboxPanel();

add(panel1, BorderLayout.CENTER);

/*

panel2 = new CheckboxPanel();

add(panel2);

panel3 =new CheckboxPanel();

add(panel3);

panel4 =new CheckboxPanel();

add(panel4);

*/

}

public static final long serialVersionUID = 1;

Checkbox check1, check2, check3, check4, check5;

void CheckboxPanel(){

setLayout(new GridLayout(4,1));

setBackground(Color.gray);

check1 = new Checkbox("1");

add(check1);

//isSelected = new Checkbox();

check1.addItemListener((ItemListener) this);

getContentPane().add(check1);// set checked state of box

check2 = new Checkbox("2");

add(check2);

check2.addItemListener((ItemListener) this);

getContentPane().add(check2);

check3 = new Checkbox("3");

add(check3);

check3.addItemListener((ItemListener) this);

getContentPane().add(check3);

check4 = new Checkbox("4");

add(check4);

check4.addItemListener((ItemListener) this);

getContentPane().add(check4);

//check5 = new Checkbox("5");

//add(check5);

}

public void itemStateChanged(ItemEvent e) {

int index = 0;

char a = '-';

Object source = e.getItemSelectable();

if (source == check1) {

index = 0;

a = 'a';

} else if (source == check2) {

index = 1;

a = 'b';

} else if (source == check3) {

index = 2;

a = 'c';

} else if (source == check4) {

index = 3;

a = 'd';

}

if (e.getStateChange() == ItemEvent.DESELECTED) {

a = '-';

}

//choices.setCharAt(index, a);

//System.out.println("hello");

}

private File newFile(String data) throws IOException {

// TODO Auto-generated method stub

File newfile = newFile("I:\\ouput.txt");

System.out.println("DATA? - " + data);

FileOutputStream fos = new FileOutputStream(newfile);

fos.write(data.getBytes());

fos.close();

JOptionPane.showMessageDialog(null, "Save File");

return null;

}

private Container getContentPane() {

// TODO Auto-generated method stub

return null;

}

}

import java.awt.*;

//import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ComponentListener;

//import java.awt.event.InputEvent;

import java.awt.event.ItemListener;

//import java.awt.event.KeyEvent;

//import java.io.File;

//import java.lang.reflect.Array;

import javax.swing.JButton;

//import javax.swing.JDialog;

import javax.swing.JMenuBar;

//import javax.swing.*;

//import javax.swing.event.*;

//import javax.swing.JToggleButton;

public class CheckboxPanel extends Panel{

ItemListener iListener;

boolean state;

Button button1;

// public static Object newInstance(Class componentType,

//int length){

// }

/**

*

*

*/

public static final long serialVersionUID = 1;

//public static final char k = 0;

Checkbox[] check = new Checkbox[61];

//Checkbox check1, check2, check3, check4, check5 , check6 ,check7 ,check8 ,check9 ,check10 ,check11 ,check12 ,check13 ,

//check14 ,check15 ,check16 ,check17 ,check18 ,check19 ,check20 ,check21 ,check22 ,check23 ,check24 ,check25 ,check26 ,

//check27 ,check28 ,check29 ,check30 ,check31 ,check32 ,check33 ,check34 ,check35 ,check36 ,check37 ,check38 ,check39 ,

//check40 ,check41 ,check42 ,check43 ,check44 ,check45 ,check46 ,check47 ,check48 ,check49 ,check50 ,check51 ,check52 ,

//check53 ,check54 ,check55 ,check56 ,check57 ,check58 ,check59 ,check60,

//isSelected = new Checkbox();

protected int group1,group2,group3,group4,group5,group6,group7,group8,group9,group10,group11,group12,group13,group14,group15;

//int[] CheckBox = {k};

//Array.newInstance(private Checkbox check6;

// state of checkbox

CheckboxPanel(){

setLayout(new GridLayout(4,4));

setBackground(Color.gray);

/* Question 1 layout panel */

// Create a panel for the question and answers

Panel question1Panel = new Panel();

question1Panel.setLayout(new GridLayout(1, 2));

// Create a label for the question number

Label lbl = new Label("1");

// Add it to the question panel so it appears on the right

question1Panel.add(lbl);

// Add a panel for the answers to the question

Panel answer1Panel = new Panel();

// Use a grid layout of 4 rows by 1 column

answer1Panel.setLayout(new GridLayout(4,1));

//CheckBox.addActionListener(new ActionListener(){

//public void actionPerformed(ActionEvent ae)

//{

// System.out.println("check box state"+check.getState());

// }

check[1] = new Checkbox("A. Imaginative");

answer1Panel.add(check[1]);

//check1.addItemListener(iListener);

//state = check1.isSeleted() ; // tells whether box is checked

//check1.setSelected(state);

//getContentPane().add(check1);// set checked state of box

check[2] = new Checkbox("B. Investigative");

answer1Panel.add(check[2]);

//check1.addItemListener(iListener);

//state = check1.isSeleted() ; // tells whether box is checked

//check1.setSelected(state);

//getContentPane().add(check1);// set checked state of box

check[3] = new Checkbox("C. Realistic");

answer1Panel.add(check[3]);

check[4] = new Checkbox("D. Analytical");

answer1Panel.add(check[4]);

question1Panel.add(answer1Panel);

add(question1Panel);

/* Question 2 layout panel */

Panel question2Panel = new Panel();

question2Panel.setLayout(new GridLayout(1,2));

lbl = new Label("2");

question2Panel.add(lbl);

Panel answer2Panel = new Panel();

answer2Panel.setLayout(new GridLayout(4,1));

check[5] = new Checkbox("A. Organized");

answer2Panel.add(check[5]);

check[6]= new Checkbox("B. Adaptable");

answer2Panel.add(check[6]);

check[7] = new Checkbox("C. Critical");

answer2Panel.add(check[7]);

check[8] = new Checkbox("D. Inquisitive");

answer2Panel.add(check[8]);

question2Panel.add(answer2Panel);

add(question2Panel);

/* Question 3 layout panel*/

Panel question3Panel= new Panel();

question3Panel.setLayout(new GridLayout(1,2));

lbl = new Label("3");

question3Panel.add(lbl);

Panel answer3Panel = new Panel();

answer3Panel.setLayout(new GridLayout(4,1));

check[9] = new Checkbox("A. Debating");

answer3Panel.add(check[9]);

check[10] = new Checkbox("B.Getting to the point");

answer3Panel.add(check[10]);

check[11] = new Checkbox("C. Creating");

answer3Panel.add(check[11]);

check[12] = new Checkbox("D. Relating");

answer3Panel.add(check[12]);

question3Panel.add(answer3Panel);

add(question3Panel);

/* Question 4 layout panel*/

Panel question4Panel= new Panel();

question4Panel.setLayout(new GridLayout(1,2));

lbl = new Label("4");

question4Panel.add(lbl);

Panel answer4Panel = new Panel();

answer4Panel.setLayout(new GridLayout(4,1));

check[13] = new Checkbox("A. Personal");

answer4Panel.add(check[13]);

check[14] = new Checkbox("B. Practical");

answer4Panel.add(check[14]);

check[15] = new Checkbox("C. Academic");

answer4Panel.add(check[15]);

check[16] = new Checkbox("D. Adventurous");

answer4Panel.add(check[16]);

question4Panel.add(answer4Panel);

add(question4Panel);

/* Question 5 layout panel*/

Panel question5Panel= new Panel();

question5Panel.setLayout(new GridLayout(1,2));

lbl = new Label("5");

question5Panel.add(lbl);

Panel answer5Panel = new Panel();

answer5Panel.setLayout(new GridLayout(4,1));

check[17] = new Checkbox("A. Presice");

answer5Panel.add(check[17]);

check[18 ]= new Checkbox("B. Flexible");

answer5Panel.add(check[18]);

check[19] = new Checkbox("C. Systematic");

answer5Panel.add(check[19]);

check[20] = new Checkbox("D. Inventive");

answer5Panel.add(check[20]);

question5Panel.add(answer5Panel);

add(question5Panel);

/* Question 6 layout panel*/

Panel question6Panel= new Panel();

question6Panel.setLayout(new GridLayout(1,2));

lbl = new Label("6");

question6Panel.add(lbl);

Panel answer6Panel = new Panel();

answer6Panel.setLayout(new GridLayout(4,1));

check[21] = new Checkbox("A. Sharing");

answer6Panel.add(check[21]);

check[22]= new Checkbox("B. Orderly");

answer6Panel.add(check[22]);

check[23] = new Checkbox("C. Sensible");

answer6Panel.add(check[23]);

check[24] = new Checkbox("D. Independent");

answer6Panel.add(check[24]);

question6Panel.add(answer6Panel);

add(question6Panel);

/* Question 7 layout panel*/

Panel question7Panel= new Panel();

question7Panel.setLayout(new GridLayout(1,2));

lbl = new Label("7");

question7Panel.add(lbl);

Panel answer7Panel = new Panel();

answer7Panel.setLayout(new GridLayout(4,1));

check[25] = new Checkbox("A. Competitive");

answer7Panel.add(check[25]);

check[26] = new Checkbox("B. Perfectionist");

answer7Panel.add(check[26]);

check[27] = new Checkbox("C. Cooperative");

answer7Panel.add(check[27]);

check[28] = new Checkbox("D. Logical");

answer7Panel.add(check[28]);

question7Panel.add(answer7Panel);

add(question7Panel);

/* Question 8 layout panel*/

Panel question8Panel= new Panel();

question8Panel.setLayout(new GridLayout(1,2));

lbl = new Label("8");

question8Panel.add(lbl);

Panel answer8Panel = new Panel();

answer8Panel.setLayout(new GridLayout(4,1));

check[29] = new Checkbox("A. Intellectual");

answer8Panel.add(check[29]);

check[30] = new Checkbox("B. Sensitive");

answer8Panel.add(check[30]);

check[31] = new Checkbox("C. Hard-working");

answer8Panel.add(check[31]);

check[32] = new Checkbox("D. Risk-taking");

answer8Panel.add(check[32]);

question8Panel.add(answer8Panel);

add(question8Panel);

/* Question 9 layout panel*/

Panel question9Panel= new Panel();

question9Panel.setLayout(new GridLayout(1,2));

lbl = new Label("9");

question9Panel.add(lbl);

Panel answer9Panel = new Panel();

answer9Panel.setLayout(new GridLayout(4,1));

check[33] = new Checkbox("A. Reader");

answer9Panel.add(check[33]);

check[34] = new Checkbox("B. People person");

answer9Panel.add(check[34]);

check[35] = new Checkbox("C. Problem solver");

answer9Panel.add(check[35]);

check[36] = new Checkbox("D. Planner");

answer9Panel.add(check[36]);

question9Panel.add(answer9Panel);

add(question9Panel);

/* Question 10 layout panel*/

Panel question10Panel= new Panel();

question10Panel.setLayout(new GridLayout(1,2));

lbl = new Label("10");

question10Panel.add(lbl);

Panel answer10Panel = new Panel();

answer10Panel.setLayout(new GridLayout(4,1));

check[37] = new Checkbox("A. Memorize");

answer10Panel.add(check[37]);

check[38] = new Checkbox("B. Associate");

answer10Panel.add(check[38]);

check[39] = new Checkbox("C. Think-through");

answer10Panel.add(check[39]);

check[40] = new Checkbox("D. Originate");

answer10Panel.add(check[40]);

question10Panel.add(answer10Panel);

add(question10Panel);

/* Question 11 layout panel*/

Panel question11Panel= new Panel();

question11Panel.setLayout(new GridLayout(1,2));

lbl = new Label("11");

question11Panel.add(lbl);

Panel answer11Panel = new Panel();

answer11Panel.setLayout(new GridLayout(4,1));

check[41] = new Checkbox("A. Changer");

answer11Panel.add(check[41]);

check[42] = new Checkbox("B. Judger");

answer11Panel.add(check[42]);

check[43] = new Checkbox("C. Spontaneous");

answer11Panel.add(check[43]);

check[44] = new Checkbox("D. Wants direction");

answer11Panel.add(check[44]);

question11Panel.add(answer11Panel);

add(question11Panel);

/* Question 12 layout panel*/

Panel question12Panel= new Panel();

question12Panel.setLayout(new GridLayout(1,2));

lbl = new Label("12");

question12Panel.add(lbl);

Panel answer12Panel = new Panel();

answer12Panel.setLayout(new GridLayout(4,1));

check[45] = new Checkbox("A. Communicating");

answer12Panel.add(check[45]);

check[46] = new Checkbox("B. Discovering");

answer12Panel.add(check[46]);

check[47] = new Checkbox("C. Caring");

answer12Panel.add(check[47]);

check[48] = new Checkbox("D. Examining");

answer12Panel.add(check[48]);

question12Panel.add(answer12Panel);

add(question12Panel);

/* Question 13 layout panel*/

Panel question13Panel= new Panel();

question13Panel.setLayout(new GridLayout(1,2));

lbl = new Label("13");

question13Panel.add(lbl);

Panel answer13Panel = new Panel();

answer13Panel.setLayout(new GridLayout(4,1));

check[49] = new Checkbox("A. Challenging");

answer13Panel.add(check[49]);

check[50] = new Checkbox("B. Practicing");

answer13Panel.add(check[50]);

check[51] = new Checkbox("C. Caring");

answer13Panel.add(check[51]);

check[52] = new Checkbox("D. Examining");

answer13Panel.add(check[52]);

question13Panel.add(answer13Panel);

add(question13Panel);

/* Question 14 layout panel*/

Panel question14Panel= new Panel();

question13Panel.setLayout(new GridLayout(1,2));

lbl = new Label("14 ");

question14Panel.add(lbl);

Panel answer14Panel = new Panel();

answer14Panel.setLayout(new GridLayout(4,1));

check[53] = new Checkbox("A. Completing work");

answer14Panel.add(check[53]);

check[54] = new Checkbox("B. Seeing possibilities");

answer14Panel.add(check[54]);

check[55] = new Checkbox("C. Gaining ideas");

answer14Panel.add(check[55]);

check[56] = new Checkbox("D. Interpreting");

answer14Panel.add(check[56]);

question14Panel.add(answer14Panel);

add(question14Panel);

/* Question 15 layout panel*/

Panel question15Panel= new Panel();

question15Panel.setLayout(new GridLayout(1,2));

lbl = new Label("15");

question15Panel.add(lbl);

Panel answer15Panel = new Panel();

answer15Panel.setLayout(new GridLayout(4,1));

check[57] = new Checkbox("A. Doing");

answer15Panel.add(check[57]);

check[58] = new Checkbox("B. Feeling");

answer15Panel.add(check[58]);

check[59] = new Checkbox("C. Thinking");

answer15Panel.add(check[59]);

check[60] = new Checkbox("D. Experimenting");

answer15Panel.add(check[60]);

question15Panel.add(answer15Panel);

add(question15Panel);

/*class ToggleButton extends JFrame{

public ToggleButton(){

super("ToggleButton");

getContentPane().setLayout(new FlowLayout());

ButtonGroup buttonGroup =new ButtonGroup();

char ch = (char) ('1'+ k);

for (int k=0; k<4; k++){

JToggleButton button = new JToggleButton("Button"+ch, k==0);

button.setMnemonic(ch);

button.setEnabled(k<3);

button.setToolTipText("This is button"+ ch);

getContentPane().add(button);

buttonGroup.add(button);

}

//pack();

}

}*/

JButton button1 = new JButton("SUBMIT");

//Object BOX_TITLE;

//JDialog dialog = Panel.createDialog(Dialog.this, BOX_TITLE);

//dialog.show();

add(button1);

addComponentListener((ComponentListener) iListener);

ActionListener al = new ActionListener(){

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

if (check[1].getState()== true){

group1 = group1 +1;

}

if (check[2].getState()== true){

group1 = group1 +1;

}

if (check[3].getState()== true){

group1 = group1 +1;

}

if (check[4].getState()== true){

group1 = group1 +1;

}

if (check[5].getState()== true){

group2 = group2 +1;

}

if (check[6].getState()== true){

group2 = group2 +1;

}

if (check[7].getState()== true){

group2 = group2 +1;

}

if (check[8].getState()== true){

group2 = group2 +1;

}

if (check[9].getState()== true){

group3 = group3 +1;

}

if (check[10].getState()== true){

group3 = group3 +1;

}

if (check[11].getState()== true){

group3 = group3 +1;

}

if (check[12].getState()== true){

group3 = group3 +1;

}

if (check[13].getState()== true){

group4 = group4 +1;

}

if (check[14].getState()== true){

group4 = group4 +1;

}

if (check[15].getState()== true){

group4 = group4 +1;

}

if (check[16].getState()== true){

group4 = group4 +1;

}

if (check[17].getState()== true){

group5 = group5 +1;

}

if (check[18].getState()== true){

group5 = group5 +1;

}

if (check[19].getState()== true){

group5 = group5 +1;

}

if (check[20].getState()== true){

group5 = group5 +1;

}

if (check[21].getState()== true){

group6 = group6 +1;

}

if (check[22].getState()== true){

group6 = group6 +1;

}

if (check[23].getState()== true){

group6 = group6 +1;

}

if (check[24].getState()== true){

group6 = group6 +1;

}

if (check[25].getState()== true){

group7 = group7 +1;

}

if (check[26].getState()== true){

group7 = group7 +1;

}

if (check[27].getState()== true){

group7 = group7 +1;

}

if (check[28].getState()== true){

group7 = group7 +1;

}

if (check[29].getState()== true){

group8 = group8 +1;

}

if (check[30].getState()== true){

group8 = group8 +1;

}

if (check[31].getState()== true){

group8 = group8 +1;

}

if (check[32].getState()== true){

group8 = group8 +1;

}

if (check[33].getState()== true){

group9 = group9 +1;

}

if (check[34].getState()== true){

group9 = group9 +1;

}

if (check[35].getState()== true){

group9 = group9 +1;

}

if (check[36].getState()== true){

group9 = group9 +1;

}

if (check[37].getState()== true){

group10 = group10 +1;

}

if (check[38].getState()== true){

group10 = group10 +1;

}

if (check[39].getState()== true){

group10 = group10 +1;

}

if (check[40].getState()== true){

group10 = group10 +1;

}

if (check[41].getState()== true){

group11 = group11 +1;

}

if (check[42].getState()== true){

group11 = group11 +1;

}

if (check[43].getState()== true){

group11 = group11 +1;

}

if (check[44].getState()== true){

group11 = group11 +1;

}

if (check[45].getState()== true){

group12 = group12 +1;

}

if (check[46].getState()== true){

group12 = group12 +1;

}

if (check[47].getState()== true){

group12 = group12 +1;

}

if (check[48].getState()== true){

group12 = group12 +1;

}

if (check[49].getState()== true){

group13 = group13 +1;

}

if (check[50].getState()== true){

group13 = group13 +1;

}

if (check[51].getState()== true){

group13 = group13 +1;

}

if (check[52].getState()== true){

group13 = group13 +1;

}

if (check[53].getState()== true){

group14 = group14 +1;

}

if (check[54].getState()== true){

group14 = group14 +1;

}

if (check[55].getState()== true){

group14 = group14 +1;

}

if (check[56].getState()== true){

group14 = group14 +1;

}

if (check[57].getState()== true){

group15 = group15 +1;

}

if (check[58].getState()== true){

group15 = group15 +1;

}

if (check[59].getState()== true){

group15 = group15 +1;

}

if (check[60].getState()== true){

group15 = group15 +1;

}

System.out.println(check[1].getState());

System.out.println(check[2].getState());

System.out.println(check[3].getState());

System.out.println(check[4].getState());

System.out.println(check[5].getState());

System.out.println(check[6].getState());

System.out.println(check[7].getState());

System.out.println(check[8].getState());

System.out.println(check[9].getState());

System.out.println(check[10].getState());

System.out.println(check[11].getState());

System.out.println(check[12].getState());

System.out.println(check[13].getState());

System.out.println(check[14].getState());

System.out.println(check[15].getState());

System.out.println(check[16].getState());

System.out.println(check[17].getState());

System.out.println(check[18].getState());

System.out.println(check[19].getState());

System.out.println(check[20].getState());

System.out.println(check[21].getState());

System.out.println(check[22].getState());

System.out.println(check[23].getState());

System.out.println(check[24].getState());

System.out.println(check[25].getState());

System.out.println(check[26].getState());

System.out.println(check[27].getState());

System.out.println(check[28].getState());

System.out.println(check[29].getState());

System.out.println(check[30].getState());

System.out.println(check[31].getState());

System.out.println(check[32].getState());

System.out.println(check[33].getState());

System.out.println(check[34].getState());

System.out.println(check[35].getState());

System.out.println(check[36].getState());

System.out.println(check[37].getState());

System.out.println(check[38].getState());

System.out.println(check[39].getState());

System.out.println(check[40].getState());

System.out.println(check[41].getState());

System.out.println(check[42].getState());

System.out.println(check[43].getState());

System.out.println(check[44].getState());

System.out.println(check[45].getState());

System.out.println(check[46].getState());

System.out.println(check[47].getState());

System.out.println(check[48].getState());

System.out.println(check[49].getState());

System.out.println(check[50].getState());

System.out.println(check[51].getState());

System.out.println(check[52].getState());

System.out.println(check[53].getState());

System.out.println(check[54].getState());

System.out.println(check[55].getState());

System.out.println(check[56].getState());

System.out.println(check[57].getState());

System.out.println(check[58].getState());

System.out.println(check[59].getState());

System.out.println(check[60].getState());

}

};

button1.addActionListener(al);

}

private JMenuBar createMenuBar() {

// TODO Auto-generated method stub

return null;

}

//button1.addActionListener(al);

}

desainta at 2007-7-12 21:26:38 > top of Java-index,Java Essentials,New To Java...
# 3
You need to learn to use loops.
aniseeda at 2007-7-12 21:26:38 > top of Java-index,Java Essentials,New To Java...
# 4
how will i be able to that on the code please can you show me?
desainta at 2007-7-12 21:26:38 > top of Java-index,Java Essentials,New To Java...
# 5

> how will i be able to that on the code please can you

> show me?

TMFC for me to read.

Break down your problem into little steps.

Break down your code into subclasses and methods.

Read about loops and containers and use them.

Be a lazy programmer -- try not to create repetitious code. Create methods to do the repititions for you.

Message was edited by:

petes1234

petes1234a at 2007-7-12 21:26:38 > top of Java-index,Java Essentials,New To Java...