Solved

More checkboxs using the same code

Posted on 2004-04-09
6
188 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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

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

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…
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…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

821 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