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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:08:34+00:00 2026-06-10T14:08:34+00:00

I have a view, where elements are displayed, depending on previous choices. dispose() and

  • 0

I have a view, where elements are displayed, depending on previous choices. dispose() and parent.layout() do get rid of elements as expected. Question is, how do I get them back? I suppose, dispose() doesn’t delete an element, just takes it out of the elements list to render. So, how can I get one back?

Thanx in advance,
Marcus


Edit:

Just found, that dispose() frees the object and recursively it’s children, so I have to recreate them, once I have them disposed? If so, how can I find the position inside a e.g. GridLayout?


Edit(2):

According to the answer below, I have tried this:

public class TestTab extends Composite 
{
    org.eclipse.swt.layout.GridLayout layout = null;

    GridData griddata = null;

    Button upperButton = null;
    Text textInTheMiddle = null;
    Button lowerButton = null;

    public InvoiceTab(Composite parent, int arg2) {

        super(parent, arg2);
        final Composite myParent = parent;

        layout = new org.eclipse.swt.layout.GridLayout(GridData.FILL_BOTH,
                false);
        layout.numColumns = 1;

        this.setLayout(layout);


        upperButton = new Button(this, SWT.PUSH);
        upperButton.setText("upper Button");

        textInTheMiddle = new Text(this, SWT.BORDER);

        lowerButton = new Button(this, SWT.PUSH);
        lowerButton.setText("lower Button");

        upperButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {

                if (textInTheMiddle.isVisible()) {
                    textInTheMiddle.setVisible(false);
                    lowerButton.moveBelow(upperButton);
                } else {
                    textInTheMiddle.setVisible(true);
                    lowerButton.moveBelow(textInTheMiddle);
                }
                myParent.layout();
            }
        });
    }   
}

The textfield gest visible as expected, but the lower button doesn’t change place?
Thanx again for any thoughts…

  • 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-10T14:08:36+00:00Added an answer on June 10, 2026 at 2:08 pm

    Yes, dispose() frees the object and recursively it’s children. So you have to recreate the controls/widgets whom you have disposed. In scenario like yours its advisable to hide the controls and re-layout your composite/container. For an example see here

    Code !!

    The important point is the usage of GridData::exclude property.

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;
    
    class TestTab extends Composite 
    {
        Button upperButton = null;
        Text textInTheMiddle = null;
        Button lowerButton = null;
    
        boolean state = true;
    
        public TestTab(Composite parent, int style) 
        {
            super(parent, style);
    
    
            GridLayout layout = new GridLayout(1, false);
            setLayout(layout);
    
    
            upperButton = new Button(this, SWT.PUSH);
            upperButton.setText("upper Button");
    
            textInTheMiddle = new Text(this, SWT.BORDER);
            GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
            data.exclude = false;
            textInTheMiddle.setLayoutData(data);
    
            lowerButton = new Button(this, SWT.PUSH);
            lowerButton.setText("lower Button");
    
            upperButton.addSelectionListener(new SelectionAdapter() 
            {
                public void widgetSelected(SelectionEvent e) {
    
    
                    GridData griddata = (GridData) textInTheMiddle.getLayoutData();
                    griddata.exclude = state;
                    textInTheMiddle.setVisible(!state);
                    textInTheMiddle.getParent().layout(false);
                    state = !state;
                }
            });
        }   
    
    }
    public class Test
    {
        public static void main(String[] args) 
        {
            Display display = new Display();
            Shell shell = new Shell(display);
            shell.setLayout(new GridLayout(1, false));
    
            new TestTab(shell, SWT.NONE);
    
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                    display.sleep();
            }
            display.dispose();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that renders a list elements using the following template :
In a certain view I have got different elements and I need the keyboard
I have a list of elements (the X in the following examples) displayed either
I have a grid view with scroll bars permanently displayed. When i set the
I have outline view each element of which is checkbox. I want to set
I have backbone view that binds an action to an element in the DOM.
I am trying to have an element index view displaying the associated projectname (
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have view on which I defined a custom tagName. I need to be
i have view like 'home/details/5', it can be access by anonymous user. but there

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.