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

  • SEARCH
  • Home
  • 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 8685977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:43:05+00:00 2026-06-12T22:43:05+00:00

I am developing a simple To-do List application which involves obtaining ‘things to do’

  • 0

I am developing a simple “To-do List” application which involves obtaining ‘things to do’ for
a particular day from the database and displaying them as checkbox text on a panel resting on a frame.There is a button “done” which can be used to remove
the ticked checkboxes after a task is complete.

The code that I used for the dynamic creation of the checkboxes is shown below:

//cnt-variable used to store the number of tasks for a day    
//rs1-ResultSet variable into which the task description is read into.    
//DATA-variable with 'to-do' description

 for(int i=0;i<cnt&&rs1.next();i++)
 {
     String s2=rs1.getString("DATA");
     JCheckBox cb = new JCheckBox("New CheckBox");
     cb.setText(s2);
     cb.setVisible(true);

     jPanel1.add(cb);
     jPanel1.validate();
 }

On running the code all it displays is an empty frame with the panel. Could someone help me figure out why the check boxes are not being displayed?
Thanks in advance.

  • 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-12T22:43:06+00:00Added an answer on June 12, 2026 at 10:43 pm

    Try this. This allows you to create a random number of check boxes…

    enter image description here

    public class TestCheckboxes {
    
        public static void main(String[] args) {
            new TestCheckboxes();
        }
    
        public TestCheckboxes() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException ex) {
                    } catch (InstantiationException ex) {
                    } catch (IllegalAccessException ex) {
                    } catch (UnsupportedLookAndFeelException ex) {
                    }
    
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new CheckBoxPane());
                    frame.setSize(400, 400);
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
    
            });
        }
    
        public class CheckBoxPane extends JPanel {
    
            private JPanel content;
    
            public CheckBoxPane() {
                setLayout(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.weightx = 1;
                gbc.weighty = 1;
                gbc.anchor = GridBagConstraints.CENTER;
                content = new JPanel(new GridBagLayout());
                add(content, gbc);
    
                JButton more = new JButton("More");
                more.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        GridBagConstraints gbc = new GridBagConstraints();
                        gbc.gridx = 0;
                        gbc.gridy = 0;
    
                        content.removeAll();
                        int count = 10 + (int) Math.round(Math.random() * 90);
                        System.out.println(count);
                        for (int index = 0; index < count; index++) {
                            gbc.gridx++;
                            if (index % 8 == 0) {
                                gbc.gridx = 0;
                                gbc.gridy++;
                            }
                            content.add(new JCheckBox(Integer.toString(index)), gbc);
                        }
    
                        content.revalidate();
                        repaint();
    
                    }
    
                });
    
                gbc.gridy++;
                gbc.weightx = 0;
                gbc.weighty = 0;
    
                add(more, gbc);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a simple Wedding List application, where guests can reserve the present they
I am developing an application in android in which i creating a list view
I am developing simple travel agent android application. When application starts it loads list
While i was developing a C++ application, I was using a simple list<int> *somelist
I am developing a simple students information application. I have student list in my
i am developing a application in which i add contact to contact List. i
I am developing an android application in which i have data coming from Url,The
I am developing a simple web application in which I want to take the
I developing the simple UIApplication in which i want to crop the UIImage (in
I'm developing a simple program which makes a Python script executable, and I'm working

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.