Layout problem - Table does not take full space

I’m struggling with the following layout problem and hopefully someone can help me:

I have a simple HorizontalLayout to which I add two components: A fixed-width Panel and a Table


However I want the table to take the full space available but it doesn’t.
It only takes approx. half of the space and leaves a large empty space between itself and the panel.

Here’s a sample code to demonstrate the problem:

import com.vaadin.Application;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

public class UI extends Application {

    Table table;

    @Override
    public void init() {
        Window window = new Window();
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSizeFull();
        
        table = new Table("Table");
        table.setSizeFull();
        addData();

        horizontalLayout.addComponent(createMenu());
        horizontalLayout.addComponent(table);

        window.addComponent(horizontalLayout);
        this.setMainWindow(window);
    }

    private void addData() {
        IndexedContainer container = new IndexedContainer();
        Item item = null;
        container.addContainerProperty("Firstname", String.class, null);
        container.addContainerProperty("Lastname", String.class, null);

        item = container.getItem(container.addItem());

        item.getItemProperty("Firstname").setValue("John");
        item.getItemProperty("Lastname").setValue("Doe");
        table.setContainerDataSource(container);
    }

    private Panel createMenu() {
        VerticalLayout rightLayout = new VerticalLayout();
        Panel menuPanel = new Panel(rightLayout);
        menuPanel.setSizeFull();
        menuPanel.setWidth("219px");
        menuPanel.setCaption("Menu");
        menuPanel.addComponent(new Label("Link 1"));
        menuPanel.addComponent(new Label("Link 2"));
        return menuPanel;

    }
}

Thank you in advance!

horizontalLayout.setExpandRatio(table,1);

Thank you for your reply, Artur.
I tried your code and now the table expands to the full size of the layout.

However now if the table has many columns only a few are shown, the rest of the columns is not shown since the layout is too small to show them all. No ScrollPane is shown either to resolve the problem.

Do you have any advise?