Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:39+00:00 2026-06-04T16:08:39+00:00

Hi I have 2 list defined: ArrayList<JLabel> questionsList = new ArrayList<JLabel>(); ArrayList<JRadioButton> answersList =

  • 0

Hi I have 2 list defined:

ArrayList<JLabel> questionsList = new ArrayList<JLabel>();
ArrayList<JRadioButton> answersList = new ArrayList<JRadioButton>();

I try to read questions and answers in format like that:

1st Question 
  answer1
  answer2

2nd Question 
  answer1
  answer2
etc.

So 1st question is read from list questionsList then I want to read from another list answersList all answers to that question and etc.

In questionsList I read data from mysql and they are saved in JLabels in format like:
1. Question one
2. Question two
etc

In answersList I read data from mysql and they are saved in JRadioButtons in format like:
answer1

answer2
etc

My code so far:

    int height = 0;

        for(int i1 =0; i1<questionsList.size(); i1++)
        {   
              client.insideFillPollPanel.add(questionsList.get(i1)).setBounds(20, 20+150*i1, 480, 14);

            height = 20+150*i1;  

            for(int i2 =0; i2<answersList.size(); i2++)
            client.insideFillPollPanel.add(answersList.get(i2)).setBounds(20, 50+30*i2, 480, 14);



        }

How do i solve it to be display like 1st format I showed so question then asnwers question and asnwers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:08:40+00:00Added an answer on June 4, 2026 at 4:08 pm

    I would recommend you to create a Question class which contains both the question and all answers belonging to that question and then, instead of having

    ArrayList<JLabel> questionsList = new ArrayList<JLabel>();
    ArrayList<JRadioButton> answersList = new ArrayList<JRadioButton>();
    

    You use

    ArrayList<Question> questions = new ArrayList<Question>();
    

    (as a side note: It is considered good practice to program against interfaces, so instead of storing the questions in a ArrayList<Question> I suggest you go for a List<Question>.)


    For example:

    class Question {
    
        JLabel questionLabel;
        List<JRadioButton> answers;
    
        public Question(String q, String... ans) {
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list iteration in python defined like this: for i in range(5):
I have a class defined like so: public class Test { static <T> List<Class<T>>
I have a class Bar that has a user-defined list of config keys and
If I have a List < Person > where person is defined by the
I have a List<ParentObject> where ParentObject is defined as: public class ParentObject { ChildObject
I have defined a custom list template type for SharePoint . I install it
I have the following function defined inside my linked list class. The declaration in
I have a button defined inside of a DataTemplate for my list box. <phone:PhoneApplicationPage.Resources>
I have a table a with a list of id's, and a user-defined function
I have list of files stored inside arraylist that I need to download in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.