Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: count components inside a JPanel

  1. #1
    Junior Member
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default count components inside a JPanel

    I have a JPanel with 5 JCheckBox on it. What I'd like to do is count how many of them are selected and create a collection out of them so I can iterate through them without using if (JCheckBox.isSelected()) { do something... }.

    Is this possible or am I just dreaming?

    ~DewBoy3d
    --
    DewBoy3d
    Rochester, NY


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: count components inside a JPanel

    The method of checking which are selected would be to iterate through them and use the isSelected option, as far as im aware thee is no "add all selected checkboxes to a collection" function

    Sorry not really much help lol! Make your own

    Regards,
    Chris
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

Similar Threads

  1. select count(*)
    By jacinto in forum JDBC & Databases
    Replies: 4
    Last Post: March 2nd, 2010, 09:30 PM
  2. Creating A Count Matrix In Java
    By statsman5 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: July 14th, 2009, 04:40 PM
  3. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 01:25 PM
  4. Creating and displaying a JPanel inside another JPanel
    By JayDuck in forum AWT / Java Swing
    Replies: 1
    Last Post: April 7th, 2009, 08:02 AM
  5. Replies: 2
    Last Post: March 6th, 2009, 02:00 PM