Results 1 to 4 of 4
  1. #1
    khb3283 is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default How to count total items of JCheckbox

    I have a small application described below :
    Five checkbox such as : Apple, Mango, Grape, Tangerine, Peach an one button.
    Assume that I check apple, grape, when I click button, A message will show with content : You like apple, grape.

    How can I do that ?

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    addactionListener to buttons
    actionperformed(?) method, check the event source, use joptiondialog to popup dialog

  3. #3
    viswanadh7 is offline Member
    Join Date
    Mar 2009
    Posts
    10
    Rep Power
    0

    Smile

    Apply actionlistener for the JButton and call getActionCommand() on the ActionEvent object.like


    Java Code:
    public void actionPerformed(ActionEvent buttonevent)
    {
    if(buttonevent.getSource()==yourbuttonname)
    {
    System.out.println("Selected:"+buttonevent.getActionCommand();
    }
    }

  4. #4
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

Similar Threads

  1. Need Help for coding invoice total
    By maxb in forum New To Java
    Replies: 3
    Last Post: 11-22-2008, 05:22 PM
  2. total beginner needs little help
    By asambasamba in forum New To Java
    Replies: 1
    Last Post: 06-18-2008, 06:33 PM
  3. Total Newbie, Be Kind :)
    By dazza-s in forum New To Java
    Replies: 11
    Last Post: 04-26-2008, 11:54 PM
  4. Printing total out
    By denisdoherty in forum New To Java
    Replies: 1
    Last Post: 04-25-2008, 07:40 AM
  5. jcheckbox issues need help. thanks.
    By carlos123 in forum New To Java
    Replies: 3
    Last Post: 11-05-2007, 11:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •