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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:47:25+00:00 2026-05-27T06:47:25+00:00

I have an ArrayList<JCheckBox> that i want to convert to an ArrayList<String> First I

  • 0

I have an ArrayList<JCheckBox> that i want to convert to an ArrayList<String>

First I do like this. I get all my titles from a file and put them into a new ArrayList. Afterwords I make a new JCheckBox Array that contains all the Strings from the StringArray.

ArrayList<String> titler = new ArrayList<String>();
titler.addAll(FileToArray.getName());

ArrayList<JCheckBox> filmListe = new ArrayList<JCheckBox>();
for(String titel:titler){
    filmListe.add(new JCheckBox(titel));
}
for(JCheckBox checkbox:filmListe){
    CenterCenter.add(checkbox);
}

This is what I am trying to do: First I make a new ArrayList (still in the JCheckBox format), that contains alle the selected Checkboxes. Afterwords I want to add the to a new ArrayList in a String format.

The main problem is italicized (with **):

ArrayList<JCheckBox> selectedBoxes = new ArrayList<JCheckBox>();

for(JCheckBox checkbox: filmListe){
    if (checkbox.isSelected()){
        selectedBoxes.add(checkbox);
    }

ArrayList<String> titlesArr = new ArrayList<String>();
for(JCheckBox titel:selectedBoxes){ 
    *titlesArr.add(titel);*
}

A lot of code and text for a little problem! But I really appreciate your help! 🙂

  • 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-27T06:47:26+00:00Added an answer on May 27, 2026 at 6:47 am

    Assuming the checkbox’s label is exactly the same as what you originally had in your list of titles, just use the checkbox’s getText method (which gets the String label). You don’t need to make a separate list of checkboxes that are checked – just put an if-block inside your first loop like this:

        ArrayList<String> titlesArr = new ArrayList<String>(filmListe.size());
    
        for (JCheckBox checkbox : filmListe) {
            if (checkbox.isSelected()) {
                titlesArr.add(checkbox.getText());
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList<String> that I'd like to return a copy of. ArrayList has
I have an ArrayList<String> , and I want to remove repeated strings from it.
I have `a string example = this site holds all the examples from The
I have an ArrayList of type String that contain certain values. I want to
I have an ArrayList that I want to use to hold RaceCar objects that
I'm trying to get this to add and nothing happens at all. I have
I have a ArrayList made up of different elements imported from a db, made
I have an arraylist that contains items called Room. Each Room has a roomtype
I have an arraylist that gets different type of values in it, 1st value->
I have a arraylist of employees from the gridview in my ASP.net Page as

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.