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.

Creating Dynamically Radio Buttons, Labels

Hi everybody,

I am developing a desktop application which evaluates an excel file. In the excel file there are Course Titles, Course Codes etc. and my program has to list these cells with radiobuttons for selecting a course. The excel part has no problem, the program reads the data and put them in a string arrays.It puts every column into a different String array, so i have 6 string arrays (every one has about 600 records) . I pass them to GUI for printing, selecting etc.

My problem starts here: I thought a solution like; Create jradiobuttons and jlabels with using index numbers of arrays, list them like an excel appearance. i need to create labels and radio buttons dynamically, because the excel file is not static, the information in it can change in time. I tried some ways to create Radiobuttons and Labels dynamically but i can't ! I used GroupLayout for creation. As a result, i need a solution or a new idea. Maybe i am thinking in a hard way, because i am a little newbie.

Re: Creating Dynamically Radio Buttons, Labels

I am asking what is the logic behind creating labels and buttons during the execution time. I added my code, this is adding only one row, i need to add 600 more rows. But can't figure out how to do it.

Re: Creating Dynamically Radio Buttons, Labels

Ok, i will give a simple explanation: i want to create 700 jradiobuttons and 700 jlabels. The appearance must be like a given SS which i put my previous post. So i am asking to you how can i create 700 buttons ?

Re: Creating Dynamically Radio Buttons, Labels

Originally Posted by Norm

Have you tried setting the sizes of the components you are using to build the GUI?

I thought that but grid layout is not allowed. So i will use gridbag layout, it is more complex and more flexible as read from an article. When i changed the code i will post again...Btw thank you for your attention.

Re: Creating Dynamically Radio Buttons, Labels

With gridbag layout it is easy to make a mistake/bug, it is so complex. So again i decided to use simple gird layout. I addedd 7 more panels to my main panel, and put the data into them seperately. I can arrange the horizontal gaps between columns by hand with netbeans. The problem is solved.