JPanel () { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); for (int i = 0; i < myOptions.size(); i++) { int top = i == 0 ? 0 : UIUtil.DEFAULT_VGAP; int left = myIndented.get(i) ? IdeBorderFactory.TITLED_BORDER_INDENT : 0; Object option = myOptions.get(i); if (option instanceof JComponent component) { panel.add(component, new GridBagConstraints(0, i, REMAINDER, 1, 1, 0, WEST, getFill(component), JBUI.insets(top, left, 0, 0), 0, 0)); } else { JComponent first = (JComponent)((Pair<?, ?>)option).first; panel.add(first, new GridBagConstraints(0, i, 1, 1, 1, 0, WEST, getFill(first), JBUI.insets(top, left, 0, 0), 0, 0)); JComponent second = (JComponent)((Pair<?, ?>)option).second; panel.add(second, new GridBagConstraints(1, i, 1, 1, 1, 0, EAST, HORIZONTAL, JBUI.insets(top, UIUtil.DEFAULT_HGAP, 0, 0), 0, 0)); if (first instanceof JLabel) { ((JLabel)first).setLabelFor(second); } } } JPanel p = new JPanel(); p.setPreferredSize(new Dimension(0, 0)); panel.add(p, new GridBagConstraints(0, myOptions.size(), REMAINDER, 1, 0, 1, NORTH, NONE, JBInsets.emptyInsets(), 0, 0)); if (myTitle != null) { IdeaTitledBorder titledBorder = IdeBorderFactory.createTitledBorder(myTitle, true); panel.setBorder(titledBorder); titledBorder.acceptMinimumSize(panel); } UIUtil.applyDeprecatedBackground(panel); return panel; }