/*
 * TV-Browser
 * Copyright (C) 04-2003 Martin Oberhauser (martin_oat@yahoo.de)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * CVS information:
 *     $Date: 2011-03-26 17:33:19 +0100 (Sa, 26 Mär 2011) $
 *   $Author: bananeweizen $
 * $Revision: 6970 $
 */
package util.ui;

import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Rectangle;

import javax.swing.JPanel;
import javax.swing.Scrollable;

/**
 * A JPanel that can be scrolled vertcal if contained in a JScrollPane.
 * 
 * @author René Mach
 * @since 2.5.1
 */
public class ScrollableJPanel extends JPanel implements Scrollable {

  /**
   * Creates an instance of this panel with the default layout.
   */
  public ScrollableJPanel() {
    super();
  }
  
  /**
   * Creates an instance of this panel with the given layout.
   * @param layout The layout to use.
   */
  public ScrollableJPanel(LayoutManager layout) {
    super(layout);
  }
  
  public Dimension getPreferredScrollableViewportSize() {
    return getPreferredSize();
  }

  public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
    return 50;
  }

  public boolean getScrollableTracksViewportHeight() {
    return false;
  }

  public boolean getScrollableTracksViewportWidth() {
    return true;
  }

  public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
    return 20;
  }
  
}