int (int width, int height) { if (getClientProperty(USE_BASELINE_KEY) != Boolean.TRUE || myLayoutPolicy != NOWRAP_LAYOUT_POLICY || myOrientation != SwingConstants.HORIZONTAL) { // Support only one layout now. Can be extended later return super.getBaseline(width, height); } int componentCount = getComponentCount(); List<Rectangle> bounds = new ArrayList<>(); for (int i = 0; i < componentCount; i++) { bounds.add(new Rectangle()); } calculateBoundsNowrapImpl(bounds); int baseline = -1; for (int i = 0; i < componentCount; i++) { Component component = getComponent(i); if (component.isVisible()) { Rectangle rect = bounds.get(i); int b = component.getBaseline(rect.width, rect.height); if (b >= 0) { int baselineInParent = rect.y + b; if (baseline < 0) { baseline = baselineInParent; } else { if (baseline != baselineInParent) { return -1; } } } } } return baseline; }