public class JViewport extends JComponent implements Accessible
默认情况下,JViewport
不透明。要改变这一点,使用setOpaque
方法。
注:we实现更快的滚动算法,不需要缓冲绘制。该算法的工作原理如下:
JComponents
,如果他们不停止和重新粉刷,整个视口。Window
图形在滚动区域做一个copyArea
。copyArea
s开销。相比于非后备存储情况下这种方法将大大降低油漆区。
这种方法会导致较慢的时间比后备存储方法时,视图是由另一个窗口的遮挡,或部分屏幕。当另一个窗口遮住视口的copyArea将垃圾和油漆事件将由系统生成的通知我们我们需要油漆,新暴露的区域。处理这是重画整个视口的唯一途径,可能导致存储支持情况下性能下降。在大多数应用中很少用户滚动而视是由另一个窗口或屏幕的遮挡,因此优化通常是值得的性能损失时遮蔽。
警告: Swing是线程不安全的。更多信息见Swing's Threading Policy。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
JScrollPane
Modifier and Type | Class and Description |
---|---|
protected class |
JViewport.AccessibleJViewport
这个类实现了对
JViewport 类可访问性支持。
|
protected class |
JViewport.ViewListener
视图的侦听器。
|
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected boolean |
backingStore
过时的。
作为java 2平台V1.3
|
static int |
BACKINGSTORE_SCROLL_MODE
绘制视图内容为屏幕图像。
|
protected Image |
backingStoreImage
用于支持存储的视图图像。
|
static int |
BLIT_SCROLL_MODE
使用
graphics.copyArea 实施滚动。
|
protected boolean |
isViewSizeSet
真当视口尺寸已确定。
|
protected Point |
lastPaintPosition
我们已经画上
viewPosition ,所以我们知道多少的后备存储图像是有效的。
|
protected boolean |
scrollUnderway
的
scrollUnderway 旗用于组件
JList 。
|
static int |
SIMPLE_SCROLL_MODE
该模式使用的重每次滚动的滚动窗格的全部内容的简单方法。
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JViewport()
创建一个
JViewport 。
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
添加到列表,通知
ChangeListener 每次视图的大小,位置,或视口的大小发生了变化。
|
protected void |
addImpl(Component child, Object constraints, int index)
集
JViewport 是一个轻量级的孩子,可
null 。
|
void |
addNotify()
通知这个组件,它现在有一个父组件。
|
protected boolean |
computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
计算参数为一个blit,后备存储图像目前包含
oldLoc 在左上角我们滚动
newLoc 。
|
protected LayoutManager |
createLayoutManager()
subclassers可以重写此安装一个不同的布局管理器(或
null )在构造函数。
|
protected JViewport.ViewListener |
createViewListener()
为视图创建一个侦听器。
|
protected void |
firePropertyChange(String propertyName, Object oldValue, Object newValue)
通知属性改变监听器。
|
protected void |
fireStateChanged()
通知所有的
ChangeListeners 当视图的大小,位置,或改变视口的大小。
|
AccessibleContext |
getAccessibleContext()
获取与此相关的accessiblecontext jviewport。
|
ChangeListener[] |
getChangeListeners()
返回所有的
ChangeListener s数组添加到这个jviewport与addchangelistener()。
|
Dimension |
getExtentSize()
返回视图坐标中视图的可见部分的大小。
|
Insets |
getInsets()
返回的插图(境)尺寸为(0,0,0,0),由于边界不支持在一个
JViewport 。
|
Insets |
getInsets(Insets insets)
返回包含这一
Insets
JViewport s对象嵌入值。
|
int |
getScrollMode()
返回当前滚动模式。
|
ViewportUI |
getUI()
返回呈现此组件的L和F对象。
|
String |
getUIClassID()
返回一个字符串,指定呈现此组件的“L”和“F”类的名称。
|
Component |
getView()
返回
JViewport 的一个孩子或
null 。
|
Point |
getViewPosition()
返回在视口的左上角显示的视图坐标,或0如果没有观。
|
Rectangle |
getViewRect()
返回一个矩形的起源是
getViewPosition 和大小
getExtentSize 。
|
Dimension |
getViewSize()
如果视图的大小没有被显式设置,则返回首选的大小,否则返回视图的当前大小。
|
boolean |
isBackingStoreEnabled()
过时的。
作为java 2平台V1.3,取而代之的
getScrollMode() 。
|
boolean |
isOptimizedDrawingEnabled()
的
JViewport 重写此方法的默认实现(在
JComponent )返回false。
|
protected boolean |
isPaintingOrigin()
如果滚动模式是一个
BACKINGSTORE_SCROLL_MODE 导致绘画起源于
JViewport 返回true,或其祖先之一。
|
void |
paint(Graphics g)
这取决于
backingStore 启用,要么画图像通过存储备份或油漆只是最近暴露的部分,使用后备存储“blit”剩下的。
|
protected String |
paramString()
返回该
JViewport 字符串表示形式。
|
void |
remove(Component child)
删除
Viewport s一个轻量级的孩子。
|
void |
removeChangeListener(ChangeListener l)
从列表中删除,每一次的意见通知
ChangeListener 大小,位置,或视口的大小发生了变化。
|
void |
repaint(long tm, int x, int y, int w, int h)
在父母总是重画坐标系统确保只有一个涂料是由
RepaintManager 进行。
|
void |
reshape(int x, int y, int w, int h)
这个视口的边界集。
|
void |
scrollRectToVisible(Rectangle contentRect)
滚动视图,在视图中
Rectangle 变得可见。
|
void |
setBackingStoreEnabled(boolean enabled)
过时的。
作为java 2平台V1.3,取而代之的
setScrollMode() 。
|
void |
setBorder(Border border)
视口“卷轴”的孩子(称为“观”)由正常的父/子卡(通常认为是在滚动的相反方向移动)。
|
void |
setExtentSize(Dimension newExtent)
设置视图坐标的视图的可见部分的大小。
|
void |
setScrollMode(int mode)
用于控制滚动视图内容的方法。
|
void |
setUI(ViewportUI ui)
设置呈现此组件的“L”和F对象。
|
void |
setView(Component view)
集
JViewport 是一个轻量级的孩子(
view ),可
null 。
|
void |
setViewPosition(Point p)
设置视口的左上角显示的视图坐标,没有如果没有观。
|
void |
setViewSize(Dimension newSize)
设置视图的大小。
|
Dimension |
toViewCoordinates(Dimension size)
将像素坐标中的大小转换为视图坐标。
|
Point |
toViewCoordinates(Point p)
将像素坐标中的一个点转换为视图坐标。
|
void |
updateUI()
重置UI属性从目前看价值和感觉。
|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected boolean isViewSizeSet
protected Point lastPaintPosition
viewPosition
,所以我们知道多少的后备存储图像是有效的。
@Deprecated protected boolean backingStore
false
。
setScrollMode(int)
protected transient Image backingStoreImage
protected boolean scrollUnderway
scrollUnderway
旗用于组件
JList
。当downarrow按下键在
JList
和选定的单元格是列表中的最后的
scrollpane
autoscrolls。在这里,老小区需要重新粉刷,所以我们需要一个标志使视口做优化只画的时候有一个明确的
setViewPosition(Point)
电话。当
setBounds
是通过其他途径称,旗下的视图重画通常。另一种方法是删除从
JViewport
类和有
JList
利用
setBackingStoreEnabled
处理这个案件。默认的是
false
。
public static final int BLIT_SCROLL_MODE
graphics.copyArea
实施滚动。对于大多数应用程序,这是最快的。
setScrollMode(int)
,
Constant Field Values
public static final int BACKINGSTORE_SCROLL_MODE
JTable
默认模式。这种模式可以在“显示模式”在某些情况下,提供了许多优点,但它需要大量额外的RAM。
setScrollMode(int)
,
Constant Field Values
public static final int SIMPLE_SCROLL_MODE
setScrollMode(int)
,
Constant Field Values
public ViewportUI getUI()
ViewportUI
对象
public void setUI(ViewportUI ui)
ui
-
ViewportUI
L和F的对象
UIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
updateUI
方法重写,继承类
JComponent
JComponent.updateUI()
public String getUIClassID()
getUIClassID
方法重写,继承类
JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected void addImpl(Component child, Object constraints, int index)
JViewport
是一个轻量级的孩子,可
null
。(因为只有一个孩子,占整个视口的
constraints
和
index
参数被忽略。)
addImpl
方法重写,继承类
Container
child
-视口的轻
child
constraints
-
constraints
得到尊重
index
-指数
setView(java.awt.Component)
public void remove(Component child)
Viewport
s一个轻量级的孩子。
remove
方法重写,继承类
Container
child
-要移除的组件
setView(java.awt.Component)
public void addNotify()
JComponent
KeyboardAction
事件监听器。这种方法被内部调用的工具包,不应该直接调用程序。
public void scrollRectToVisible(Rectangle contentRect)
Rectangle
变得可见。
本文试图在滚动,如果视图目前没有有效论证观点isValid
返回false。为了避免过度的验证时控制层次是创造这将不会验证如果一个人的祖先没有同伴,或是没有验证根祖先或祖先的不是Window
或Applet
。
值得注意的是,这种方法不会滚动的有效在视口;例如,如果contentRect
大于视口,滚动将局限于视口的边界。
scrollRectToVisible
方法重写,继承类
JComponent
contentRect
-
Rectangle
显示
JComponent.isValidateRoot()
,
Component.isValid()
,
Component.getPeer()
public final void setBorder(Border border)
null
边界,或非零的插图,不支持,以防止该组件的几何变得足够复杂的抑制子。要创建一个有边界
JViewport
,将它添加到一个
JPanel
有边界。
注意:如果border
是non-null
,该方法将抛出一个异常作为边界不支持在一个JViewPort
。
setBorder
方法重写,继承类
JComponent
border
-
Border
设置
IllegalArgumentException
这未实现的方法
Border
,
CompoundBorder
public final Insets getInsets()
JViewport
。
getInsets
方法重写,继承类
JComponent
Rectangle
零维零的起源
setBorder(javax.swing.border.Border)
public final Insets getInsets(Insets insets)
Insets
JViewport
s对象嵌入值。通过在
Insets
对象将被初始化,所有现有的价值观在这个对象被覆盖。
getInsets
方法重写,继承类
JComponent
insets
-
Insets
对象可重复使用
getInsets()
public boolean isOptimizedDrawingEnabled()
JViewport
重写此方法的默认实现(在
JComponent
)返回false。这保证了绘制机械将调用
Viewport
的
paint
实施而不是消息的
JViewport
儿童直接。
isOptimizedDrawingEnabled
方法重写,继承类
JComponent
protected boolean isPaintingOrigin()
BACKINGSTORE_SCROLL_MODE
导致绘画起源于
JViewport
返回true,或其祖先之一。否则返回
false
。
isPaintingOrigin
方法重写,继承类
JComponent
BACKINGSTORE_SCROLL_MODE
。
JComponent.isPaintingOrigin()
public void paint(Graphics g)
backingStore
启用,要么画图像通过存储备份或油漆只是最近暴露的部分,使用后备存储“blit”剩下的。
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.)
public void reshape(int x, int y, int w, int h)
StateChanged
事件。
reshape
方法重写,继承类
JComponent
x
左边缘的起源
y
-原点的顶部边缘
w
宽度的像素
h
高像素
JComponent.reshape(int, int, int, int)
public void setScrollMode(int mode)
mode
-以下值之一:
BLIT_SCROLL_MODE
,
BACKINGSTORE_SCROLL_MODE
,
SIMPLE_SCROLL_MODE
public int getScrollMode()
scrollMode
财产
setScrollMode(int)
@Deprecated public boolean isBackingStoreEnabled()
getScrollMode()
。
true
如果这个视口是保持其内容的屏幕图像。
true
如果
scrollMode
是
BACKINGSTORE_SCROLL_MODE
@Deprecated public void setBackingStoreEnabled(boolean enabled)
setScrollMode()
。
viewPosition
成本。而不是重画整个视口我们使用
Graphics.copyArea
影响一些滚动。
enabled
-如果是真的,保持一个画外的后备存储
public Component getView()
JViewport
的一个孩子或
null
。
null
如果不存在
setView(java.awt.Component)
public void setView(Component view)
JViewport
是一个轻量级的孩子(
view
),可
null
。
view
-视图的新的轻量级的孩子
getView()
public Dimension getViewSize()
Dimension
指定视图的尺寸
public void setViewSize(Dimension newSize)
newSize
-
Dimension
指定视图的新尺寸
public Point getViewPosition()
Point
对象给左上角的坐标
public void setViewPosition(Point p)
p
-
Point
对象给左上角的坐标
public Rectangle getViewRect()
getViewPosition
和大小
getExtentSize
。这是视图的可见部分,视图坐标。
Rectangle
给可见部分的视图使用视图坐标。
protected boolean computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
oldLoc
在左上角我们滚动
newLoc
参数。参数修改返回的blit操作所需的值。
dx
-水平三角洲
dy
-垂直三角
blitFrom
-我们从
Point
blit
blitTo
-
Point
blit到我们
blitSize
-该地区的
Dimension
blit
blitPaint
的blit
public Dimension getExtentSize()
Dimension
对象给视图的尺寸
public Dimension toViewCoordinates(Dimension size)
size
-使用像素
Dimension
物体坐标
Dimension
对象转换为视图坐标
public Point toViewCoordinates(Point p)
p
-使用像素
Point
物体坐标
Point
对象转换为视图坐标
public void setExtentSize(Dimension newExtent)
newExtent
-
Dimension
指定视图的尺寸
protected JViewport.ViewListener createViewListener()
ViewListener
protected LayoutManager createLayoutManager()
null
)在构造函数。返回
LayoutManager
安装在
JViewport
。
LayoutManager
public void addChangeListener(ChangeListener l)
ChangeListener
每次视图的大小,位置,或视口的大小发生了变化。
public void removeChangeListener(ChangeListener l)
ChangeListener
大小,位置,或视口的大小发生了变化。
l
-
ChangeListener
删除
addChangeListener(javax.swing.event.ChangeListener)
public ChangeListener[] getChangeListeners()
ChangeListener
s数组添加到这个jviewport与addchangelistener()。
ChangeListener
s说如果没有听众已添加一个空数组
protected void fireStateChanged()
ChangeListeners
当视图的大小,位置,或改变视口的大小。
public void repaint(long tm, int x, int y, int w, int h)
RepaintManager
进行。
repaint
方法重写,继承类
JComponent
tm
-毫秒最大时间更新前
x
-
x
坐标(像素从左)
y
-
y
坐标(像素从顶部往下)
w
-宽度
h
-高度
Component.update(java.awt.Graphics)
protected String paramString()
JViewport
字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能会在实现过程中有所不同。返回的字符串是空的但可能不
null
。
paramString
方法重写,继承类
JComponent
JViewport
字符串表示形式
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
windowBlit
财产。(这
putClientProperty
财产最终)。
firePropertyChange
方法重写,继承类
Component
propertyName
-一个包含属性名称
oldValue
-属性的旧值
newValue
-新的属性值
public AccessibleContext getAccessibleContext()
getAccessibleContext
接口
Accessible
getAccessibleContext
方法重写,继承类
Component
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.