private void addRow(@NotNull Collection<JComponent> rowComponents) { JPanel row = new MultiRowFlowPanel(FlowLayout.CENTER, getGapToUse(0), getGapToUse(3)); row.setBackground(myBackgroundColor); myComponents.add(row); if (rowComponents.isEmpty()) { row.add(new JLabel(" ")); } else { for (JComponent component : rowComponents) { row.add(component); } } GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.insets.top = 3; myResult.add(row, constraints); }
@NotNull private MultiRowFlowPanel addRowIfNecessary(@NotNull MultiRowFlowPanel panel) { if (panel.getComponentCount() <= 0) { return panel; } add(panel, new GridBag().anchor(GridBagConstraints.WEST).weightx(1).fillCellHorizontally().coverLine()); myRows.add(panel); return new MultiRowFlowPanel( FlowLayout.LEFT, ArrangementConstants.HORIZONTAL_GAP, ArrangementConstants.VERTICAL_GAP ); }
@Nonnull private MultiRowFlowPanel addRowIfNecessary(@Nonnull MultiRowFlowPanel panel) { if (panel.getComponentCount() <= 0) { return panel; } add(panel, new GridBag().anchor(GridBagConstraints.WEST).weightx(1).fillCellHorizontally().coverLine()); myRows.add(panel); return new MultiRowFlowPanel( FlowLayout.LEFT, ArrangementConstants.HORIZONTAL_GAP, ArrangementConstants.VERTICAL_GAP ); }
public void applyAvailableWidth(int width) { for (MultiRowFlowPanel row : myRows) { row.setForcedWidth(width - myLabelWidth); } validate(); }