Results 1 to 4 of 4
- 12-09-2012, 01:22 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Netbeans-generate number of radio buttons dynamically
I'm creating a databse application with SQL server management as the back end and the GUI in Netbeans. Based on the number of rows or tuples retrieved from the databse, I want to create those many radio buttons. Currently I've just come to this:
So, is there a way to to create radio buttons dynamically (something like jRadioButtoni.setText(cpf+" "+cnum+" "+cname)) where i is the number of tuples returned by the query in result.Java Code:result = select.executeQuery("SELECT ......."); while(result.next()) { cpf=result.getString("CoursePrefix"); cnum=result.getString("CourseNumber"); String cname=result.getString("CourseName"); jRadioButton1.setText(cpf+" "+cnum+" "+cname); }
Also, in the GUI builder I have to drag and drop the swing controls. I cannot declare teh components via the source code.
Any help and pointers in the direction will be greatly appreciated! Thanks!!
- 12-09-2012, 01:41 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Netbeans-generate number of radio buttons dynamically
Go through the result set and create the radio buttons (ie use "new") with the name you want. Then add them to whatever container you want.
The gui builder does its thing at design time (ie code writing time), not at runtime which is when you actually discover the number the buttons you want. It's not looking good for the gui builder!in the GUI builder I have to drag and drop the swing controls. I cannot declare teh components via the source code
(Maybe a NB aware component exists. From the recesses of my memory I seem to remember Delphi had a control that would create a bunch of radio buttons based on an array of strings. Someone might have written a similar component that can be installed onto the palette of your gui builder. My guess is that it would be faster to write your own code than search about for someone else's and then wrestle with their documentation - or lack of it. Letting go of the gui builder does take some work, but is worth it.)
- 12-09-2012, 01:50 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Netbeans-generate number of radio buttons dynamically
Also at javaprogrammingforums.com, forums.netbeans.org and stackoverflow.com
@OP: If you are going to start a discussion at various places its helpful and polite to post the locations of those places. That way everyone taking part in a discussion knows what else is being said.
Bear in mind that some people will not participate in a discussion if they think they might be wasting their time on something that has been dealt with elsewhere.Last edited by pbrockway2; 12-09-2012 at 01:57 AM.
- 12-09-2012, 06:06 AM #4
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Re: Netbeans-generate number of radio buttons dynamically
Hmm...so basically Netbeans does not the functionality of dynamically creating components.
I'll work on the code without the GUI builder.
Thanks!
And sorry about that...I really wanted to know how to do it. I had seen it in some tutorial but when I went back to search for it, I couldn't find it.
Maybe I just confused the tutorial for something else.
Similar Threads
-
Help help.radio buttons
By 10e5x in forum New To JavaReplies: 3Last Post: 01-04-2011, 07:10 PM -
Help with Radio Buttons
By miguelms19 in forum AWT / SwingReplies: 3Last Post: 06-29-2010, 07:49 PM -
How can i setString when i use radio buttons?
By Tahorn in forum AWT / SwingReplies: 4Last Post: 02-16-2010, 02:03 PM -
[SOLVED] Radio Buttons
By dbashby in forum New To JavaReplies: 2Last Post: 04-04-2009, 03:44 PM -
How to use Radio Buttons
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks