javax.swing
public class JViewport extends JComponent implements Accessible
_ +-------------------------------+ ...........Y1 \ | view | . \ | (this component's child) | . > VY | | . / = Y2-Y1 | +------------------------------+ ....Y2_/ | | viewport | | . | | (this component) | | . | | | | . | | | | . | | | | . | | | | . | +------------------------------+ ....Y3 | | . | . | . . | . | . . +---------.---------------------+ ...........Y4 . . . . . . . . . . . . X1.......X2.....................X3.......X4 \____ ___/ \/ VX = X2-X1
A viewport is, like all swing components, located at some position in the swing component tree; that location is exactly the same as any other components: the viewport's "bounds".
But in terms of drawing its child, the viewport thinks of itself as
covering a particular position of the view's coordinate space.
For example, the {@link #getViewPosition} method returns
the position (VX,VY)
shown above, which is an position in
"view space", even though this is implemented by positioning
the underlying child at position (-VX,-VY)
Nested Class Summary | |
---|---|
protected class | JViewport.AccessibleJViewport
Provides accessibility support for JViewport .
|
protected class | JViewport.ViewListener
A {@link java.awt.event.ComponentListener} that listens for
changes of the view's size. |
Field Summary | |
---|---|
protected boolean | backingStore
This flag indicates whether we use a backing store for drawing.
|
protected Image | backingStoreImage
The backingstore image used for the backingstore and blit scroll methods. |
static int | BACKINGSTORE_SCROLL_MODE |
static int | BLIT_SCROLL_MODE |
protected boolean | isViewSizeSet |
protected Point | lastPaintPosition
The position at which the view has been drawn the last time. |
protected boolean | scrollUnderway |
static int | SIMPLE_SCROLL_MODE |
Constructor Summary | |
---|---|
JViewport()
Initializes the default setting for the scrollMode property. |
Method Summary | |
---|---|
void | addChangeListener(ChangeListener listener) |
protected void | addImpl(Component comp, Object constraints, int index) |
protected boolean | computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
Computes the parameters for the blitting scroll method. |
protected LayoutManager | createLayoutManager()
Creates the LayoutManager that is used for this viewport. |
protected JViewport.ViewListener | createViewListener()
Creates a {@link ViewListener} that is supposed to listen for
size changes on the view component.
|
protected void | fireStateChanged() |
AccessibleContext | getAccessibleContext()
Returns the accessible context for this JViewport . |
ChangeListener[] | getChangeListeners() |
Dimension | getExtentSize() |
Insets | getInsets() |
Insets | getInsets(Insets insets) |
int | getScrollMode() |
ViewportUI | getUI()
This method returns the viewport's UI delegate.
|
String | getUIClassID()
This method returns the String ID of the UI class of Separator.
|
Component | getView() |
Point | getViewPosition()
Get the viewport's position in view space. |
Rectangle | getViewRect() |
Dimension | getViewSize()
Returns the viewSize when set, or the preferred size of the set
Component view. |
boolean | isBackingStoreEnabled() |
boolean | isOptimizedDrawingEnabled()
Overridden to return false , so the JViewport's paint method
gets called instead of directly calling the children. |
void | paint(Graphics g) |
void | removeChangeListener(ChangeListener listener) |
void | repaint(long tm, int x, int y, int w, int h)
Forward repaint to parent to make sure only one paint is performed by the
RepaintManager.
|
void | reshape(int x, int y, int w, int h) |
void | scrollRectToVisible(Rectangle contentRect)
Scrolls the view so that contentRect becomes visible.
|
void | setBackingStoreEnabled(boolean b) |
void | setBorder(Border border) |
void | setExtentSize(Dimension newSize) |
void | setScrollMode(int mode) |
void | setUI(ViewportUI ui)
This method sets the viewport's UI delegate.
|
void | setView(Component v) |
void | setViewPosition(Point p) |
void | setViewSize(Dimension newSize) |
Dimension | toViewCoordinates(Dimension size) |
Point | toViewCoordinates(Point p) |
void | updateUI()
This method resets the UI used to the Look and Feel defaults.. |
Deprecated: since JDK 1.3
This flag indicates whether we use a backing store for drawing.dx
and dy
specifiy the X and Y offset by which the viewport
is scrolled. All other arguments are output parameters and are filled by
this method.
blitFrom
holds the position of the blit rectangle in the
viewport rectangle before scrolling, blitTo
where the blitArea
is copied to.
blitSize
holds the size of the blit area and
blitPaint
is the area of the view that needs to be painted.
This method returns true
if blitting is possible and
false
if the viewport has to be repainted completetly without
blitting.
Parameters: dx the horizontal delta dy the vertical delta blitFrom the position from where to blit; set by this method blitTo the position where to blit area is copied to; set by this method blitSize the size of the blitted area; set by this method blitPaint the area that needs repainting; set by this method
Returns: true
if blitting is possible,
false
otherwise
Returns: a LayoutManager to use for this viewport
Returns: a ViewListener instance
JViewport
. This
will be an instance of {@link AccessibleJViewport}.
Returns: the accessible context for this JViewport
Returns: The viewport's UI delegate.
Returns: The UI class' String ID.
Deprecated: 1.4
false
, so the JViewport's paint method
gets called instead of directly calling the children. This is necessary
in order to get a useful clipping and translation on the children.
Returns: false
Parameters: tm number of milliseconds to defer the repaint request x the X coordinate of the upper left corner of the dirty area y the Y coordinate of the upper left corner of the dirty area w the width of the dirty area h the height of the dirty area
Parameters: contentRect the rectangle to make visible within the view
Deprecated: 1.4
Parameters: ui The viewport's UI delegate.