Solved

More checkboxs using the same code

Posted on 2004-04-09
6
192 Views
Last Modified: 2010-03-31
Hello everyone out there hope all is going well.

I have 50 checkboxs named (kp1-kp50) these checkboxs are in a seperate JPanel named KP'S, In another JPanel next to it is another 50 checkboxs named (dm1-dm50) and others with names (kk1-kk20) and so on.

How could I use the code below to work with all of these checkboxs going in both directions
(IN (checkToAudio.put(cb, af)) and Out((AudioFile)return checkToAudio.get(cb))



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
  • 4
  • 2
6 Comments
 

Author Comment

by:Drop_of_Rain
ID: 10793971
The reason I am asking this is because I might go in either direction. If you have seen any of my other questions.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 10794837
You can use the one instance of CheckBoxesToAudioFiles for all your checkboxes regardless of what panel they are in.
Though if you are storing the audio file names as the checkbox action command then the CheckBoxesToAudioFiles class is not really necessary.
0
 

Author Comment

by:Drop_of_Rain
ID: 10794913
I am going to have to have this be possible both ways. The reason is that a user will be able to choose which option(checkbox) they want in their workout.  If I have this be possible won;t the checkboxs need to be toggles. I say this because if a user chooses 1 option three times (example 1,4,5,1,3,2,1) the checkbox will become unchecked and then checked but only seeing it twice.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 10794930
how do you want the checkbox to worlk exactly?
0
 

Author Comment

by:Drop_of_Rain
ID: 10794942
I now realize that I am going to have 2 differt setups. 1 will be checkboxs and the other will be toggles.
0
 

Author Comment

by:Drop_of_Rain
ID: 10796156
Thanks again.

Christopher
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses

739 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