所有类


javax.swing
类 SwingUtilities

java.lang.Object
  继承者 javax.swing.SwingUtilities
所有已实现的接口:
SwingConstants

public class SwingUtilities
   
   
   
   
extends Object
implements SwingConstants

Swing 实用方法的集合。


字段摘要
 
从接口 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 RectanglecalculateInnerArea(JComponent c, Rectangle r)
          将指定组件的内部绘制区域的位置和大小存储在 r 中,然后返回 r
static Rectangle[]computeDifference(Rectangle rectA, Rectangle rectB)
          返回矩形数组的便捷方法,该矩形表示不与 rectB 重叠的 rectA 内的区域。
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 voidconvertPointFromScreen(Point p, Component c)
          将一个点从屏幕坐标转换到组件的坐标系统
static voidconvertPointToScreen(Point p, Component c)
          将一个点从组件的坐标系统转换到屏幕坐标。
static RectangleconvertRectangle(Component source, Rectangle aRectangle, Component destination)
          将 source 坐标系统中的矩形 aRectangle 转换到 destination 坐标系统。
static ComponentfindFocusOwner(Component c)
          已过时。 从 1.4 开始,由 KeyboardFocusManager.getFocusOwner() 取代。
static AccessiblegetAccessibleAt(Component c, Point p)
          如果存在,则返回本地坐标 Point 处包含的 Accessible 子对象。
static AccessiblegetAccessibleChild(Component c, int i)
          返回对象的第 n 个可访问子对象。
static intgetAccessibleChildrenCount(Component c)
          返回对象中可访问的子对象数。
static intgetAccessibleIndexInParent(Component c)
          获取此对象在其可访问的父对象中的索引。
static AccessibleStateSetgetAccessibleStateSet(Component c)
          获取此对象的状态。
static ContainergetAncestorNamed(String name, Component comp)
          在组件层次结构中搜索上面的 comp 的便捷方法,返回它找到的 name 第一个对象。
static ContainergetAncestorOfClass(Class<?> c, Component comp)
          在组件层次结构中搜索上面的 comp 的便捷方法,返回它找到的类 c 的第一个对象。
static ComponentgetDeepestComponentAt(Component parent, int x, int y)
          返回包含位置 xyparent 的最深可见后代组件。
static RectanglegetLocalBounds(Component aComponent)
          返回组件 aComponent 的矩形 (0,0,bounds.width,bounds.height)。
static ComponentgetRoot(Component c)
          返回当前组件树结构的根组件。
static JRootPanegetRootPane(Component c)
          如果 c 是一个 JRootPane 后代,则返回其 JRootPane 祖先。
static ActionMapgetUIActionMap(JComponent component)
          返回该 UI 在组件 component 中提供的 ActionMap。
static InputMapgetUIInputMap(JComponent component, int condition)
          返回由组件 component 中的条件 condition 的 UI 提供的 InputMap。
static WindowgetWindowAncestor(Component c)
          返回 c 的第一个 Window 祖先;如果 c 未包含在 Window 内,则返回 null。
static voidinvokeAndWait(Runnable doRun)
          导致 doRun.run() 在 AWT 事件指派线程上同步执行。
static voidinvokeLater(Runnable doRun)
          导致 doRun.run() 在 AWT 事件指派线程上异步执行。
static booleanisDescendingFrom(Component a, Component b)
          如果组件 a 从组件 b 继承,则返回 true
static booleanisEventDispatchThread()
          如果当前线程是 AWT 事件指派线程,则返回 true。
static booleanisLeftMouseButton(MouseEvent anEvent)
          如果鼠标事件指定左边鼠标按键,则返回 true。
static booleanisMiddleMouseButton(MouseEvent anEvent)
          如果鼠标事件指定中间鼠标按键,则返回 true。
static booleanisRectangleContainingRectangle(Rectangle a, Rectangle b)
          如果 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),则调用 action 上的 actionPerformed
static voidpaintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
          在指定矩形中的任意图形 g 上绘制一个组件 c,指定该矩形的左上角位置和大小。
static voidpaintComponent(Graphics g, Component c, Container p, Rectangle r)
          在指定一个 Rectangle 对象的指定矩形中的任意图形 g 上绘制一个组件 c
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 voidupdateComponentTreeUI(Component c)
          简单的外观更改:将树结构中的每个节点转到 updateUI() -- 也就是说,通过当前外观初始化其 UI 属性。
static WindowwindowForComponent(Component c)
          返回 c 的第一个 Window 祖先;如果 c 未包含在 Window 内,则返回 null。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

isRectangleContainingRectangle

public static final boolean isRectangleContainingRectangle(Rectangle a,
                                                           Rectangle b)
如果 a 包含 b,则返回 true


getLocalBounds

public static Rectangle getLocalBounds(Component aComponent)
返回组件 aComponent 的矩形 (0,0,bounds.width,bounds.height)。


getWindowAncestor

public static Window getWindowAncestor(Component c)
返回 c 的第一个 Window 祖先;如果 c 未包含在 Window 内,则返回 null。

参数:
c - 要获取其 Window 祖先的 Component
返回:
返回 c 的第一个 Window 祖先;如果 c 未包含在 Window 内,则返回 null。

convertPoint

public static Point convertPoint(Component source,
                                 Point aPoint,
                                 Component destination)
source 坐标系统中的 aPoint 转换到 destination 坐标系统。如果 source 为 null,则假定 aPoint 位于 destination 的根组件坐标系统中。如果 destination 为 null,则将 aPoint 转换到 source 的根组件坐标系统。如果 sourcedestination 都为 null,则返回 aPoint,无需进行任何转换。


convertPoint

public static Point convertPoint(Component source,
                                 int x,
                                 int y,
                                 Component destination)
source 坐标系统中的点 (x,y) 转换到 destination 坐标系统。如果 source> 为 null,则假定 (x,y) 位于 destination 的根组件坐标系统中。如果 destination 为 null,则将 (x,y) 转换到 source 的根组件坐标系统。如果 sourcedestination 都为 null,则返回 (x,y),无需进行任何转换。


convertRectangle

public static Rectangle convertRectangle(Component source,
                                         Rectangle aRectangle,
                                         Component destination)
source 坐标系统中的矩形 aRectangle 转换到 destination 坐标系统。如果 source> 为 null,则假定 aRectangle 位于 destination 的根组件坐标系统中。如果 destination 为 null,则将 aRectangle 转换到 source 的根组件坐标系统。如果 sourcedestination 都为 null,则返回 aRectangle,无需进行任何转换。


getAncestorOfClass

public static Container getAncestorOfClass(Class<?> c,
                                           Component comp)
在组件层次结构中搜索上面的 comp 的便捷方法,返回它找到的类 c 的第一个对象。如果无法找到类 c,可以返回 null。