|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
![]()
![]()
![]()
javax.swing.JViewport
, MenuContainer
, Serializable
, Accessible

public class JViewport


The "viewport" or "porthole" through which you see the underlying information. When you scroll, what moves is the viewport. It is like peering through a camera's viewfinder. Moving the viewfinder upwards brings new things into view at the top of the picture and loses things that were at the bottom.
By default, JViewport is opaque. To change this, use the
setOpaque method.
NOTE:We have implemented a faster scrolling algorithm that does not require a buffer to draw in. The algorithm works as follows:
JComponents,
if they aren't, stop and repaint the whole viewport.
Window's graphics and
do a copyArea on the scrolled region.
copyAreas.
Compared to the non backing store case this
approach will greatly reduce the painted region.
This approach can cause slower times than the backing store approach when the viewport is obscured by another window, or partially offscreen. When another window obscures the viewport the copyArea will copy garbage and a paint event will be generated by the system to inform us we need to paint the newly exposed region. The only way to handle this is to repaint the whole viewport, which can cause slower performance than the backing store case. In most applications very rarely will the user be scrolling while the viewport is obscured by another window or offscreen, so this optimization is usually worth the performance hit when obscured.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
JScrollPane
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
JViewport.AccessibleJViewport
This class implements accessibility support for the JViewport class. |
protected class |
JViewport.ViewListener
A listener for the view. |
Nested classes/interfaces inherited from class javax.swing.JComponent ![]() |
|---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
protected boolean |
backingStore
Deprecated. As of Java 2 platform v1.3 |
static int |
BACKINGSTORE_SCROLL_MODE
Draws viewport contents into an offscreen image. |
protected Image |
backingStoreImage
The view image used for a backing store. |
static int |
BLIT_SCROLL_MODE
Use graphics.copyArea to implement scrolling. |
protected boolean |
isViewSizeSet
True when the viewport dimensions have been determined. |
protected Point |
lastPaintPosition
The last viewPosition that we've painted, so we know how
much of the backing store image is valid. |
protected boolean |
scrollUnderway
The scrollUnderway flag is used for components like
JList. |
static int |
SIMPLE_SCROLL_MODE
This mode uses the very simple method of redrawing the entire contents of the scrollpane each time it is scrolled. |
Fields inherited from class javax.swing.JComponent ![]() |
|---|
accessibleContext |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JViewport
Creates a JViewport. |
|
| Method Summary | |
|---|---|
void |
addChangeListener
Adds a ChangeListener to the list that is
notified each time the view's
size, position, or the viewport's extent size has changed. |
protected void |
addImpl
Sets the JViewport's one lightweight child,
which can be null. |
protected boolean |
computeBlit
Computes the parameters for a blit where the backing store image currently contains oldLoc in the upper left hand corner
and we're scrolling to newLoc. |
protected LayoutManager |
createLayoutManager
Subclassers can override this to install a different layout manager (or null) in the constructor. |
protected JViewport.ViewListener |
createViewListener
Creates a listener for the view. |
protected void |
firePropertyChange
Notifies listeners of a property change. |
protected void |
fireStateChanged
Notifies all ChangeListeners when the views
size, position, or the viewports extent size has changed. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this JViewport. |
ChangeListener |
getChangeListeners
Returns an array of all the ChangeListeners added
to this JViewport with addChangeListener(). |
Dimension |
getExtentSize
Returns the size of the visible part of the view in view coordinates. |
Insets |
getInsets
Returns the insets (border) dimensions as (0,0,0,0), since borders are not supported on a JViewport. |
Insets |
getInsets
Returns an Insets object containing this
JViewports inset values. |
int |
getScrollMode
Returns the current scrolling mode. |
ViewportUI |
getUI
Returns the L&F object that renders this component. |
String |
getUIClassID
Returns a string that specifies the name of the L&F class that renders this component. |
Component |
getView
Returns the JViewport's one child or null. |
Point |
getViewPosition
Returns the view coordinates that appear in the upper left hand corner of the viewport, or 0,0 if there's no view. |
Rectangle |
getViewRect
Returns a rectangle whose origin is getViewPosition
and size is getExtentSize. |
Dimension |
getViewSize
If the view's size hasn't been explicitly set, return the preferred size, otherwise return the view's current size. |
boolean |
isBackingStoreEnabled
Deprecated. As of Java 2 platform v1.3, replaced by getScrollMode(). |
boolean |
isOptimizedDrawingEnabled
The JViewport overrides the default implementation of
this method (in JComponent) to return false. |
void |
paint
Depending on whether the backingStore is enabled,
either paint the image through the backing store or paint
just the recently exposed part, using the backing store
to "blit" the remainder. |
protected String |
paramString
Returns a string representation of this JViewport. |
void |
remove
Removes the Viewports one lightweight child. |
void |
removeChangeListener
Removes a ChangeListener from the list that's notified each
time the views size, position, or the viewports extent size
has changed. |
void |
repaint
Always repaint in the parents coordinate system to make sure only one paint is performed by the RepaintManager. |
void |
reshape
Sets the bounds of this viewport. |
void |
scrollRectToVisible
Scrolls the view so that Rectangle
within the view becomes visible. |
void |
setBackingStoreEnabled
Deprecated. As of Java 2 platform v1.3, replaced by setScrollMode(). |
void |
setBorder
The viewport "scrolls" its child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll). |
void |
setExtentSize
Sets the size of the visible part of the view using view coordinates. |
void |
setScrollMode
Used to control the method of scrolling the viewport contents. |
void |
setUI
Sets the L&F object that renders this component. |
void |
setView
Sets the JViewport's one lightweight child
(view), which can be null. |
void |
setViewPosition
Sets the view coordinates that appear in the upper left hand corner of the viewport, does nothing if there's no view. |
void |
setViewSize
Sets the size of the view. |
Dimension |
toViewCoordinates
Converts a size in pixel coordinates to view coordinates. |
Point |
toViewCoordinates
Converts a point in pixel coordinates to view coordinates. |
void |
updateUI
Resets the UI property to a value from the current look and feel. |
Methods inherited from class javax.swing.JComponent ![]() |
|---|
addAncestorListener |