Divider () { return new DividerImpl() { @Override public void setOrientation(boolean isVerticalSplit) { removeAll(); setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); List<JComponent> actionComponents = Arrays.asList(createActionComponent(myTopAction), createActionComponent(myBottomAction)); List<JComponent> syncComponents = DiffUtil.createSyncHeightComponents(actionComponents); GridBag bag = new GridBag(); JComponent button1 = syncComponents.get(0); JComponent button2 = syncComponents.get(1); if (button1 != null) { int width = button1.getPreferredSize().width; if (getDividerWidth() < width) setDividerWidth(width); } if (button2 != null) { int width = button2.getPreferredSize().width; if (getDividerWidth() < width) setDividerWidth(width); } if (button1 != null) { add(button1, bag.nextLine()); } if (button1 != null && button2 != null) { add(Box.createVerticalStrut(JBUIScale.scale(20)), bag.nextLine()); } if (button2 != null) { add(button2, bag.nextLine()); } revalidate(); repaint(); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (myPainter != null) myPainter.paint(g, this); } }; }