// layouter: voidfunc(Container) or func(Container) -> Dimension // (return value is preferred size) static JPanel customLayoutPanel_trackWidth(fO layouter) { sclass P extends JPanel implements Scrollable { *() { super(new AbstractLayoutManager { public void layoutContainer(Container parent) { Dimension size = cast callF(layouter, parent); if (size != null) preferredSize = size; } }); @Override public Dimension getPreferredScrollableViewportSize() { ret getPreferredSize(); } @Override public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { return 1; } @Override public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return 10; } @Override public bool getScrollableTracksViewportWidth() { true; } @Override public boolean getScrollableTracksViewportHeight() { false; } } ret new P; }