only 2 check boxes from four at a time checked

Discussion in 'Java' started by Kgbol, Jun 13, 2007.

  1. Kgbol

    Kgbol Guest

    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.
     
    Kgbol, Jun 13, 2007
    #1
    1. Advertising

  2. Kgbol

    Eric Sosman Guest

    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.

    --
     
    Eric Sosman, Jun 13, 2007
    #2
    1. Advertising

  3. Kgbol

    Kgbol Guest

    Ok i did how you told and it works fine. Thanks a lot
     
    Kgbol, Jun 14, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yurps
    Replies:
    1
    Views:
    6,920
    rajeshthangarasu1983
    Feb 29, 2008
  2. kris
    Replies:
    0
    Views:
    524
  3. Dave Smithz
    Replies:
    17
    Views:
    989
  4. ahmad_n80
    Replies:
    0
    Views:
    475
    ahmad_n80
    Jul 21, 2007
  5. Suresh
    Replies:
    2
    Views:
    408
    Suresh
    Apr 22, 2004
Loading...

Share This Page