- 所有已实现的接口:
SwingConstants
- 自从:
- 1.2
-
字段摘要
在接口 javax.swing.SwingConstants 中声明的字段
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST -
方法总结
修饰符和类型方法描述static Rectangle将指定组件的内部绘制区域的位置和大小存储在r中并返回r。static Rectangle[]computeDifference(Rectangle rectA, Rectangle rectB) 方便地返回一个矩形数组,表示rectA中不与rectB重叠的区域。static RectanglecomputeIntersection(int x, int y, int width, int height, Rectangle dest) 无需分配新矩形即可方便地计算两个矩形的交集。static intcomputeStringWidth(FontMetrics fm, String str) 使用具有指定“度量”(大小)的字体计算字符串的宽度。static RectanglecomputeUnion(int x, int y, int width, int height, Rectangle dest) 在不分配新矩形的情况下计算两个矩形并集的便捷方法。static MouseEventconvertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) 返回类似于sourceEvent的 MouseEvent,只是其 x 和 y 成员已转换为destination的坐标系。static PointconvertPoint(Component source, int x, int y, Component destination) 将source坐标系中的点(x,y)转换为destination坐标系。static PointconvertPoint(Component source, Point aPoint, Component destination) 将source坐标系中的aPoint转换为destination坐标系。static void将点从屏幕坐标转换为组件的坐标系static void将点从组件的坐标系转换为屏幕坐标。static RectangleconvertRectangle(Component source, Rectangle aRectangle, Component destination) 将source坐标系中的矩形aRectangle转换为destination坐标系。static Component已弃用。static AccessiblegetAccessibleAt(Component c, Point p) 返回包含在局部坐标Point的Accessible子节点(如果存在)。static AccessiblegetAccessibleChild(Component c, int i) 返回对象的第 n 个可访问子对象。static int返回对象中可访问的子对象的数量。static int获取此对象在其可访问父对象中的索引。static AccessibleStateSet获取此对象的状态。static ContainergetAncestorNamed(String name, Component comp) 在组件层次结构中搜索comp上方的便捷方法,并返回它找到的name的第一个对象。static ContainergetAncestorOfClass(Class<?> c, Component comp) 在组件层次结构中搜索comp上方的便捷方法,并返回它找到的类c的第一个对象。static ComponentgetDeepestComponentAt(Component parent, int x, int y) 返回包含位置x、y的parent的最深可见后代组件。static RectanglegetLocalBounds(Component aComponent) 返回组件aComponent的矩形 (0,0,bounds.width,bounds.height)static Component返回当前组件树的根组件。static JRootPane如果 c 是 JRootPane 后代,则返回其 JRootPane 祖先。static ActionMapgetUIActionMap(JComponent component) 返回组件component中 UI 提供的 ActionMap。static InputMapgetUIInputMap(JComponent component, int condition) 返回 UI 为组件component中的条件condition提供的 InputMap。static ContainergetUnwrappedParent(Component component) 返回component的第一个祖先,它不是JLayer的实例。static ComponentgetUnwrappedView(JViewport viewport) 返回第一个JViewport的后代,它不是JLayer的实例。static Window返回c的第一个Window祖先,如果c不包含在Window中,则返回null。static voidinvokeAndWait(Runnable doRun) 导致doRun.run()在 AWT 事件调度线程上同步执行。static voidinvokeLater(Runnable doRun) 成因doRun.run()在 AWT 事件调度线程上异步执行。static boolean如果组件a是组件b的后代,则返回truestatic boolean如果当前线程是 AWT 事件调度线程,则返回 true。static booleanisLeftMouseButton(MouseEvent anEvent) 如果鼠标事件指定鼠标左键,则返回 true。static booleanisMiddleMouseButton(MouseEvent anEvent) 如果鼠标事件指定鼠标中键,则返回 true。static final boolean如果a包含b,则返回truestatic booleanisRightMouseButton(MouseEvent anEvent) 如果鼠标事件指定鼠标右键,则返回 true。static StringlayoutCompoundLabel(FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) 计算并返回图标原点的位置、文本基线的原点位置以及复合标签字符串的可能裁剪版本。static StringlayoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) 计算并返回图标原点的位置、文本基线的原点位置以及复合标签字符串的可能裁剪版本。static booleannotifyAction(Action action, KeyStroke ks, KeyEvent event, Object sender, int modifiers) 如果action是非null并接受发送者对象,则在action上调用actionPerformed。static voidpaintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) 将组件绘制到指定的Graphics。static voidpaintComponent(Graphics g, Component c, Container p, Rectangle r) 将组件绘制到指定的Graphics。static booleanprocessKeyBindings(KeyEvent event) 处理与event关联的Component的键绑定。static voidreplaceUIActionMap(JComponent component, ActionMap uiActionMap) 将component的 UI ActionMap 更改为uiActionMap的便捷方法。static voidreplaceUIInputMap(JComponent component, int type, InputMap uiInputMap) 将component的 UI InputMap 更改为uiInputMap的便捷方法。static void一个简单的外观变化:要求树中的每个节点updateUI()——也就是说,用当前的外观初始化它的 UI 属性。static Window返回c的第一个Window祖先,如果c不包含在Window中,则返回null。
-
方法详情
-
isRectangleContainingRectangle
如果a包含b,则返回true- 参数:
a- 第一个矩形b- 第二个矩形- 返回:
true如果a包含b
-
getLocalBounds
返回组件aComponent的矩形 (0,0,bounds.width,bounds.height)- 参数:
aComponent- 一个组件- 返回:
-
组件
aComponent的局部边界
-
getWindowAncestor
返回c的第一个Window祖先,如果c不包含在Window中,则返回null。- 参数:
c-Component得到Window的祖先。- 返回:
c的第一个Window祖先,或者null如果c不包含在Window中。- 自从:
- 1.3
-
convertPoint
将source坐标系中的aPoint转换为destination坐标系。如果source是null,则假定aPoint在destination的根组件坐标系中。如果destination为null,则aPoint将转换为source的根组件坐标系。如果source和destination都是null,则返回aPoint而不进行任何转换。- 参数:
source- 源组件aPoint- 重点destination- 目标组件- 返回:
- 转换后的坐标
-
convertPoint
将source坐标系中的点(x,y)转换为destination坐标系。如果source是null,则假定(x,y)在destination的根组件坐标系中。如果destination为null,则(x,y)将转换为source的根组件坐标系。如果source和destination都是null,则返回(x,y)而不进行任何转换。- 参数:
source- 源组件x- 点的 x 坐标y- 点的 y 坐标destination- 目标组件- 返回:
- 转换后的坐标
-
convertRectangle
public static Rectangle convertRectangle(Component source, Rectangle aRectangle, Component destination) 将source坐标系中的矩形aRectangle转换为destination坐标系。如果source是null,则假定aRectangle在destination的根组件坐标系中。如果destination为null,则aRectangle将转换为source的根组件坐标系。如果source和destination都是null,则返回aRectangle而不进行任何转换。- 参数:
source- 源组件aRectangle- 一个矩形destination- 目标组件- 返回:
- 转换后的矩形
-
getAncestorOfClass
在组件层次结构中搜索comp上方的便捷方法,并返回它找到的类c的第一个对象。如果找不到类c,可以返回null。- 参数:
c- 组件的类comp- 组件- 返回:
comp的祖先,如果找不到c,则为null。
-
getAncestorNamed
在组件层次结构中搜索comp上方的便捷方法,并返回它找到的name的第一个对象。如果找不到name,可以返回null。- 参数:
name- 组件名称comp- 组件- 返回:
comp的祖先,如果找不到name,则为null。
-
getDeepestComponentAt
返回包含位置x、y的parent的最深可见后代组件。如果parent不包含指定位置,则返回null。如果parent不是容器,或者parent的可见后代均不包含指定位置,则返回parent。- 参数:
parent- 开始搜索的根组件x- x 目标位置y- y 目标位置- 返回:
- 最深的组件
-
convertMouseEvent
public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) 返回类似于sourceEvent的 MouseEvent,只是其 x 和 y 成员已转换为destination的坐标系。如果source是null,则假定sourceEventx 和 y 成员位于destination的根组件坐标系中。如果destination是null,则返回的 MouseEvent 将在source的坐标系中。sourceEvent不会更改。返回一个新事件。如果目标不是null,则返回事件的source字段将设置为destination使用 translateMouseEvent() 方法将鼠标事件从一个组件转换为另一个组件,而不更改源。- 参数:
source- 源组件sourceEvent- 源鼠标事件destination- 目标组件- 返回:
- 新鼠标事件
-
convertPointToScreen
将点从组件的坐标系转换为屏幕坐标。- 参数:
p- 一个 Point 对象(转换为新坐标系)c- 一个组件对象
-
convertPointFromScreen
将点从屏幕坐标转换为组件的坐标系- 参数:
p- 一个 Point 对象(转换为新坐标系)c- 一个组件对象
-
windowForComponent
返回c的第一个Window祖先,如果c不包含在Window中,则返回null。注意:此方法提供与
getWindowAncestor相同的功能。- 参数:
c-Component得到Window的祖先。- 返回:
c的第一个Window祖先,或者null如果c不包含在Window中。
-
isDescendingFrom
如果组件a是组件b的后代,则返回true- 参数:
a- 第一个组件b- 第二个组件- 返回:
true如果组件a来自组件b
-
computeIntersection
无需分配新矩形即可方便地计算两个矩形的交集。如果两个矩形不相交,则返回的矩形从 (0,0) 开始,宽度和高度为零。- 参数:
x- 第一个矩形左上角的 X 坐标y- 第一个矩形左上角的 Y 坐标width- 第一个矩形的宽度height- 第一个矩形的高度dest- 第二个矩形- 返回:
dest,修改为指定交点
-
computeUnion
在不分配新矩形的情况下计算两个矩形并集的便捷方法。- 参数:
x- 第一个矩形的 x 坐标y- 第一个矩形的 y 坐标width- 第一个矩形的宽度height- 第一个矩形的高度dest- 第二个矩形的坐标;两个矩形的并集在此矩形中返回- 返回:
destRectangle
-
computeDifference
方便地返回一个矩形数组,表示rectA中不与rectB重叠的区域。如果两个 Rect 不重叠,则返回一个空数组- 参数:
rectA- 第一个矩形rectB- 第二个矩形- 返回:
-
代表
rectA内不与rectB重叠的区域的矩形数组。
-
isLeftMouseButton
如果鼠标事件指定鼠标左键,则返回 true。- 参数:
anEvent- MouseEvent 对象- 返回:
- 如果鼠标左键处于活动状态则为真
-
isMiddleMouseButton
如果鼠标事件指定鼠标中键,则返回 true。- 参数:
anEvent- MouseEvent 对象- 返回:
- 如果鼠标中键处于活动状态则为真
-
isRightMouseButton
如果鼠标事件指定鼠标右键,则返回 true。- 参数:
anEvent- MouseEvent 对象- 返回:
- 如果鼠标右键处于活动状态则为真
-
computeStringWidth
使用具有指定“度量”(大小)的字体计算字符串的宽度。- 参数:
fm- 用于计算的 FontMetrics 对象str- 要计算的字符串- 返回:
- 一个包含字符串宽度的 int
-
layoutCompoundLabel
public static String layoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) 计算并返回图标原点的位置、文本基线的原点位置以及复合标签字符串的可能裁剪版本。位置是相对于 viewR 矩形计算的。 JComponents 方向(LEADING/TRAILING)也将被考虑在内并相应地转换为 LEFT/RIGHT 值。- 参数:
c- 组件fm-FontMetrics的实例text- 正文icon- 图标verticalAlignment- 垂直对齐horizontalAlignment- 水平对齐verticalTextPosition- 垂直文本位置horizontalTextPosition- 水平文本位置viewR- 可用矩形iconR- 图标的矩形textR- 文本矩形textIconGap- 文本和图标之间的间隙- 返回:
- 复合标签字符串的可能被剪裁的版本
-
layoutCompoundLabel
public static String layoutCompoundLabel(FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) 计算并返回图标原点的位置、文本基线的原点位置以及复合标签字符串的可能裁剪版本。位置是相对于 viewR 矩形计算的。此 layoutCompoundLabel() 不知道如何处理 horizontalTextPosition(它们将默认为 RIGHT)和 horizontalAlignment(它们将默认为 CENTER)中的 LEADING/TRAILING 值。请改用其他版本的 layoutCompoundLabel()。- 参数:
fm-FontMetrics的实例text- 正文icon- 图标verticalAlignment- 垂直对齐horizontalAlignment- 水平对齐verticalTextPosition- 垂直文本位置horizontalTextPosition- 水平文本位置viewR- 可用矩形iconR- 图标的矩形textR- 文本矩形textIconGap- 文本和图标之间的间隙- 返回:
- 复合标签字符串的可能被剪裁的版本
-
paintComponent
将组件绘制到指定的Graphics。此方法主要用于渲染Components,它们不作为可见包含层次结构的一部分存在,但用于渲染。例如,如果您正在进行自己的渲染并想要渲染一些文本(甚至是 HTML),您可以使用JLabel的文本渲染支持并通过此方法直接绘制,而无需将标签添加到可见的包含层次结构。此方法使用
CellRendererPane来处理实际绘画,仅在使用一个组件进行渲染时才推荐使用。如果像JTable那样使用多个组件来处理渲染,请直接使用CellRendererPane。否则,如下所述,您最终可能会得到一个CellRendererPaneperComponent。如果
c的父级不是CellRendererPane,则会创建一个新的CellRendererPane,将c添加到其中,并将CellRendererPane添加到p。如果c的父级是CellRendererPane而CellRendererPane的父级不是p,则将其添加到p。该组件应该是
JComponent的后代,或者是另一种轻量级组件。轻量级组件是指其“轻量级”属性(由ComponentisLightweight方法返回)为真的组件。如果组件不是轻量级的,就会发生坏事:崩溃、异常、绘画问题……- 参数:
g- 要绘制的Graphics对象c-Component绘制p- 中间体Containerx- 指定绘制区域左侧的 int,以像素为单位,从图形上下文的左边缘开始测量y- 一个 int,指定要绘制的区域的顶部,以从图形上下文的顶部边缘向下测量的像素为单位w- 指定绘制区域宽度的整数,以像素为单位h- 指定绘制区域高度的整数,以像素为单位- 参见:
-
paintComponent
将组件绘制到指定的Graphics。这是paintComponent(Graphics,Component,Container,int,int,int,int)的覆盖方法。请参阅它以获取更多信息。- 参数:
g- 要绘制的Graphics对象c-Component绘制p- 中间体Containerr- 要绘制的Rectangle- 参见:
-
updateComponentTreeUI
一个简单的外观变化:要求树中的每个节点updateUI()——也就是说,用当前的外观初始化它的 UI 属性。- 参数:
c- 组件
-
invokeLater
成因doRun.run()在 AWT 事件调度线程上异步执行。这将在处理完所有未决 AWT 事件后发生。当应用程序线程需要更新 GUI 时,应使用此方法。在下面的示例中,invokeLater调用将Runnable对象doHelloWorld在事件调度线程上排队,然后打印一条消息。Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; SwingUtilities.invokeLater(doHelloWorld); System.out.println("This might well be displayed before the other message.");如果从事件调度线程调用 invokeLater——例如,从 JButton 的 ActionListener——doRun.run()仍将被推迟,直到处理完所有未决事件。请注意,如果doRun.run()抛出一个未捕获的异常,事件调度线程将展开(不是当前线程)。可以在 Swing 中的并发 中找到此方法的其他文档和示例。
从 1.3 开始,此方法只是
java.awt.EventQueue.invokeLater()的掩护。与 Swing 的其余部分不同,可以从任何线程调用此方法。
- 参数:
doRun-Runnable的实例- 参见:
-
invokeAndWait
public static void invokeAndWait(Runnable doRun) throws InterruptedException , InvocationTargetException 导致doRun.run()在 AWT 事件调度线程上同步执行。此调用会阻塞,直到处理完所有未决的 AWT 事件并且(然后)doRun.run()返回。当应用程序线程需要更新 GUI 时,应使用此方法。不应从事件调度线程调用它。下面是一个创建新应用程序线程的示例,该线程使用invokeAndWait从事件调度线程打印字符串,然后在完成后从应用程序线程打印字符串。final Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; Thread appThread = new Thread() { public void run() { try { SwingUtilities.invokeAndWait(doHelloWorld); } catch (Exception e) { e.printStackTrace(); } System.out.println("Finished on " + Thread.currentThread()); } }; appThread.start();请注意,如果Runnable.run方法抛出一个未捕获的异常(在事件调度线程上),它会被捕获并重新抛出,作为InvocationTargetException,在调用者的线程上。可以在 Swing 中的并发 中找到此方法的其他文档和示例。
从 1.3 开始,此方法只是
java.awt.EventQueue.invokeAndWait()的掩护。- 参数:
doRun-Runnable的实例- 抛出:
InterruptedException- 如果我们在等待事件分派线程完成执行时被打断doRun.run()InvocationTargetException- 如果在运行时抛出异常doRun- 参见:
-
isEventDispatchThread
public static boolean isEventDispatchThread()如果当前线程是 AWT 事件调度线程,则返回 true。从 1.3 开始,此方法只是
java.awt.EventQueue.isDispatchThread()的掩护。- 返回:
- 如果当前线程是 AWT 事件调度线程,则为 true
-
getAccessibleIndexInParent
获取此对象在其可访问父对象中的索引。注意:从 Java 2 平台 v1.3 开始,建议开发人员调用 Component.AccessibleAWTComponent.getAccessibleIndexInParent() 而不是使用此方法。
- 参数:
c- 组件- 返回:
- -1 此对象没有可访问的父对象。否则,子项在其可访问父项中的索引。
-
getAccessibleAt
返回包含在局部坐标Point的Accessible子节点(如果存在)。否则返回null。- 参数:
c- 组件p- 本地坐标- 返回:
-
指定位置的
Accessible(如果存在);否则null
-
getAccessibleStateSet
获取此对象的状态。注意:从 Java 2 平台 v1.3 开始,建议开发人员调用 Component.AccessibleAWTComponent.getAccessibleIndexInParent() 而不是使用此方法。
- 参数:
c- 组件- 返回:
- 包含对象当前状态集的 AccessibleStateSet 实例
- 参见:
-
getAccessibleChildrenCount
返回对象中可访问的子对象的数量。如果此对象的所有子对象都实现了 Accessible,则此方法应返回此对象的子对象的数量。注意:从 Java 2 平台 v1.3 开始,建议开发人员调用 Component.AccessibleAWTComponent.getAccessibleIndexInParent() 而不是使用此方法。
- 参数:
c- 组件- 返回:
- 对象中可访问的子对象的数量。
-
getAccessibleChild
返回对象的第 n 个可访问子对象。注意:从 Java 2 平台 v1.3 开始,建议开发人员调用 Component.AccessibleAWTComponent.getAccessibleIndexInParent() 而不是使用此方法。
- 参数:
c- 组件i- 从零开始的子索引- 返回:
- 对象的第 n 个可访问子对象
-
findFocusOwner
已弃用。从 1.4 开始,由KeyboardFocusManager.getFocusOwner()取代。返回作为焦点所有者的指定Component的子节点Component(如果有)。- 参数:
c-Component层次结构的根,用于搜索焦点所有者- 返回:
-
焦点所有者,或
null如果没有焦点所有者,或者如果焦点所有者不是comp或comp的后代 - 参见:
-
getRootPane
如果 c 是 JRootPane 后代,则返回其 JRootPane 祖先。如果 c 是 RootPaneContainer,则返回其 JRootPane。- 参数:
c- 组件- 返回:
-
组件 c 或
null的 JRootPane。
-
getRoot
返回当前组件树的根组件。- 参数:
c- 组件- 返回:
- c 的第一个祖先是 Window 或最后一个 Applet 祖先
-
processKeyBindings
处理与event关联的Component的键绑定。此方法仅在event.getComponent()不是从JComponent继承,或者您没有从JComponent子类中调用super.processKeyEvent时才有用。JComponent自动处理其processKeyEvent方法中的绑定,因此您很少需要直接调用此方法。- 参数:
event- KeyEvent 用于识别要处理的绑定,以及哪个组件具有焦点。- 返回:
- 如果已找到并处理绑定,则为真
- 自从:
- 1.4
-
notifyAction
public static boolean notifyAction(Action action, KeyStroke ks, KeyEvent event, Object sender, int modifiers) 如果action是非null并接受发送者对象,则在action上调用actionPerformed。 ActionEvent 的命令由以下因素决定:- 如果操作是通过
registerKeyboardAction注册的,则传入命令字符串(如果传入null,则将使用null)。 - 名称为 Action.ACTION_COMMAND_KEY 的操作值,除非
null。 - KeyEvent 的字符串值,除非
getKeyChar返回 KeyEvent.CHAR_UNDEFINED..
action是非null并且在其上调用 actionPerformed,这将返回 true。- 参数:
action- 一个动作ks——一击event- 关键事件sender- 发件人modifiers- 动作修饰符- 返回:
true如果action是非null并且对其调用 actionPerformed。- 自从:
- 1.3
- 参见:
- 如果操作是通过
-
replaceUIInputMap
将component的 UI InputMap 更改为uiInputMap的便捷方法。如果uiInputMap是null,这将删除任何以前安装的 UI InputMap。- 参数:
component- 一个组件type- 一种类型uiInputMap- 一个InputMap- 自从:
- 1.3
-
replaceUIActionMap
将component的 UI ActionMap 更改为uiActionMap的便捷方法。如果uiActionMap是null,这将删除任何以前安装的 UI ActionMap。- 参数:
component- 一个组件uiActionMap- 一个ActionMap- 自从:
- 1.3
-
getUIInputMap
返回 UI 为组件component中的条件condition提供的 InputMap。如果 UI 没有安装指定类型的 InputMap,这将返回
null。- 参数:
component- 一个组件condition- 一个条件- 返回:
-
组件中 UI 为
condition提供的ActionMap,如果 UI 未安装指定类型的 InputMap,则为null。 - 自从:
- 1.3
-
getUIActionMap
返回组件component中 UI 提供的 ActionMap。如果 UI 没有安装 ActionMap,这将返回
null。- 参数:
component- 一个组件- 返回:
-
组件中 UI 提供的
ActionMap,如果 UI 未安装 ActionMap,则为null。 - 自从:
- 1.3
-
calculateInnerArea
将指定组件的内部绘制区域的位置和大小存储在r中并返回r。位置和大小指定组件的边界,调整后不包括边界区域(insets)。此方法对于实现绘画代码的类很有用。- 参数:
c- 有问题的 JComponent;如果null,此方法返回nullr- 要修改的 Rectangle 实例;可能是null- 返回:
null如果组件是null;否则,返回传入的矩形(如果非null)或指定位置和大小信息的新矩形- 自从:
- 1.4
-
getUnwrappedParent
返回component的第一个祖先,它不是JLayer的实例。- 参数:
component-Component获取第一个祖先,它不是JLayer实例。- 返回:
component的第一个祖先不是JLayer的实例。如果找不到这样的祖先,则返回null。- 抛出:
NullPointerException- 如果component是null- 自从:
- 1.7
- 参见:
-
getUnwrappedView
返回第一个JViewport的后代,它不是JLayer的实例。如果找不到这样的后代,则返回null。如果viewport的视图组件不是JLayer,则此方法等效于JViewport.getView()否则JLayer.getView()将在所有降序JLayer上递归调用。- 参数:
viewport-JViewport获取第一个后代,它不是JLayer实例。- 返回:
-
第一个
JViewport的后代不是JLayer的实例。如果找不到这样的后代,则返回null。 - 抛出:
NullPointerException- 如果viewport是null- 自从:
- 1.7
- 参见:
-
KeyboardFocusManager.getFocusOwner()取代。