Solved

keep track of the order they were checked?

Posted on 2004-04-10
3
170 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now