KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > Scrollable


1 /*
2  * @(#)Scrollable.java 1.12 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing;
9
10 import java.awt.Dimension JavaDoc;
11 import java.awt.Rectangle JavaDoc;
12
13
14 /**
15  * An interface that provides information to a scrolling container
16  * like JScrollPane. A complex component that's likely to be used
17  * as a viewing a JScrollPane viewport (or other scrolling container)
18  * should implement this interface.
19  *
20  * @see JViewport
21  * @see JScrollPane
22  * @see JScrollBar
23  * @version 1.12 12/19/03
24  * @author Hans Muller
25  */

26 public interface Scrollable
27 {
28     /**
29      * Returns the preferred size of the viewport for a view component.
30      * For example, the preferred size of a <code>JList</code> component
31      * is the size required to accommodate all of the cells in its list.
32      * However, the value of <code>preferredScrollableViewportSize</code>
33      * is the size required for <code>JList.getVisibleRowCount</code> rows.
34      * A component without any properties that would affect the viewport
35      * size should just return <code>getPreferredSize</code> here.
36      *
37      * @return the preferredSize of a <code>JViewport</code> whose view
38      * is this <code>Scrollable</code>
39      * @see JViewport#getPreferredSize
40      */

41     Dimension JavaDoc getPreferredScrollableViewportSize();
42
43
44     /**
45      * Components that display logical rows or columns should compute
46      * the scroll increment that will completely expose one new row
47      * or column, depending on the value of orientation. Ideally,
48      * components should handle a partially exposed row or column by
49      * returning the distance required to completely expose the item.
50      * <p>
51      * Scrolling containers, like JScrollPane, will use this method
52      * each time the user requests a unit scroll.
53      *
54      * @param visibleRect The view area visible within the viewport
55      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
56      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
57      * @return The "unit" increment for scrolling in the specified direction.
58      * This value should always be positive.
59      * @see JScrollBar#setUnitIncrement
60      */

61     int getScrollableUnitIncrement(Rectangle JavaDoc visibleRect, int orientation, int direction);
62
63
64     /**
65      * Components that display logical rows or columns should compute
66      * the scroll increment that will completely expose one block
67      * of rows or columns, depending on the value of orientation.
68      * <p>
69      * Scrolling containers, like JScrollPane, will use this method
70      * each time the user requests a block scroll.
71      *
72      * @param visibleRect The view area visible within the viewport
73      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
74      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
75      * @return The "block" increment for scrolling in the specified direction.
76      * This value should always be positive.
77      * @see JScrollBar#setBlockIncrement
78      */

79     int getScrollableBlockIncrement(Rectangle JavaDoc visibleRect, int orientation, int direction);
80     
81
82     /**
83      * Return true if a viewport should always force the width of this
84      * <code>Scrollable</code> to match the width of the viewport.
85      * For example a normal
86      * text view that supported line wrapping would return true here, since it
87      * would be undesirable for wrapped lines to disappear beyond the right
88      * edge of the viewport. Note that returning true for a Scrollable
89      * whose ancestor is a JScrollPane effectively disables horizontal
90      * scrolling.
91      * <p>
92      * Scrolling containers, like JViewport, will use this method each
93      * time they are validated.
94      *
95      * @return True if a viewport should force the Scrollables width to match its own.
96      */

97     boolean getScrollableTracksViewportWidth();
98
99     /**
100      * Return true if a viewport should always force the height of this
101      * Scrollable to match the height of the viewport. For example a
102      * columnar text view that flowed text in left to right columns
103      * could effectively disable vertical scrolling by returning
104      * true here.
105      * <p>
106      * Scrolling containers, like JViewport, will use this method each
107      * time they are validated.
108      *
109      * @return True if a viewport should force the Scrollables height to match its own.
110      */

111     boolean getScrollableTracksViewportHeight();
112 }
113
Popular Tags