Solved

keep track of the order they were checked?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java 8 lambda expresssions exception handling 3 75
eclipse shortcuts 9 45
Oracle SQL syntax check  without executing 6 37
difference of if loops 23 42
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

867 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

12 Experts available now in Live!

Get 1:1 Help Now