I have swing application which does following:
public void init() {
jFrame = new JFrame();
...
jFrame.add(sortingDataInputComponent.asComponent());
...
Implement the Scrollable interface in the component to which you add rows and override getPreferredScrollableViewportSize() as shown here for JTable
and here for JList
. Invoking pack()
on the enclosing Window
will cause it to be "sized to fit the preferred size and layouts of its subcomponents."