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 6791461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:50:57+00:00 2026-05-26T17:50:57+00:00

I am making a Java application where I show a couple of checkboxes with

  • 0

I am making a Java application where I show a couple of checkboxes with relevant item from a file. Based on the selection I have to modify the original file accordingly. I have done this part.

I now realized that there might be some information that the user wants to add extra. I therefore want to show a checkbox with a JTextField hooked to it. The idea that I am trying to use is that if the value of checkbox is true, the value of JTextField associated with it, is included in the file.

I want to do something like this:

checkBoxes[i] = new Checkbox(new JTextField("enter new member e.g private int newMember"), null, false);

then

if(checkBoxes[i]==true)
{
    updatefile(file, checkBoxes[i]);
}

Where updateFile is a function that adds the value of checkBoxes[i] to file

Any idea on how should I work on this?

  • 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-05-26T17:50:58+00:00Added an answer on May 26, 2026 at 5:50 pm

    Just create the JTextField separately, there’s no need for them to be the same control.

    i.e.

    checkBoxes[i] = new JCheckBox("label");
    textFields[i] = new JTextField("extra data");
    // ...
    if (checkBoxes[i].isSelected()) {
        updateFile(file, textFields[i]);
    }
    

    If you want to enable/disable the textFields based on the selected state of the checkbox, do it using a listener – e.g. an ActionListener:

    checkBoxes[i].addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            textFields[i].setEnabled(checkBoxes[i].isSelected());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a shopping list mobile application (Java ME) and i have two classes;
I am making an application with Java Swing and i have a problem. I
I am making a Java application that is stored in a .jar file and
I'm making a Java ME application for Symbian S60 5th edition and I have
I am making a simple email application in Java. I have an Account class.
I am making an application in java and I want to have a terminal
I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them
Using J2SE, I tried making a LAN application using java.net.*, and it worked perfectly.
I am planning on making a Java Swing application and was wondering if Swing
I am making a qt application which allows the user to select a file

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.