Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.swing.JViewport

java.lang.Object
    |
    +----java.awt.Component
            |
            +----java.awt.Container
                    |
                    +----java.awt.swing.JComponent
                            |
                            +----java.awt.swing.JViewport

public class JViewport
extends JComponent
implements Accessible
The "view port" through which you see information as it scrolls by underneath the "port hole". Kind of like moving a square magnifying glass up and down a page. Moving the magnifying glass up brings the contents above into view.

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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Inner Class Summary
 JViewport.AccessibleJViewport
The class used to obtain the accessible role for this object.
 JViewport.ViewListener
A listener for the view.
 
Inner classes inherited from class java.awt.swing.JComponent
 JComponent.AccessibleJComponent
 

Field Summary
boolean  backingStore
 
Image  backingStoreImage
 
boolean  isViewSizeSet
 
Point  lastPaintPosition
The last viewPosition that we've painted, so we know how much of the backing store image is valid.
boolean  scrollUnderway
 
 
Fields inherited from class java.awt.swing.JComponent
 accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
 BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 

Constructor Summary
 JViewport()
 
 

Method Summary
void  addChangeListener(ChangeListener l)
Add a ChangeListener to the list that's notified each time the views size, position, or the viewports extent size has changed.
void  addImpl(Component child, Object constraints, int index)
Sets the Viewports one lightweight child, child can be null.
boolean  computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
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.
LayoutManager  createLayoutManager()
Subclassers can override this to install a different layout manager (or null) in the constructor.
JViewport.ViewListener  createViewListener()
 
void  fireStateChanged()
 
AccessibleContext  getAccessibleContext()
Get the AccessibleContext associated with this JComponent
Dimension  getExtentSize()
Returns the size of the visible part of the view in view coordinates.
Insets  getInsets()
 
Component  getView()
Returns the Viewports one child or null.
Point  getViewPosition()
Returns the view coordinates that appear in the upper left hand corner of the viewport, 0,0 if there's no view.
Rectangle  getViewRect()
Return a rectangle whose origin is getViewPosition and size is getExtentSize().
Dimension  getViewSize()
If the views size hasn't been explicitly set return the preferred size, otherwise return the views current size.
boolean  isBackingStoreEnabled()
Returns true if this viewport is maintaining an offscreen image of its contents.
boolean  isOptimizedDrawingEnabled()
 
void  paint(Graphics g)
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.
void  remove(Component child)
 
void  removeChangeListener(ChangeListener l)
Remove a ChangeListener from the list that's notified each time the views size, position, or the viewports extent size has changed.
void  repaint(long tm, int x, int y, int w, int h)
We always repaint in our parent coordinate system to make sure only one paint is performed by the RepaintManager
void  scrollRectToVisible(Rectangle contentRect)
Overridden to scroll the View such that aRect within the View becomes visible.
void  setBackingStoreEnabled(boolean x)
If true if this viewport will maintain an offscreen image of its contents.
void  setBorder(Border border)
The viewport "scrolls" it's child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll).
void  setBounds(int x, int y, int w, int h)
 
void  setExtentSize(Dimension newExtent)
Set the size of the visible part of the view, newExtent is in view coordinates.
void  setView(Component view)
Sets the Viewports one lightweight child, view can be null.
void  setViewPosition(Point p)
Sets the view coordinates that appear in the upper left hand corner of the viewport, null if there's no view.
void  setViewSize(Dimension newSize)
Sets the view coordinates that appear in the upper left hand corner of the viewport, null if there's no view.
Dimension  toViewCoordinates(Dimension size)
Convert a size in pixel coordinates to view coordinates.
Point  toViewCoordinates(Point p)
Convert a point in pixel coordinates to view coordinates.
 
Methods inherited from class java.awt.swing.JComponent
 addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setBounds, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
 add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
 action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isViewSizeSet

protected boolean isViewSizeSet

lastPaintPosition

protected Point lastPaintPosition
The last viewPosition that we've painted, so we know how much of the backing store image is valid.

backingStore

protected boolean backingStore

backingStoreImage

protected Image backingStoreImage

scrollUnderway

protected boolean scrollUnderway
Constructor Detail

JViewport

public JViewport()
Method Detail

addImpl

protected void addImpl(Component child,
                       Object constraints,
                       int index)
Sets the Viewports one lightweight child, child can be null.
Overrides:
addImpl in class Container
See Also:
setView

remove

public void remove(Component child)
Overrides:
remove in class Container

scrollRectToVisible

public void scrollRectToVisible(Rectangle contentRect)
Overridden to scroll the View such that aRect within the View becomes visible.
Overrides:
scrollRectToVisible in class JComponent

setBorder

public final void setBorder(Border border)
The viewport "scrolls" it's child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll). A non-null border, or non-zero insets, isn't supported, to prevent the geometry of this component from becoming complex enough to inhibit subclassing. To createa JViewport with a border, add it to a JPanel that has a border.
Overrides:
setBorder in class JComponent

getInsets

public final Insets getInsets()
Returns:
new Insets(0, 0, 0, 0)
Overrides:
getInsets in class JComponent
See Also:
setBorder

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
Overrides:
isOptimizedDrawingEnabled in class JComponent

paint

public void paint(Graphics g)
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.
Overrides:
paint in class JComponent

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Overrides:
setBounds in class Component

isBackingStoreEnabled

public boolean isBackingStoreEnabled()
Returns true if this viewport is maintaining an offscreen image of its contents.

setBackingStoreEnabled

public void setBackingStoreEnabled(boolean x)
If true if this viewport will maintain an offscreen image of its contents. The image is used to reduce the cost of small one dimensional changes to the viewPosition. Rather than repainting the entire viewport we use Graphics.copyArea() to effect some of the scroll.

getView

public Component getView()
Returns the Viewports one child or null.
See Also:
setView

setView

public void setView(Component view)
Sets the Viewports one lightweight child, view can be null.
See Also:
getView

getViewSize

public Dimension getViewSize()
If the views size hasn't been explicitly set return the preferred size, otherwise return the views current size. If there's no view return 0,0.

setViewSize

public void setViewSize(Dimension newSize)
Sets the view coordinates that appear in the upper left hand corner of the viewport, null if there's no view.

getViewPosition

public Point getViewPosition()
Returns the view coordinates that appear in the upper left hand corner of the viewport, 0,0 if there's no view.

setViewPosition

public void setViewPosition(Point p)
Sets the view coordinates that appear in the upper left hand corner of the viewport, null if there's no view.

getViewRect

public Rectangle getViewRect()
Return a rectangle whose origin is getViewPosition and size is getExtentSize(). This is the visible part of the view, in view coordinates.
Returns:
The visible part of the view, in view coordinates.

computeBlit

protected boolean computeBlit(int dx,
                              int dy,
                              Point blitFrom,
                              Point blitTo,
                              Dimension blitSize,
                              Rectangle blitPaint)
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. The blit* parameters are returned.

getExtentSize

public Dimension getExtentSize()
Returns the size of the visible part of the view in view coordinates.

toViewCoordinates

public Dimension toViewCoordinates(Dimension size)
Convert a size in pixel coordinates to view coordinates. Subclasses of viewport that support "logical coordinates" will override this method.

toViewCoordinates

public Point toViewCoordinates(Point p)
Convert a point in pixel coordinates to view coordinates. Subclasses of viewport that support "logical coordinates" will override this method.

setExtentSize

public void setExtentSize(Dimension newExtent)
Set the size of the visible part of the view, newExtent is in view coordinates.

createViewListener

protected JViewport.ViewListener createViewListener()

createLayoutManager

protected LayoutManager createLayoutManager()
Subclassers can override this to install a different layout manager (or null) in the constructor. Returns a new JViewportLayout object.

addChangeListener

public void addChangeListener(ChangeListener l)
Add a ChangeListener to the list that's notified each time the views size, position, or the viewports extent size has changed.
See Also:
removeChangeListener, setViewPosition, setViewSize, setExtentSize

removeChangeListener

public void removeChangeListener(ChangeListener l)
Remove a ChangeListener from the list that's notified each time the views size, position, or the viewports extent size has changed.
See Also:
addChangeListener

fireStateChanged

protected void fireStateChanged()

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int w,
                    int h)
We always repaint in our parent coordinate system to make sure only one paint is performed by the RepaintManager
Overrides:
repaint in class JComponent

getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent
Implements:
getAccessibleContext in interface Accessible
Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.