import javax.swing.*;
import java.awt.*;
class TestScroll{
JScrollPane sc;
JPanel pan;
JFrame f;
public TestScroll(){
f = new JFrame("Prueba");
pan = new JPanel(new GridLayout(6,0,5,5));
sc = new JScrollPane(pan);
}
public void init(){
for (int i = 0; i < 200; i++) pan.add(new Button(""+i));
f.add(sc, BorderLayout.CENTER);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 500);
f.setVisible(true);
}
public static void main(String args[]){
TestScroll test = new TestScroll();
test.init();
}
}