Solved

keep track of the order they were checked?

Posted on 2004-04-10
3
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

734 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