Solved

get info from a few checkboxes/textboxes with 1 button

Posted on 2006-10-19
3
182 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
  • 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 500 total points
ID: 17771615
for(JCheckBox c : boxesF1) { // for each checkbox
    if(c.isSelected()) {
        // do what you want
    }
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create a gui in perl 3 69
solarwind tftp server 2 44
eclipse compiler vs Installed JREs option 3 73
GUI builder for Eclipse? 8 27
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now