【问题标题】:How can i fill my Panels with GridLayoutmanager如何使用 GridLayoutmanager 填充我的面板
【发布时间】:2019-02-05 03:46:48
【问题描述】:

先看https://imgur.com/a/1r6sK31

我有一个项目,我想在其中显示一个包含一些数据的表格。 它显示数据,但面板不会垂直和水平填充。 我使用来自 com.intellij.uiDesigner.core 的 GridLayoutManager

thats how it looks right now

表格有自己的面板和类,它可以在其中获取数据 表格下方的类只是一个带有所有按钮的基类(所以我不需要一直重写该类)和一个表格面板,应该填充它,以及我想添加 tableView 并填充它的 mainView在应该添加它的面板中。查看第一张图片

编辑: 我用mainPanel.add(panelToAdd,new GridConstraints());添加所有面板

【问题讨论】:

    标签: intellij-idea gridlayoutmanager


    【解决方案1】:

    我找到了一个可行的解决方案。 您需要添加 GridConstraints 并将 LayoutManager 设置为这些 JPanel

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

    【讨论】:

      猜你喜欢
      • 2011-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多