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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:13:30+00:00 2026-05-26T02:13:30+00:00

I need to replace content of grid cell after button click. For example: there

  • 0

I need to replace content of grid cell after button click. For example: there is Label and I need to replace it with Text. Is it possible with GridLayout? I need to use SWT.

  • 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-26T02:13:30+00:00Added an answer on May 26, 2026 at 2:13 am

    You can simply dispose the Label and put a new Text in its place. GridLayout uses the z-order of children to determine the location in the grid, so you’ll need to use the moveAbove() and moveBelow() on the Text in order to get it in the correct location. Then call layout() on the parent. For example:

    Text text = new Text(label.getParent(), SWT.BORDER);
    text.moveAbove(label);
    label.dispose();
    text.getParent().layout();
    

    Here’s a simple widget that illustrates exactly what I mean:

    public class ReplaceWidgetComposite
        extends Composite
    {
        private Label label;
        private Text text;
        private Button button;
    
        public ReplaceWidgetComposite(Composite parent, int style)
        {
            super(parent, style);
    
            setLayout(new GridLayout(1, false));
    
            label = new Label(this, SWT.NONE);
            label.setText("This is a label!");
    
            button = new Button(this, SWT.PUSH);
            button.setText("Press me to change");
            button.addSelectionListener(new SelectionAdapter()
            {
                public void widgetSelected(SelectionEvent e)
                {
                    text = new Text(ReplaceWidgetComposite.this, SWT.BORDER);
                    text.setText("Now it's a text!");
                    text.moveAbove(label);
                    label.dispose();
                    button.dispose();
                    ReplaceWidgetComposite.this.layout(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to replace several URLs in a text file with some content dependent
I need to process a HTML content and replace the IMG SRC value with
I need to go though a content of element, and replace every tabulator \t
I need to open a file , replace some content( 12345 with 77348) and
We use Telerik's RadEditor for our content management system's WYSIWYG editor. We need the
I am trying to use JavaScript to dynamically replace content inside of curly braces.
Need to replace text bullet chars • with HTML ul & li tags within
I need to replace a simple string in a minified .js file after a
I need to load some ajax content after the fieldset with the class address.
here i need to replace content says... : <asp:DataList ID=dlProductReviews runat=server RepeatDirection=Vertical RepeatColumns=1> <ItemTemplate>

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.