Search code examples
intellij-ideagridlayoutmanager

How can i fill my Panels with GridLayoutmanager


firstly look at https://i.sstatic.net/PV03B.jpg

I have a project where I wanna show a Table with some data. it show the data but the panels dont fill verticaly and horizontaly. I use the GridLayoutManager from com.intellij.uiDesigner.core

thats how it looks right now

The table has its own panel and class where it gets its data the class below the table is just a baseClass with all buttons (so i dont need to rewrite the class all the time) and a panel for the table, where it should be filled, and the mainView where i wanna add the tableView and fill it in the panel where it should be added. View first Image

Edit: i add all panels with mainPanel.add(panelToAdd,new GridConstraints());


Solution

  • I found a solution that works. You need to add GridConstraints and set the LayoutManager to these JPanels

    GridConstraints constraints = new GridConstraints();
    constraints.setFill(GridConstraints.FILL_BOTH);
    this.setLayout(new GridLayoutManager(1,1));
    
    this.add(mainPanel, constraints);