JPanel (@NotNull TableView<?> table, @NotNull ActionOnSaveInfo info, @NotNull JCheckBox anchorCheckBox, int anchorBaseline) { if (info.isSaveActionApplicable()) { JBCheckBox checkBox = new JBCheckBox(info.getActionOnSaveName()); checkBox.setAnchor(anchorCheckBox); checkBox.setSelected(info.isActionOnSaveEnabled()); checkBox.addActionListener(e -> { info.setActionOnSaveEnabled(checkBox.isSelected()); int row = table.getEditingRow(); int column = table.getEditingColumn(); if (row >= 0 && column >= 0) { // Comment under the checkbox may depend on the checkbox state. Need to re-create the cell editor component. table.stopEditing(); table.editCellAt(row, column); } }); ComponentPanelBuilder builder = UI.PanelFactory.panel(checkBox); ActionOnSaveComment comment = info.getComment(); if (comment != null) { builder.withComment(comment.getCommentText(), false); if (comment.isWarning()) { builder.withCommentIcon(AllIcons.General.Warning); } } return builder.createPanel(); } JPanel panel = new JPanel(new GridLayout(2, 1, 0, JBUI.scale(3))); JBLabel label = new JBLabel(info.getActionOnSaveName()); // `setEnabled(false)` is not called for this label because on Windows disabled label looks just the same as its comment // The label should have the same indent and baseline as the checkbox text int leftInsetScaled = UIUtil.getCheckBoxTextHorizontalOffset(anchorCheckBox); // already scaled Dimension labelSize = label.getPreferredSize(); int baselineDelta = anchorBaseline - label.getBaseline(labelSize.width, labelSize.height); //noinspection UseDPIAwareBorders - already scaled panel.setBorder(new EmptyBorder(baselineDelta, leftInsetScaled, 0, 0)); panel.add(label); ActionOnSaveComment comment = info.getComment(); if (comment != null) { JLabel commentComponent = ComponentPanelBuilder.createCommentComponent(comment.getCommentText(), true, -1, false); if (comment.isWarning()) { commentComponent.setIcon(AllIcons.General.Warning); } panel.add(commentComponent); } return panel; }