import java.awt.*;

import javax.swing.*;

/**
 * @author Remi Forax
 *
 */
public class ScrollPaneExample extends JPanel implements Scrollable {

  public boolean getScrollableTracksViewportHeight() {
    return true;
  }

  public boolean getScrollableTracksViewportWidth() {
    return false;
  }

  public Dimension getPreferredScrollableViewportSize() {
    return new Dimension(200,100);
  }

  public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
    return 30;
  }

  public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
    return 5;
  }

  public static void main(String[] args) {
    ScrollPaneExample example=new ScrollPaneExample();
    for(int i=0;i<20;i++)
      example.add(new JButton("Hello "+i));
    
    JFrame frame=new JFrame("ScrollPaneExample");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    frame.setContentPane(new JScrollPane(example));
    frame.pack();
    frame.show();
  }  
}
