?
Solved

get info from a few checkboxes/textboxes with 1 button

Posted on 2006-10-19
3
Medium Priority
?
221 Views
Last Modified: 2010-05-18
hi, im pretty new to GUI programming but not java...
i have an applet which basically displays about 30 checkboxes for user to check
then there are some textfields to be typed in
after that is done the user clicks "Submit"

when the submit button is clicked, i would like to call a method where all the users info will be used to query a database.
How do i make it so that i can iterate through a container which has the checkboxes which the user checked and the values of the textfields.

/*sample code of what i have
this gives 5 checkboxes...checks if they should be checked by default and return checked or not
then im putting it in a collection of checkboxes..
I DO NOT KNOW where to go from here ... after the for loop, what do i do to retrieve
if the button was checked or not by the user?*/        
for(int x = 0 ; x < 10; x++)
        {
            JCheckBox check = gui.checkDefaultsArray1(array,x);
            boxesF1[x] = new JCheckBox(array[x],true);

            c.ipady = 0;
            c.gridx = 0;
            c.gridy = x+5;
            pane.add(check, c);
            countF1 = x+5;
        }


THANK YOU VERY MUCh!!!
0
Comment
Question by:Squadless
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 17767686
iterate thru checkboxes and chechbox.isSelected() will tell you if it is checked or not
0
 
LVL 1

Author Comment

by:Squadless
ID: 17769226
can i get a code example of how do to this please...something a little mroe concrete?
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 2000 total points
ID: 17771615
for(JCheckBox c : boxesF1) { // for each checkbox
    if(c.isSelected()) {
        // do what you want
    }
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 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