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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:43:16+00:00 2026-06-05T02:43:16+00:00

I have a problem with a gridLayout to adapted to user screen size, I

  • 0

I have a problem with a gridLayout to adapted to user screen size, I want to create a gridLayout with 3 columns and 2 rows, the first row will contain a menu, the second row will be the body using a panel, and the first column X second row will contain a tree but I can’t get the result that I want, this code show the panel but not full size
Here’s my code I can’t found why it doesn’t work !!

@Override
public void init() {

    Window main = new Window("My App");
    main.setSizeFull();
    setMainWindow(main);

    VerticalLayout root = new VerticalLayout();
    main.setContent(root);
    main.getContent().setSizeFull();

    GridLayout grid = new GridLayout(3, 2);

    main.addComponent(grid);

    grid.setColumnExpandRatio(0, 0.13f);
    grid.setColumnExpandRatio(1, 0.86f);
    grid.setColumnExpandRatio(2, 0.0f);


    grid.setHeight(100, Sizeable.UNITS_PERCENTAGE);
    grid.setWidth(100,Sizeable.UNITS_PERCENTAGE);


    grid.addComponent(new Label("menu"), 0, 0, 0, 1);
    grid.addComponent(new Label("tree"), 1, 0, 1, 0);

    Panel pan = new Panel();
    pan.setWidth(100, Sizeable.UNITS_PERCENTAGE);
    pan.setHeight(100, Sizeable.UNITS_PERCENTAGE);

    VerticalLayout body = new VerticalLayout();
    body.setSizeFull();

    body.addComponent(pan);

    grid.addComponent(body, 1, 1, 1, 1);

}
  • 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-05T02:43:18+00:00Added an answer on June 5, 2026 at 2:43 am

    Before going into the specifics of your question I wanted to leave you with a tool that can help you understand how the components are expanding in Vaadin:

    • add “?debug” to the end of the address you use to run your application (eg localhost/app/?debug”)
    • little window will appear with buttons on top.
    • press C to clear and then AL to analyse layout
    • a tree of components will appear as result. You can browse that tree by pressing the plus signs
    • every time you press a component (label, panel, etc) the component will be highlighted on the screen.

    With this you can see that my code below has a layout that expands the entire screen, a panel that expands on the 2 last cells of the grid and labels with expanding width

    The debug mode is documented on the book of Vaadin

    I believe the components are expanding correctly but are in the wrong places. Check how GridLayout works in the book of vaadin.
    The following code changes your coordinates and adds a label to show to you the panel is indeed taking the right cells of the grid. Also it seemed more logical to add the VerticalLayout to the panel for alignment than the other way around:

    @Override
    public void init() {
    
    
        Window main = new Window("My App");
        main.setSizeFull();
                setMainWindow(main);
    
                VerticalLayout root = new VerticalLayout();
        main.setContent(root);
        main.getContent().setSizeFull();
    
        GridLayout grid = new GridLayout(3, 2);
    
        main.addComponent(grid);
    
        grid.setColumnExpandRatio(0, 0.13f);
        grid.setColumnExpandRatio(1, 0.86f);
        grid.setColumnExpandRatio(2, 0.0f);
    
    
        grid.setHeight(100, Sizeable.UNITS_PERCENTAGE);
        grid.setWidth(100,Sizeable.UNITS_PERCENTAGE);
    
    
                grid.addComponent(new Label("menu"), 0, 0, 2, 0);
    
                grid.addComponent(new Label("tree"), 0, 1);
    
                Panel pan = new Panel();
        pan.setWidth(100, Sizeable.UNITS_PERCENTAGE);
        pan.setHeight(100, Sizeable.UNITS_PERCENTAGE);
    
    
    
    
        VerticalLayout body = new VerticalLayout();
        body.setSizeFull();
        pan.addComponent(body);
    
        Label bodyLabel= new Label("body panel taking the 2 columns of the last row");
        bodyLabel.setSizeUndefined();
    
    
        body.addComponent(bodyLabel);
        body.setComponentAlignment(bodyLabel, Alignment.MIDDLE_CENTER);
    
        grid.addComponent(pan, 1,1 , 2, 1);
    
             }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
I have problem with HTTP headers, they're encoded in ASCII and I want to
I have another problem with PyQT, this time I have an example that will
I have a problem with understanding the following code: import java.awt.Dimension; import java.awt.GridLayout; import
My current problem is that I have a JFrame with a 2x2 GridLayout. And
I have this interface to create. I have a problem with the JScrollPane: I
I have been struggling with a problem that at first glance might look easy
Hello I have a Problem with some Buttons I would like to create a
The problem I have is that when more rows are added to JTable (jtbls)
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

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.