JComponent (@NotNull TableView<?> table, @NotNull ActionOnSaveInfo info, boolean hovered) { JPanel resultPanel = new JPanel(new GridBagLayout()); resultPanel.setBorder(JBUI.Borders.empty(TOP_INSET, 8, 0, 0)); // This anchorCheckBox is not painted and doesn't appear in the UI component hierarchy. Its purpose is to make sure that the preferred // size of the real checkBox is calculated correctly. The problem is that com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder.getBorderInsets() // returns different result for a checkbox that has CellRendererPane class as its UI ancestor. We need TableCellEditor and // TableCellRenderer to look 100% identically. // Its second goal is to normalize baseline of other components. // The third use case is to calculate checkbox text horizontal offset - needed to align a label if label is used instead of a checkbox. JCheckBox anchorCheckBox = new JCheckBox(info.getActionOnSaveName()); Dimension cbSize = anchorCheckBox.getPreferredSize(); int anchorBaseline = anchorCheckBox.getBaseline(cbSize.width, cbSize.height); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.NONE; resultPanel.add(createActionNamePanel(table, info, anchorCheckBox, anchorBaseline), gbc); gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.NORTHEAST; if (hovered) { for (ActionLink link : info.getActionLinks()) { Dimension linkSize = link.getPreferredSize(); int baselineDelta = anchorBaseline - link.getBaseline(linkSize.width, linkSize.height); //noinspection UseDPIAwareInsets - baselineDelta is already scaled gbc.insets = new Insets(baselineDelta, JBUI.scale(5), 0, JBUI.scale(7)); resultPanel.add(link, gbc); } } for (JComponent control : info.getDropDownLinks()) { Dimension linkSize = control.getPreferredSize(); int baselineDelta = anchorBaseline - control.getBaseline(linkSize.width, linkSize.height); //noinspection UseDPIAwareInsets - baselineDelta is already scaled gbc.insets = new Insets(baselineDelta, JBUI.scale(5), 0, JBUI.scale(7)); resultPanel.add(control, gbc); } setupTableCellBackground(resultPanel, hovered); return resultPanel; }