- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JLayer<V>
-
- 参数类型
-
V
-JLayer
的视图组件的类型
- All Implemented Interfaces:
-
ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
,Scrollable
public final class JLayer<V extends Component> extends JComponent implements Scrollable, PropertyChangeListener, Accessible
JLayer
是用于Swing组件的通用装饰器,可以实现各种先进的绘画效果,并接收在其边框内生成的所有AWTEvent
的通知。JLayer
将绘画和输入事件的处理委托给一个执行实际装饰的LayerUI
对象。在
LayerUI
实现的自定义绘画和JLayer本身及其所有子组件的事件通知工作。 该组合使您可以通过添加新的高级功能来丰富现有组件,例如临时锁定层次结构,复合组件的数据提示,增强的鼠标滚动等等。JLayer
是一个很好的解决方案,如果您只需要对复合组件进行自定义绘画或从其子组件捕获输入事件。import javax.swing.*; import javax.swing.plaf.LayerUI; import java.awt.*; public class JLayerSample { private static JLayer<JComponent> createLayer() { // This custom layerUI will fill the layer with translucent green // and print out all mouseMotion events generated within its borders LayerUI<JComponent> layerUI = new LayerUI<JComponent>() { public void paint(Graphics g, JComponent c) { // paint the layer as is super.paint(g, c); // fill it with the translucent green g.setColor(new Color(0, 128, 0, 128)); g.fillRect(0, 0, c.getWidth(), c.getHeight()); } public void installUI(JComponent c) { super.installUI(c); // enable mouse motion events for the layer's subcomponents ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK); } public void uninstallUI(JComponent c) { super.uninstallUI(c); // reset the layer event mask ((JLayer) c).setLayerEventMask(0); } // overridden method which catches MouseMotion events public void eventDispatched(AWTEvent e, JLayer<? extends JComponent> l) { System.out.println("AWTEvent detected: " + e); } }; // create a component to be decorated with the layer JPanel panel = new JPanel(); panel.add(new JButton("JButton")); // create the layer for the panel using our custom layerUI return new JLayer<JComponent>(panel, layerUI); } private static void createAndShowGUI() { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // work with the layer as with any other Swing component frame.add(createLayer()); frame.setSize(200, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(); } }); } }
注意:JLayer
不支持以下方法:-
Container.add(java.awt.Component)
-
Container.add(String, java.awt.Component)
-
Container.add(java.awt.Component, int)
-
Container.add(java.awt.Component, Object)
-
Container.add(java.awt.Component, Object, int)
UnsupportedOperationException
被抛出,添加一个组件到JLayer
使用setView(Component)
或setGlassPane(JPanel)
。- 从以下版本开始:
- 1.7
- 另请参见:
-
JLayer(Component)
,setView(Component)
,getView()
,LayerUI
,JLayer(Component, LayerUI)
,setUI(javax.swing.plaf.LayerUI)
,getUI()
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected void
addImpl(Component comp, Object constraints, int index)
JLayer
不支持此方法,并始终抛出UnsupportedOperationException
void
addNotify()
通知此组件它现在有一个父组件。JPanel
createGlassPane()
由构造函数调用方法创建一个默认值glassPane
。void
doLayout()
AccessibleContext
getAccessibleContext()
获取与此JLayer
关联的AccessibleContext。Border
getBorder()
将其功能委托给getView().getBorder()
方法,如果视图组件是javax.swing.JComponent
的实例,否则返回null
。JPanel
getGlassPane()
返回JLayer
的glassPane组件或null
。long
getLayerEventMask()
返回此JLayer
及其LayerUI
接收的事件掩码的位图。Dimension
getPreferredScrollableViewportSize()
返回视图组件的视口的首选大小。int
getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
返回滚动增量,这是显示逻辑行或列的组件所必需的,以便根据方向的值完全暴露一个行或列的块。boolean
getScrollableTracksViewportHeight()
返回false
以表示视口的高度不会确定图层的高度,除非图层的首选高度小于视口的高度。boolean
getScrollableTracksViewportWidth()
返回false
以表示视口的宽度不决定图层的宽度,除非图层的首选宽度小于视口的宽度。int
getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
返回滚动增量,这是显示逻辑行或列的组件所必需的,以便根据方向的值完全暴露一个新行或列。LayerUI<? super V>
getUI()
返回LayerUI
为这JLayer
。V
getView()
返回JLayer
的视图组件或null
。boolean
imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
将其功能委托给LayerUI.imageUpdate(java.awt.Image, int, int, int, int, int, JLayer)
方法,如果设置了LayerUI
。boolean
isOptimizedDrawingEnabled()
JLayer
覆盖此方法的默认实现(在JComponent
)以返回false
。protected boolean
isPaintingOrigin()
始终返回true
,使绘画始于JLayer
,或其祖先之一。void
paint(Graphics g)
代表所有绘画到LayerUI
对象。protected void
paintComponent(Graphics g)
这种方法是空的,因为所有的绘画都是由paint(Graphics)
和ComponentUI.update(Graphics, JComponent)
方法完成的void
paintImmediately(int x, int y, int w, int h)
void
propertyChange(PropertyChangeEvent evt)
当绑定属性更改时,此方法将被调用。void
remove(Component comp)
从此容器中删除指定的组件。void
removeAll()
从此容器中删除所有组件。void
removeNotify()
通知此组件它不再具有父组件。void
setBorder(Border border)
将其功能委托给getView().setBorder(Border)
方法,如果视图组件是javax.swing.JComponent
的实例,否则此方法是无操作的。void
setGlassPane(JPanel glassPane)
设置JLayer
的glassPane组件,可以是null
。void
setLayerEventMask(long layerEventMask)
启用来自JLayer的事件 及其指定的事件掩码参数定义的 所有后代将被传递到LayerUI.eventDispatched(AWTEvent, JLayer)
方法。void
setLayout(LayoutManager mgr)
设置此容器的布局管理器。void
setUI(LayerUI<? super V> ui)
设置LayerUI
,它将执行绘画和接收JLayer
输入事件。void
setView(V view)
设置JLayer
的视图组件,可以是null
。void
updateUI()
-
Methods inherited from class java.awt.Component
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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, 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
-
-
-
-
构造方法详细信息
-
JLayer
public JLayer()
使用null
视图组件创建一个新的JLayer
对象,默认为LayerUI
。
-
JLayer
public JLayer(V view)
创建一个新的JLayer
对象,默认为LayerUI
。- 参数
-
view
- 由JLayer
装饰的组件 - 另请参见:
-
setUI(javax.swing.plaf.LayerUI<? super V>)
-
-
方法详细信息
-
getView
public V getView()
返回JLayer
的视图组件或null
。
这是一个绑定属性。- 结果
-
JLayer
的视图组件或null
如果不存在) - 另请参见:
-
setView(Component)
-
setView
public void setView(V view)
设置JLayer
的视图组件,可以是null
。
这是一个绑定属性。- 参数
-
view
- 此JLayer
的视图组件 - 另请参见:
-
getView()
-
setUI
public void setUI(LayerUI<? super V> ui)
设置LayerUI
,它将执行绘画和接收JLayer
输入事件。- 参数
-
ui
- 这个JLayer的JLayer
-
getUI
public LayerUI<? super V> getUI()
返回JLayer的JLayer
。- 重写:
-
getUI
在JComponent
- 结果
-
该
LayerUI
为这JLayer
-
getGlassPane
public JPanel getGlassPane()
返回JLayer
的glassPane组件或null
。
这是一个绑定属性。- 结果
-
JLayer
的glassPane组件或null
如果不存在) - 另请参见:
-
setGlassPane(JPanel)
-
setGlassPane
public void setGlassPane(JPanel glassPane)
设置JLayer
的glassPane组件,可以是null
。
这是一个绑定属性。- 参数
-
glassPane
-如此的glassPane组件JLayer
- 另请参见:
-
getGlassPane()
-
createGlassPane
public JPanel createGlassPane()
由构造函数调用方法创建一个默认值glassPane
。 默认情况下,此方法创建一个新的JPanel,其可见性设置为true和opacity设置为false。- 结果
-
默认为
glassPane
-
setLayout
public void setLayout(LayoutManager mgr)
设置此容器的布局管理器。 该方法被覆盖以防止布局管理器被设置。注意:如果
mgr
为非null
,则此方法将抛出异常,因为JLayer
不支持布局管理器。- 重写:
-
setLayout
在Container
- 参数
-
mgr
- 指定的布局管理器 - 异常
-
IllegalArgumentException
- 不支持此方法 - 另请参见:
-
Container.doLayout()
,Container.getLayout()
,Container.invalidate()
-
setBorder
public void setBorder(Border border)
将其功能委托给getView().setBorder(Border)
方法,如果视图组件是javax.swing.JComponent
的实例,否则此方法是无操作的。- 重写:
-
setBorder
在JComponent
- 参数
-
border
- 要为view
组件呈现的view
- 另请参见:
-
getView()
,JComponent.setBorder(Border)
-
getBorder
public Border getBorder()
将其功能委托给getView().getBorder()
方法,如果视图组件是javax.swing.JComponent
的实例,否则返回null
。- 重写:
-
getBorder
中的JComponent
- 结果
-
边框对象为
view
组件 - 另请参见:
-
getView()
,setBorder(javax.swing.border.Border)
,JComponent.getBorder()
-
addImpl
protected void addImpl(Component comp, Object constraints, int index)
JLayer
不支持此方法,并始终抛出UnsupportedOperationException
- 重写:
-
addImpl
在Container
- 参数
-
comp
- 要添加的组件 -
constraints
- 表示此组件的布局约束的对象 -
index
- 容器列表中插入组件的位置,其中-1
表示附加到最后 - 异常
-
UnsupportedOperationException
- 不支持此方法 - 另请参见:
-
setView(Component)
,setGlassPane(JPanel)
-
remove
public void remove(Component comp)
从此容器中删除指定的组件。 此方法还通知布局管理器通过removeLayoutComponent
方法从该容器的布局中删除组件。该方法更改布局相关信息,因此使组件层次结构无效。 如果已经显示了容器,则此后必须验证层次结构以反映更改。
- 重写:
-
remove
在Container
- 参数
-
comp
- 要删除的组件 - 另请参见:
-
Container.add(java.awt.Component)
,Container.invalidate()
,Container.validate()
,Container.remove(int)
-
removeAll
public void removeAll()
从此容器中删除所有组件。 此方法还通知布局管理器通过removeLayoutComponent
方法从该容器的布局中删除组件。该方法更改布局相关信息,因此使组件层次结构无效。 如果已经显示了容器,则此后必须验证层次结构以反映更改。
-
isPaintingOrigin
protected boolean isPaintingOrigin()
始终返回true
,使绘画始于JLayer
,或其祖先之一。- 重写:
-
isPaintingOrigin
在JComponent
- 结果
- 真正
- 另请参见:
-
JComponent.isPaintingOrigin()
-
paintImmediately
public void paintImmediately(int x, int y, int w, int h)
- 重写:
-
paintImmediately
在JComponent
- 参数
-
x
- 要绘制的区域的x值 -
y
- 要绘制的区域的y值 -
w
- 要绘制的区域的宽度 -
h
- 要涂漆的区域的高度 - 另请参见:
-
JComponent.repaint(long, int, int, int, int)
,JComponent.isPaintingOrigin()
-
imageUpdate
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
将其功能委托给LayerUI.imageUpdate(java.awt.Image, int, int, int, int, int, JLayer)
方法,如果设置了LayerUI
。- Specified by:
-
imageUpdate
在接口ImageObserver
- 重写:
-
imageUpdate
在Component
- 参数
-
img
- 正在观察的图像 -
infoflags
- 有关详细信息,请参阅imageUpdate
-
x
- x坐标 -
y
- y坐标 -
w
- 宽度 -
h
- 高度 - 结果
-
false
如果infoflags指示图像被完全加载; 否则为true
。 - 另请参见:
-
ImageObserver
,Graphics.drawImage(Image, int, int, Color, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, int, int, Color, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, int, int, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
-
paintComponent
protected void paintComponent(Graphics g)
这种方法是空的,因为所有的绘画都是由paint(Graphics)
和ComponentUI.update(Graphics, JComponent)
方法完成的- 重写:
-
paintComponent
在JComponent
- 参数
-
g
- 要保护的Graphics
对象 - 另请参见:
-
JComponent.paint(java.awt.Graphics)
,ComponentUI
-
isOptimizedDrawingEnabled
public boolean isOptimizedDrawingEnabled()
JLayer
覆盖此方法的默认实现(在JComponent
)以返回false
。 这样可以确保绘图机器会调用JLayer
的paint
实现,而不是直接发送给JLayer
的孩子。- 重写:
-
isOptimizedDrawingEnabled
在JComponent
- 结果
- 假
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
当绑定属性更改时,此方法将被调用。- Specified by:
-
propertyChange
在接口PropertyChangeListener
- 参数
-
evt
- 描述事件源和已更改的属性的PropertyChangeEvent对象。
-
setLayerEventMask
public void setLayerEventMask(long layerEventMask)
启用来自JLayer的事件及其指定事件掩码参数定义的所有后代将被传递到LayerUI.eventDispatched(AWTEvent, JLayer)
方法。交付的事件是
LayerUI
被设置为JLayer
和JLayer
可显示。以下示例显示了如何在
LayerUI
实现中正确使用此方法:public void installUI(JComponent c) { super.installUI(c); JLayer l = (JLayer) c; // this LayerUI will receive only key and focus events l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK); } public void uninstallUI(JComponent c) { super.uninstallUI(c); JLayer l = (JLayer) c; // JLayer must be returned to its initial state l.setLayerEventMask(0); }
默认情况下,JLayer
接收事件,其事件掩码为0
。- 参数
-
layerEventMask
- 要接收的事件类型的位掩码 - 另请参见:
-
getLayerEventMask()
,LayerUI.eventDispatched(AWTEvent, JLayer)
,Component.isDisplayable()
-
getLayerEventMask
public long getLayerEventMask()
返回此JLayer
及其LayerUI
接收的事件掩码的位图。这意味着
LayerUI.eventDispatched(AWTEvent, JLayer)
方法将只接收与事件掩码相匹配的事件。默认情况下,
JLayer
收到任何事件。- 结果
-
该
JLayer
接收的事件类型的位掩码
-
updateUI
public void updateUI()
-
getPreferredScrollableViewportSize
public Dimension getPreferredScrollableViewportSize()
返回视图组件的视口的首选大小。如果此层的视图组件实现
Scrollable
,则此方法将其实现委托给视图组件。- Specified by:
-
getPreferredScrollableViewportSize
在接口Scrollable
- 结果
- 视图组件的视口的首选大小
- 另请参见:
-
Scrollable
-
getScrollableBlockIncrement
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
返回滚动增量,这是显示逻辑行或列的组件所必需的,以便根据方向的值完全暴露一个行或列的块。如果此层的视图组件实现
Scrollable
,则此方法将其实现委托给视图组件。- Specified by:
-
getScrollableBlockIncrement
在接口Scrollable
- 参数
-
visibleRect
- 在视口内可见的视图区域 -
orientation
- SwingConstants.VERTICAL或SwingConstants.HORIZONTAL。 -
direction
- 向上/向左滚动小于0,向下/向右大于零。 - 结果
- 在指定方向滚动的“块”增量
- 另请参见:
-
Scrollable
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
返回false
以表示视口的高度不会确定图层的高度,除非图层的首选高度小于视口的高度。如果此层的视图组件实现
Scrollable
,则此方法将其实现委托给视图组件。- Specified by:
-
getScrollableTracksViewportHeight
在接口Scrollable
- 结果
- 图层是否应跟踪视口的高度
- 另请参见:
-
Scrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
返回false
以表示视口的宽度不决定图层的宽度,除非图层的首选宽度小于视口的宽度。如果此层的视图组件实现
Scrollable
,则此方法将其实现委托给视图组件。- Specified by:
-
getScrollableTracksViewportWidth
在接口Scrollable
- 结果
- 图层是否应跟踪视口的宽度
- 另请参见:
-
Scrollable
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
返回滚动增量,这是显示逻辑行或列的组件所必需的,以便根据方向的值完全暴露一个新行或列。 理想情况下,组件应通过返回完全暴露项目所需的距离来处理部分暴露的行或列。滚动容器,如
JScrollPane
,每次用户请求单位滚动时都会使用此方法。如果此层的视图组件实现
Scrollable
,则此方法将其实现委托给视图组件。- Specified by:
-
getScrollableUnitIncrement
在接口Scrollable
- 参数
-
visibleRect
- 在视口内可见的视图区域 -
orientation
- SwingConstants.VERTICAL或SwingConstants.HORIZONTAL。 -
direction
- 向上/向左滚动小于零,向下/向右大于零。 - 结果
- 在指定方向滚动的“单位”增量。 该值应始终为正。
- 另请参见:
-
Scrollable
-
addNotify
public void addNotify()
通知此组件它现在有一个父组件。 调用此方法时,父组件链将使用KeyboardAction
事件侦听器进行设置。 该方法在内部被工具包调用,不应该被程序直接调用。
-
removeNotify
public void removeNotify()
通知此组件它不再具有父组件。 当调用此方法时,将删除在父组件链中设置的任何KeyboardAction
。 该方法在内部被工具包调用,不应该被程序直接调用。
-
doLayout
public void doLayout()
将其功能委托给LayerUI.doLayout(JLayer)
方法,如果设置了LayerUI
。
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
获取与此JLayer
相关联的AccessibleContext。- Specified by:
-
getAccessibleContext
在接口Accessible
- 重写:
-
getAccessibleContext
在Component
- 结果
-
与此
JLayer
相关的AccessibleContext。
-
-