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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:00:31+00:00 2026-06-17T14:00:31+00:00

I am facing some problem in RowLayout while resizing the shell. I created the

  • 0

I am facing some problem in RowLayout while resizing the shell. I created the composite and set the layout as RowLayout for that composite. Added three Buttons inside the composite. Now when I resize the shell,
if there is not enough space for the third button, it should come down. But it is not coming down.
Could anyone tell whats wrong in the code? Please see my code below.

package com.rcp.mytraining.layout.composite;

import org.eclipse.swt.widgets.Composite;

public class ChatComposite extends Composite {

    /**
     * Create the composite.
     * 
     * @param parent
     * @param style
     */
    public ChatComposite(Composite parent, int style) {
        super(parent, style);

        Composite comp = new Composite(parent, SWT.NONE);
        // Color s = new Color(display, new RGB(30,30,30));

        Color s = Display.getDefault().getSystemColor(1);

        comp.setBackground(s);

        RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);

        rowLayout.wrap = true;
        rowLayout.pack = false;     

        comp.setLayout(rowLayout);

        Button btnNewButton = new Button(comp, SWT.NONE);
        btnNewButton.setText("New Button");

        Button btnNewButton_1 = new Button(comp, SWT.NONE);
        btnNewButton_1.setText("ss");

        Button btnNewButton_2 = new Button(comp, SWT.NONE);
        btnNewButton_2.setText("New Button");
        comp.pack();
    }

    @Override
    protected void checkSubclass() {
        // Disable the check that prevents subclassing of SWT components
    }

    public static void main(String[] args) {

        Display display = new Display();

        Shell shell = new Shell(display);

        // shell.setSize(200, 200);

        // shell.setLayout(new FillLayout());

        ChatComposite chatComposite = new ChatComposite(shell, SWT.NONE);


        shell.pack();
        shell.open();

        // chatComposite.pack();

        while (!shell.isDisposed()) {

            if (!display.readAndDispatch()) {

                display.sleep();
            }

        }
        // display.dispose();

    }

}

Please see the difference in the below code. I wanted to work in the same way. The above code should work in the sameway as the below code works

package com.rcp.mytraining.layout.composite;

import org.eclipse.swt.widgets.Composite;

public class ChatComposite extends Composite {

    /**
     * Create the composite.
     * 
     * @param parent
     * @param style
     */
    public ChatComposite(Composite parent, int style) {
        super(parent, style);

        /*
         * RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
         * 
         * // rowLayout.wrap = true; //rowLayout.pack = true;
         * setLayout(rowLayout);
         * 
         * Button btnNewButton = new Button(this, SWT.NONE);
         * btnNewButton.setText("New Button");
         * 
         * Button btnNewButton_1 = new Button(this, SWT.NONE);
         * btnNewButton_1.setText("New Button");
         * 
         * Button btnNewButton_2 = new Button(this, SWT.NONE);
         * btnNewButton_2.setText("New Button");
         */

        pack();

    }

    @Override
    protected void checkSubclass() {
        // Disable the check that prevents subclassing of SWT components
    }

    public static void main(String[] args) {

        Display display = new Display();

        Shell shell = new Shell(display);

        // shell.setSize(200, 200);

        shell.setLayout(new FillLayout());

        Composite comp = new Composite(shell, SWT.NONE);
        // Color s = new Color(display, new RGB(30,30,30));

        Color s = Display.getDefault().getSystemColor(1);

        comp.setBackground(s);

        RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);

        rowLayout.wrap = true;
        // rowLayout.pack = true;
        comp.setLayout(rowLayout);

        Button btnNewButton = new Button(comp, SWT.NONE);
        btnNewButton.setText("New Button");

        Button btnNewButton_1 = new Button(comp, SWT.NONE);
        btnNewButton_1.setText("ss");

        Button btnNewButton_2 = new Button(comp, SWT.NONE);
        btnNewButton_2.setText("New Button");
        comp.pack();

        // ChatComposite chatComposite = new ChatComposite(shell, SWT.NONE);

        shell.pack();
        shell.open();

        // chatComposite.pack();

        while (!shell.isDisposed()) {

            if (!display.readAndDispatch()) {

                display.sleep();
            }

        }
        // display.dispose();

    }

}
  • 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-17T14:00:33+00:00Added an answer on June 17, 2026 at 2:00 pm

    Your composite is not resizing with the shell, as you did not specify it to do so.

    Add a GridData object to its layout data , like this:

    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    

    Note: for debugging purposes, you could set the background of comp to red (or some other flashy color) and see the difference.

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

Sidebar

Related Questions

Im currently facing the problem that when i try to set focus on some
I have created web-application using JSF 2.0 & JSP and facing some weird problem.
I am facing some problem while adding values in numeric string: I have string
I am facing some problem during calculation of Numerical Integration with two data set.
I am facing some problem with ListView , I have inflated a layout with
I am facing some problem while returning data from web services. I am using
I have 2 classes Test(Base)and Program(child). Now I am facing some problem while downcasting.
Hi guys I am using entity framework, I am facing some problem while checking
I am facing some problem while including ZXingWidget to my previous iOS project. It
Hope you all fine.I am facing some sort of problem while passing multiple parameters

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.