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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:14:41+00:00 2026-05-27T12:14:41+00:00

I’m quite new to creating layout using SWT. This is what I have to

  • 0

I’m quite new to creating layout using SWT. This is what I have to create
enter image description here

And this is my try so far :
enter image description here

Code :

   private void createContents(final Shell shell) {
    shell.setLayout(new GridLayout(2,true));

    /// Side Panel
    Composite sideComposite = new Composite(shell, SWT.NONE);
    sideComposite.setLayout(new RowLayout(SWT.VERTICAL | SWT.BORDER ));
    Label codeLabel = new Label(sideComposite, SWT.NONE);
    codeLabel.setText("Folders");

    // Create list of folders
    Composite foldersComposite = new Composite(sideComposite, SWT.NONE);
    foldersComposite.setLayout(new GridLayout(2,true));
    createFoldersComposite(foldersComposite);

    // Create tags
    Composite tagsComposite = new Composite(sideComposite, SWT.NONE);
    tagsComposite.setLayout(new RowLayout());
    createTagsComposte(tagsComposite);

    /// .Side Panel

    /// Main Panel
    Composite mainComposite = new Composite(shell, SWT.NONE);
    mainComposite.setLayout(new RowLayout(SWT.VERTICAL));

    // Create search field
    Composite searchComposite = new Composite(mainComposite, SWT.NONE);
    searchComposite.setLayout(new GridLayout(2,true));

    Label searchLabel = new Label(searchComposite, SWT.NONE);
    searchLabel.setText("Search");
    GridData gridData = new GridData();
    gridData.horizontalSpan = 1;
    searchLabel.setLayoutData(gridData);

    Text searchText = new Text(mainComposite, SWT.BORDER | SWT.V_SCROLL);
    searchLabel.setLayoutData(gridData);

    // Create search result
    Composite resultComposite = new Composite(mainComposite, SWT.BORDER);
    resultComposite.setLayout(new GridLayout(2,true));
    createResultComposite(resultComposite);

    // Code Review
    Text codeText = new Text(mainComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER );
    codeText.setSize(500, 500);


    /// .Main Panel
}

Question: How can I fix my existing code to have the exact layout I want ?

  • 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-27T12:14:41+00:00Added an answer on May 27, 2026 at 12:14 pm

    It may be helpful to break this down into separate widgets, instead of having a monolithic control that tries to handle the layout for everything at once. This allows you to nail down the layout on each separate component correctly, then building them up a piece at a time to get the overall layout you want.

    This is especially noticeable in your sample code – you’re creating a Composite called searchComposite with a two-column GridLayout, and you’re adding searchLabel to that composite. But you’re adding searchText to mainComposite, which I think is not what you intended.

    Instead, I would create a SearchControl that had a two-column GridLayout containing a Label and a Text. The GridData on the Text should grabExcessHorizontalSpace to fill the remainder of the control.

    I would suggest getting more familiar with GridLayout and GridData. Don’t be afraid to experiment. For example, you’re always passing true to the GridLayout constructor, which will make column match widths. While this is perfectly reasonable, it doesn’t match the layout you’ve sketched where some columns are wider than each other. Also, I would suggest looking at GridDataFactory. It will turn all the GridData fiddling into a one-liner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.