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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:24:00+00:00 2026-06-04T13:24:00+00:00

I hava a Composite descComp with some stuff in it… basically it is a

  • 0

I hava a

Composite descComp

with some stuff in it… basically it is a container for a form, consisting of number of labels, Combos and buttons, all aligned in a line.
My form is not finite, I have a button that adds one extra line for extra input. However for that to work it seams I have to dispose old children of my descComp…

private void populateConstantMain(ContentData tariffConstantsOfType, Composite descComp,GridLayout descCompLayout, Boolean resize) {

    int arraySize;

    if (resize == false) {
        arraySize = tariffConstantsOfType.getQueryRowCount();
    } else {
        for (int i = 0 ; i < descComp.getChildren().length; i++) {
            System.out.println("Disposing: " + i + " " + descComp.getChildren()[i].toString());
            //descComp.getChildren()[i].setEnabled(false);
            descComp.getChildren()[i].dispose();
        }
        arraySize = tariffConstantsOfType.getQueryRowCount() + 1;
    }
......
}

For some reason

descComp.getChildren()[i].dispose();

does not work, meaning it wont dispose all children, that results in errors in inserting new children, therefore spoiling the layout :/ Interesting thing is that

descComp.getChildren()[i].setEnabled(false);

works, when I uncoment it, for all children…

  • 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-04T13:24:01+00:00Added an answer on June 4, 2026 at 1:24 pm

    I have a hunch that calling getChildren() on a composite returns you only the non-disposed children at the time you call it. So calling descComp.getChildren()[i].dispose(); is all messed up as your index is incrementing but your array is decreasing in size. Why don’t you try:

        for (Control control : descComp.getChildren()) {
            control.dispose();
        }
    

    This way you get a static view of the children in the composite before you start disposing of each of them.

    I’ve also switched the code to use the nicer J5 for-each syntax. If you are stuck on J1.4 then unfortunately you’ll need to stick to the for(;;) loop:

        Control[] children = descComp.getChildren();
        for (int i = 0 ; i < children.length; i++) {
            children[i].dispose();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hava a form (form_remote_tag) that updates a comments section. The form is in
I am trying to upload an image to the server. I hava a form
I hava a data window object, in which I am fetching some attributes from
I hava one PPTP server(192.168.1.100/172.17.0.1), and need route all the packets(target ip is 172.17.0.11)
I hava a url like mysite.net/home/index/page/XX while XX is any number. I need to
I hava a remote validator setup like so remote: { type: POST, url: /some/url,
I hava a thread in which I have an infinite loop, doing some network
I hava a functoin that call himself occasionally, that function has some asynchronous call
I hava a webview showing some contents which is getting from server. Now on
I hava some code like this: class LooperThread extends Thread { public Handler mHandler;

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.