- 所有已实现的接口:
-
SwingConstants
- 自1.2版本起:
- 1.2
-
Field Summary
Fields declared in interface 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic Rectangle在指定组件的内部绘制区域中存储位置和大小,并返回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) 将(x,y)点从source坐标系转换为destination坐标系。static PointconvertPoint(Component source, Point aPoint, Component destination) 将aPoint从source坐标系转换为destination坐标系。static void将点从屏幕坐标转换为组件的坐标系。static void将点从组件的坐标系转换为屏幕坐标。static RectangleconvertRectangle(Component source, Rectangle aRectangle, Component destination) 将aRectangle从source坐标系转换为destination坐标系。static Component已弃用。static AccessiblegetAccessibleAt(Component c, Point p) 返回包含在本地坐标Point处的Accessible子级(如果存在)。static AccessiblegetAccessibleChild(Component c, int i) 返回对象的第n个Accessible子级。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) 返回组件component中由UI提供的条件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的后代,则返回true。static boolean如果当前线程是AWT事件分派线程,则返回true。static booleanisLeftMouseButton(MouseEvent anEvent) 如果鼠标事件指定左鼠标按钮,则返回true。static booleanisMiddleMouseButton(MouseEvent anEvent) 如果鼠标事件指定中间鼠标按钮,则返回true。static final boolean如果a包含b,则返回true。static 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且接受发送方对象,则调用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。
-
Method Details
-
isRectangleContainingRectangle
如果a包含b,则返回true。- 参数:
-
a- 第一个矩形 -
b- 第二个矩形 - 返回:
-
如果
a包含b,则返回true
-
getLocalBounds
返回组件aComponent的矩形(0,0,bounds.width,bounds.height)。- 参数:
-
aComponent- 一个组件 - 返回:
-
组件
aComponent的本地边界
-
getWindowAncestor
返回c的第一个Window祖先,如果c不包含在Window中,则返回null。- 参数:
-
c- 要获取Window祖先的Component - 返回:
-
c的第一个Window祖先,如果c不包含在Window中,则返回null - 自1.3版本起:
- 1.3
-
convertPoint
将aPoint从source坐标系转换为destination坐标系。如果source为null,则假定aPoint在destination的根组件坐标系中。如果destination为null,则将aPoint转换为source的根组件坐标系。如果source和destination都为null,则返回aPoint而不进行任何转换。- 参数:
-
source- 源组件 -
aPoint- 点 -
destination- 目标组件 - 返回:
- 转换后的坐标
-
convertPoint
将(x,y)点从source坐标系转换为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) 将aRectangle从source坐标系转换为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,则假定sourceEvent的 x 和 y 成员是相对于destination的根组件坐标系。如果destination是null,返回的 MouseEvent 将在source的坐标系中。不会更改sourceEvent。将返回一个新事件。如果 destination 非null,返回事件的source字段将设置为destination,使用 translateMouseEvent() 方法将鼠标事件从一个组件转换到另一个组件而不更改源。- 参数:
-
source- 源组件 -
sourceEvent- 源鼠标事件 -
destination- 目标组件 - 返回:
- 新的鼠标事件
-
convertPointToScreen
将一个点从组件的坐标系转换为屏幕坐标。- 参数:
-
p- 一个 Point 对象(转换为新坐标系) -
c- 一个组件对象
-
convertPointFromScreen
将一个点从屏幕坐标转换为组件的坐标系- 参数:
-
p- 一个 Point 对象(转换为新坐标系) -
c- 一个组件对象
-
windowForComponent
返回c的第一个Window祖先,如果c不包含在Window中,则返回null。注意:此方法提供与
getWindowAncestor相同的功能。- 参数:
-
c- 要获取Window祖先的Component。 - 返回:
-
c的第一个Window祖先,如果c不包含在Window中,则返回null。
-
isDescendingFrom
如果组件a是组件b的后代,则返回true- 参数:
-
a- 第一个组件 -
b- 第二个组件 - 返回:
-
如果组件
a是组件b的后代,则返回true
-
computeIntersection
方便地计算两个矩形的交集,而不分配新矩形。如果两个矩形不相交,则返回的矩形从 (0,0) 开始,宽度和高度为零。- 参数:
-
x- 第一个矩形左上角点的 X 坐标 -
y- 第一个矩形左上角点的 Y 坐标 -
width- 第一个矩形的宽度 -
height- 第一个矩形的高度 -
dest- 第二个矩形 - 返回:
-
修改后指定交集的
dest
-
computeUnion
方便地计算两个矩形的并集,而不分配新矩形。- 参数:
-
x- 第一个矩形的 x 坐标 -
y- 第一个矩形的 y 坐标 -
width- 第一个矩形的宽度 -
height- 第一个矩形的高度 -
dest- 第二个矩形的坐标;两个矩形的并集将返回在此矩形中 - 返回:
-
dest的Rectangle
-
computeDifference
返回一个表示rectA中与rectB不重叠的区域的矩形数组。如果两个矩形不重叠,则返回一个空数组- 参数:
-
rectA- 第一个矩形 -
rectB- 第二个矩形 - 返回:
-
一个表示
rectA中与rectB不重叠的区域的矩形数组。
-
isLeftMouseButton
如果鼠标事件指定了左鼠标按钮,则返回 true。- 参数:
-
anEvent- 一个 MouseEvent 对象 - 返回:
- 如果左鼠标按钮处于活动状态,则返回 true
-
isMiddleMouseButton
如果鼠标事件指定了中间鼠标按钮,则返回 true。- 参数:
-
anEvent- 一个 MouseEvent 对象 - 返回:
- 如果中间鼠标按钮处于活动状态,则返回 true
-
isRightMouseButton
如果鼠标事件指定了右鼠标按钮,则返回 true。- 参数:
-
anEvent- 一个 MouseEvent 对象 - 返回:
- 如果右鼠标按钮处于活动状态,则返回 true
-
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 中的 LEADING/TRAILING 值(它们将默认为 RIGHT)以及 horizontalAlignment 中的 LEADING/TRAILING 值(它们将默认为 CENTER)。请改用 layoutCompoundLabel() 的其他版本。- 参数:
-
fm-FontMetrics的实例 -
text- 文本 -
icon- 图标 -
verticalAlignment- 垂直对齐 -
horizontalAlignment- 水平对齐 -
verticalTextPosition- 垂直文本位置 -
horizontalTextPosition- 水平文本位置 -
viewR- 可用矩形 -
iconR- 图标的矩形 -
textR- 文本的矩形 -
textIconGap- 文本和图标之间的间隙 - 返回:
- 可能被剪切的复合标签字符串的版本
-
paintComponent
将组件绘制到指定的Graphics。此方法主要用于渲染不作为可见包含层次结构的一部分存在的Component,但用于渲染。例如,如果您正在进行自己的渲染并希望渲染一些文本(甚至是 HTML),您可以利用JLabel的文本渲染支持,并通过此方法直接绘制,而无需将标签添加到可见包含层次结构中。此方法利用
CellRendererPane来处理实际绘制,并且仅在使用一个组件进行渲染时才建议使用。如果使用多个组件来处理渲染,如JTable所做的那样,请直接使用CellRendererPane。否则,如下所述,您可能会得到一个CellRendererPane每个Component。如果
c的父级不是CellRendererPane,则会创建一个新的CellRendererPane,将c添加到其中,并将CellRendererPane添加到p。如果c的父级是CellRendererPane,并且CellRendererPane的父级不是p,则将其添加到p。组件应该是
JComponent的后代,或者是另一种轻量级组件。轻量级组件是其“轻量级”属性(由Component的isLightweight方法返回)为 true 的组件。如果组件不是轻量级的,可能会发生糟糕的事情:崩溃、异常、绘制问题...- 参数:
-
g- 要绘制的Graphics对象 -
c- 要绘制的Component -
p- 中间的Container -
x- 以像素为单位指定要绘制的区域的左侧,从图形上下文的左边缘开始测量 -
y- 以像素为单位指定要绘制的区域的顶部,从图形上下文的顶边缘向下测量 -
w- 以像素为单位指定要绘制的区域的宽度 -
h- 以像素为单位指定要绘制的区域的高度 - 参见:
-
paintComponent
将组件绘制到指定的Graphics。这是paintComponent(Graphics,Component,Container,int,int,int,int)的封装方法。有关更多信息,请参考该方法。- 参数:
-
g- 要绘制的Graphics对象 -
c- 要绘制的Component -
p- 中间的Container -
r- 要绘制的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,则返回该位置的Accessible;否则返回null。
-
getAccessibleStateSet
获取此对象的状态。注意:从Java 2平台v1.3开始,建议开发人员调用Component.AccessibleAWTComponent.getAccessibleIndexInParent()而不是使用此方法。
- 参数:
-
c- 组件 - 返回:
- 包含对象当前状态集的AccessibleStateSet实例
- 参见:
-
getAccessibleChildrenCount
返回对象中可访问子项的数量。如果此对象的所有子项都实现了Accessible,则此方法应返回此对象的子项数。注意:从Java 2平台v1.3开始,建议开发人员调用Component.AccessibleAWTComponent.getAccessibleIndexInParent()而不是使用此方法。
- 参数:
-
c- 组件 - 返回:
- 对象中可访问子项的数量。
-
getAccessibleChild
返回对象的第n个Accessible子项。注意:从Java 2平台v1.3开始,建议开发人员调用Component.AccessibleAWTComponent.getAccessibleIndexInParent()而不是使用此方法。
- 参数:
-
c- 组件 -
i- 子项的从零开始的索引 - 返回:
- 对象的第n个Accessible子项
-
findFocusOwner
Deprecated.As of 1.4, replaced byKeyboardFocusManager.getFocusOwner().返回指定Component的焦点所有者子Component,如果有的话。- 参数:
-
c- 要搜索焦点所有者的Component层次结构的根 - 返回:
-
焦点所有者,如果没有焦点所有者,或者焦点所有者不是
comp,或者是comp的后代,则返回null - 参见:
-
getRootPane
如果c是JRootPane的后代,则返回其JRootPane祖先。如果c是RootPaneContainer,则返回其JRootPane。- 参数:
-
c- 组件 - 返回:
-
组件c的JRootPane或
null。
-
getRoot
返回当前组件树的根组件。- 参数:
-
c- 组件 - 返回:
- c的第一个Window祖先或最后一个Applet祖先
-
processKeyBindings
处理与event关联的Component的键绑定。如果event.getComponent()不是JComponent的子类,或者您没有在JComponent子类中调用super.processKeyEvent,则此方法才有用。JComponent会自动在其processKeyEvent方法中处理绑定,因此您很少需要直接调用此方法。- 参数:
-
event- 用于标识要处理的绑定以及具有焦点的组件的KeyEvent - 返回:
- 如果找到并处理了绑定,则返回true
- 自:
- 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的Action值,除非为
null。 - KeyEvent的字符串值,除非
getKeyChar返回KeyEvent.CHAR_UNDEFINED。
action非null并且在其上调用了actionPerformed,则返回true。- 参数:
-
action- 一个操作 -
ks- 一个键盘键 -
event- 一个键盘事件 -
sender- 一个发送方 -
modifiers- 操作修饰符 - 返回:
-
如果
action非null并且在其上调用了actionPerformed,则返回true - 自:
- 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为条件condition在组件component中提供的InputMap。如果UI尚未安装指定类型的InputMap,则会返回
null。- 参数:
-
component- 一个组件 -
condition- 一个条件 - 返回:
-
UI为组件中的
condition提供的ActionMap,如果UI尚未安装指定类型的InputMap,则返回null。 - 自版本:
- 1.3
-
getUIActionMap
返回UI在组件component中提供的ActionMap。如果UI尚未安装ActionMap,则会返回
null。- 参数:
-
component- 一个组件 - 返回:
-
UI在组件中提供的
ActionMap,如果UI尚未安装ActionMap,则返回null。 - 自版本:
- 1.3
-
calculateInnerArea
将指定组件的内部绘制区域的位置和大小存储在r中并返回r。位置和大小指定组件的边界,调整以不包括边框区域(插图)。此方法对于实现绘制代码的类非常有用。- 参数:
-
c- 要查询的JComponent;如果为null,此方法将返回null -
r- 要修改的Rectangle实例;可以为null - 返回:
-
如果组件为
null,则返回null;否则,返回传入的矩形(如果非null)或指定位置和大小信息的新矩形 - 自版本:
- 1.4
-
getUnwrappedParent
返回component的第一个祖先,该祖先不是JLayer的实例。- 参数:
-
component- 要获取其第一个非JLayer实例祖先的Component。 - 返回:
-
component的第一个非JLayer实例祖先。如果找不到这样的祖先,则返回null。 - 抛出:
-
NullPointerException- 如果component为null - 自版本:
- 1.7
- 参见:
-
getUnwrappedView
返回JViewport的第一个后代,该后代不是JLayer的实例。如果找不到这样的后代,则返回null。如果viewport的视图组件不是JLayer,则此方法等同于JViewport.getView(),否则将在所有下降的JLayer上递归调用JLayer.getView()。- 参数:
-
viewport- 要获取其第一个非JLayer实例后代的JViewport。 - 返回:
-
JViewport的第一个后代,该后代不是JLayer的实例。如果找不到这样的后代,则返回null。 - 抛出:
-
NullPointerException- 如果viewport为null - 自版本:
- 1.7
- 参见:
-
KeyboardFocusManager.getFocusOwner()替代。