java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JViewport
Safe:
(package private) static Object
EnableWindowBlit
protected Point
lastPaintPosition
viewPosition that we've painted, so we know how
much of the backing store image is valid.
private boolean
repaintAll
setViewPosition
if doing a window blit and the viewport is obscured.
private Timer
repaintTimer
Timer
is started and when it fires, repaint is invoked.
static int
SIMPLE_SCROLL_MODE
private boolean
waitingForRepaint
repaintAll
is true and the clip rectangle does not match the bounds.
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
void
addChangeListener(ChangeListener l)
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(Component child,
Object constraints,
int index)
JViewport's one lightweight child,
which can be null.
private void
blitDoubleBuffered(JComponent view,
Graphics g,
int clipX,
int clipY,
int clipW,
int clipH,
int blitFromX,
int blitFromY,
int blitToX,
int blitToY,
int blitW,
int blitH,
Image off)
private void
blitWindowGraphics(int x,
int y,
int w,
int h,
int ox,
int oy)
ox, oy.
private boolean
canUseWindowBlitter()
protected boolean
computeBlit(int dx,
int dy,
Point blitFrom,
Point blitTo,
Dimension blitSize,
Rectangle blitPaint)
oldLoc in the upper left hand corner
and we're scrolling to newLoc.
protected LayoutManager
createLayoutManager()
null) in the constructor.
protected void
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
protected void
fireStateChanged()
ChangeListeners when the views
size, position, or the viewports extent size has changed.
private void
flushViewDirtyRegion(Graphics g)
AccessibleContext
getAccessibleContext()
ChangeListener[]
getChangeListeners()
ChangeListeners added
to this JViewport with addChangeListener().
Dimension
getExtentSize()
Insets
getInsets()
JViewport.
Insets
getInsets(Insets insets)
Insets object containing this
JViewports inset values.
String
getUIClassID()
Point
getViewPosition()
Rectangle
getViewRect()
getViewPosition
and size is getExtentSize.
Dimension
getViewSize()
boolean
isBackingStoreEnabled()
getScrollMode().
boolean
isOptimizedDrawingEnabled()
JViewport overrides the default implementation of
this method (in JComponent) to return false.
private boolean
needsRepaintAfterBlit()
void
paint(Graphics g)
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.
private void
paintViewDoubleBuffered(JComponent view,
Graphics g,
int clipX,
int clipY,
int clipW,
int clipH,
Image off)
void
removeChangeListener(ChangeListener l)
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)
RepaintManager.
void
scrollRectToVisible(Rectangle contentRect)
Rectangle
within the view becomes visible.
void
setBackingStoreEnabled(boolean enabled)
setScrollMode().
void
setBorder(javax.swing.border.Border border)
void
setExtentSize(Dimension newExtent)
void
setScrollMode(int mode)
void
setUI(javax.swing.plaf.ViewportUI ui)
void
setView(Component view)
JViewport's one lightweight child
(view), which can be null.
void
setViewPosition(Point p)
Dimension
toViewCoordinates(Dimension size)
Point
toViewCoordinates(Point p)
private void
validateView()
Viewport's parents stopping when
a component is found that returns
true to isValidateRoot.
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, size, transferFocusBackward, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
private static final String uiClassID
static final Object EnableWindowBlit
protected boolean isViewSizeSet
protected Point lastPaintPosition
viewPosition that we've painted, so we know how
much of the backing store image is valid.
protected boolean backingStore
false.
setScrollMode(int)protected transient Image backingStoreImage
protected boolean scrollUnderway
scrollUnderway flag is used for components like
JList. When the downarrow key is pressed on a
JList and the selected
cell is the last in the list, the scrollpane autoscrolls.
Here, the old selected cell needs repainting and so we need
a flag to make the viewport do the optimized painting
only when there is an explicit call to
setViewPosition(Point).
When setBounds is called through other routes,
the flag is off and the view repaints normally. Another approach
would be to remove this from the JViewport
class and have the JList manage this case by using
setBackingStoreEnabled. The default is
false.
private ComponentListener viewListener
private transient ChangeEvent changeEvent
public static final int BLIT_SCROLL_MODE
graphics.copyArea to implement scrolling.
This is the fastest for most applications.
setScrollMode(int)public static final int BACKINGSTORE_SCROLL_MODE
JTable.
This mode may offer advantages over "blit mode"
in some cases, but it requires a large chunk of extra RAM.
setScrollMode(int)public static final int SIMPLE_SCROLL_MODE
setScrollMode(int)private int scrollMode
setScrollMode(int)private transient boolean repaintAll
setViewPosition
if doing a window blit and the viewport is obscured.
private transient boolean waitingForRepaint
repaintAll
is true and the clip rectangle does not match the bounds.
If true, and scrolling happens the
repaint manager is not cleared which then allows for the repaint
previously invoked to succeed.
private transient Timer repaintTimer
Timer
is started and when it fires, repaint is invoked.
public JViewport()
JViewport.
public javax.swing.plaf.ViewportUI getUI()
ViewportUI objectpublic void setUI(javax.swing.plaf.ViewportUI ui)
ui - the ViewportUI L&F objectUIDefaults.getUI(javax.swing.JComponent)public void updateUI()
updateUI in class JComponentJComponent.updateUI()public String getUIClassID()
getUIClassID in class JComponentJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)protected void addImpl(Component child, Object constraints, int index)
JViewport's one lightweight child,
which can be null.
(Since there is only one child which occupies the entire viewport,
the constraints and index
arguments are ignored.)
child - the lightweight child of the viewportconstraints - the constraints to be respectedindex - the indexsetView(java.awt.Component)public void remove(Component child)
Viewports one lightweight child.
child - the component to be removedsetView(java.awt.Component)public void scrollRectToVisible(Rectangle contentRect)
Rectangle
within the view becomes visible.
This attempts to validate the view before scrolling if the
view is currently not valid - isValid returns false.
To avoid excessive validation when the containment hierarchy is
being created this will not validate if one of the ancestors does not
have a peer, or there is no validate root ancestor, or one of the
ancestors is not a Window or Applet.
Note that this method will not scroll outside of the
valid viewport; for example, if contentRect is larger
than the viewport, scrolling will be confined to the viewport's
bounds.
scrollRectToVisible in class JComponentcontentRect - the Rectangle to displayJComponent.isValidateRoot(),
java.awt.Component#isValid,
java.awt.Component#getPeerprivate void validateView()
Viewport's parents stopping when
a component is found that returns
true to isValidateRoot.
If all the Component's parents are visible,
validate will then be invoked on it. The
RepaintManager is then invoked with
removeInvalidComponent. This
is the synchronous version of a revalidate.
private int positionAdjustment(int parentWidth, int childWidth, int childAt)
public final void setBorder(javax.swing.border.Border border)
null border,
or non-zero insets, isn't supported, to prevent the geometry
of this component from becoming complex enough to inhibit
subclassing. To create a JViewport with a border,
add it to a JPanel that has a border.
Note: If border is non-null, this
method will throw an exception as borders are not supported on
a JViewPort.
setBorder in class JComponentborder - the Border to setBorder,
CompoundBorderpublic final Insets getInsets()
JViewport.
getInsets in class JComponentRectange of zero dimension and zero originsetBorder(javax.swing.border.Border)public final Insets getInsets(Insets insets)
Insets object containing this
JViewports inset values. The passed-in
Insets object will be reinitialized, and
all existing values within this object are overwritten.
getInsets in class JComponentinsets - the Insets object which can be reused
getInsets()private Graphics getBackingStoreGraphics(Graphics g)
private void paintViaBackingStore(Graphics g)
private void paintViaBackingStore(Graphics g, Rectangle oClip)
public boolean isOptimizedDrawingEnabled()
JViewport overrides the default implementation of
this method (in JComponent) to return false.
This ensures
that the drawing machinery will call the Viewport's
paint
implementation rather than messaging the JViewport's
children directly.
isOptimizedDrawingEnabled in class JComponentprivate Point getViewLocation()
public void paint(Graphics g)
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.
The term "blit" is the pronounced version of the PDP-10 BLT (BLock Transfer) instruction, which copied a block of bits. (In case you were curious.)
paint in class JComponentg - the Graphics context within which to paintJComponent.paintComponent(java.awt.Graphics),
JComponent.paintBorder(java.awt.Graphics),
JComponent.paintChildren(java.awt.Graphics),
JComponent.getComponentGraphics(java.awt.Graphics),
JComponent.repaint(long, int, int, int, int)public void reshape(int x, int y, int w, int h)
StateChanged event.
reshape in class JComponentx - left edge of the originy - top edge of the originw - width in pixelsh - height in pixelsJComponent.reshape(int, int, int, int)public void setScrollMode(int mode)
mode - one of the following values:
BLIT_SCROLL_MODE,
BACKINGSTORE_SCROLL_MODE,
SIMPLE_SCROLL_MODEpublic int getScrollMode()
scrollMode propertysetScrollMode(int)public boolean isBackingStoreEnabled()
getScrollMode().
true if this viewport is maintaining
an offscreen image of its contents.
true if scrollMode is
BACKINGSTORE_SCROLL_MODEpublic void setBackingStoreEnabled(boolean enabled)
setScrollMode().
viewPosition.
Rather than repainting the entire viewport we use
Graphics.copyArea to effect some of the scroll.
enabled - if true, maintain an offscreen backing storeprivate final boolean isBlitting()
public Component getView()
JViewport's one child or null.
null if none existssetView(java.awt.Component)public void setView(Component view)
JViewport's one lightweight child
(view), which can be null.
view - the viewport's new lightweight childgetView()public Dimension getViewSize()
Dimension object specifying the size of the viewpublic void setViewSize(Dimension newSize)
newSize - a Dimension object specifying the new
size of the viewpublic Point getViewPosition()
Point object giving the upper left coordinatespublic void setViewPosition(Point p)
p - a Point object giving the upper left coordinatespublic Rectangle getViewRect()
getViewPosition
and size is getExtentSize.
This is the visible part of the view, in view coordinates.
Rectangle giving the visible part of
the view using view coordinates.protected boolean computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
oldLoc in the upper left hand corner
and we're scrolling to newLoc.
The parameters are modified
to return the values required for the blit.
dx - the horizontal deltady - the vertical deltablitFrom - the Point we're blitting fromblitTo - the Point we're blitting toblitSize - the Dimension of the area to blitblitPaint - the area to blit
public Dimension getExtentSize()
Dimension object giving the size of the viewpublic Dimension toViewCoordinates(Dimension size)
size - a Dimension object using pixel coordinates
Dimension object converted to view coordinatespublic Point toViewCoordinates(Point p)
p - a Point object using pixel coordinates
Point object converted to view coordinatespublic void setExtentSize(Dimension newExtent)
newExtent - a Dimension object specifying
the size of the viewprotected javax.swing.JViewport.ViewListener createViewListener()
ViewListenerprotected LayoutManager createLayoutManager()
null) in the constructor. Returns
a new ViewportLayout object.
LayoutManagerpublic void addChangeListener(ChangeListener l)
ChangeListener to the list that is
notified each time the view's
size, position, or the viewport's extent size has changed.
l - the ChangeListener to addremoveChangeListener(javax.swing.event.ChangeListener),
setViewPosition(java.awt.Point),
setViewSize(java.awt.Dimension),
setExtentSize(java.awt.Dimension)public void removeChangeListener(ChangeListener l)
ChangeListener from the list that's notified each
time the views size, position, or the viewports extent size
has changed.
l - the ChangeListener to removeaddChangeListener(javax.swing.event.ChangeListener)public ChangeListener[] getChangeListeners()
ChangeListeners added
to this JViewport with addChangeListener().
ChangeListeners added or an empty
array if no listeners have been addedprotected void fireStateChanged()
ChangeListeners when the views
size, position, or the viewports extent size has changed.
public void repaint(long tm, int x, int y, int w, int h)
RepaintManager.
repaint in class JComponenttm - maximum time in milliseconds before updatex - the x coordinate (pixels over from left)y - the y coordinate (pixels down from top)w - the width of the dirty regionh - the height of the dirty regionjava.awt.Component#update(java.awt.Graphics)protected String paramString()
JViewport.
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null.
paramString in class JComponentJViewportprotected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
windowBlit property.
(The putClientProperty property is final).
firePropertyChange in class JComponentpropertyName - a string containing the property nameoldValue - the old value of the propertynewValue - the new value of the propertyjava.beans.PropertyChangeSupportprivate boolean needsRepaintAfterBlit()
private Timer createRepaintTimer()
private void flushViewDirtyRegion(Graphics g)
g - the Graphics context within which to paintprivate boolean windowBlitPaint(Graphics g)
g - the Graphics context within which to paint
private void blitDoubleBuffered(JComponent view, Graphics g, int clipX, int clipY, int clipW, int clipH, int blitFromX, int blitFromY, int blitToX, int blitToY, int blitW, int blitH, Image off)
private void paintView(Graphics g)
blitPaint
can not blit.
g - the Graphics context within which to paintprivate void paintViewDoubleBuffered(JComponent view, Graphics g, int clipX, int clipY, int clipW, int clipH, Image off)
private void blitWindowGraphics(int x, int y, int w, int h, int ox, int oy)
ox, oy.
private boolean canUseWindowBlitter()
copyArea will work,
but will not produce the expected behavior.
public AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponent