Solved

keep track of the order they were checked?

Posted on 2004-04-10
3
176 Views
Last Modified: 2010-03-31
Hello everyone!

Using the code below, if I had 50 different checkboxs in 7 different JPanels with 7 different name groups (example kp1-kp10  kk1-kk10  bl1-bl8 etc how would I be able to have each checkbox as it was checked go into an arraylist to keep track of the order they were checked?



public class CheckBoxesToAudioFiles {
Map checkToAudio;

public CheckBoxesToAudioFiles {
checkToAudio = new HashMap();
}

public void mapCheckboxToAudioFile(JCheckbox cb, AudioFile af) {
checkToAudio.put(cb, af);
}

public AudioFile getAudioFileForCheckbox(JCheckbox cb) {
(AudioFile)return checkToAudio.get(cb);
}

}

0
Comment
Question by:Drop_of_Rain
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 10796157
you would use an ActionListener:

cb.addActionListener(new ActionListener()
{
   public void actionPerformed(ActionEvent event)
   {
      JCheckBox cb = (JCheckBox) event.getSource();
      if (cb.isSelected())
      {
         choices.add(cb);
      }
   }
});
0
 

Author Comment

by:Drop_of_Rain
ID: 10796184
I can see it now, very easily I'm starting to get the hand on reading this code, this is starting to get really fun. I don't know what I would do wiyhout your help and others.  I will have a lot more questions, you will earn a lot of points from me and so will others.

Thanks again,
Christopher
0
 
LVL 92

Expert Comment

by:objects
ID: 10796260
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question