void (Container parent) { if (parent instanceof JViewport viewport) { Component view = viewport.getView(); if (view != null) { Container grand = viewport.getParent(); if (grand instanceof JScrollPane) { doLayout((JScrollPane)grand, viewport, view); } else { super.layoutContainer(parent); } } } }