only 2 check boxes from four at a time checked

K

Kgbol

Could somebody tell me, ore give a code. I want to make 4 check boxes
and max 2 of them could be checked at a time.
 
E

Eric Sosman

Kgbol wrote On 06/13/07 14:58,:
Could somebody tell me, ore give a code. I want to make 4 check boxes
and max 2 of them could be checked at a time.

If you want to do this "often," consider writing a class
that mimics javax.swing.ButtonGroup (you probably don't want
to write a subclass of ButtonGroup, because getSelection and
some other methods can only talk about one button, not two
or more).

If you want to do this "just a few times," you can hard-
wire the logic into your button listeners. Keep track of how
many buttons are checked, and when the count reaches the limit
disable all the unchecked buttons. When a checked button is
unchecked and the count decreases, re-enable them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
Martindap

Latest Threads

Top