All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.sun.java.swing.SwingUtilities
rectA
that do not overlap with rectB
.
sourceEvent
except that its x
and y members have been converted to destination
's coordinate
system.
(x,y)
in source
coordinate system to
destination
coordinate system.
aPoint
in source
coordinate system to
destination
coordinate system.
aRectangle
in source
coordinate system to
destination
coordinate system.
comp
in the
component hierarchy and returns the first object of name
it
finds.
comp
in the
component hierarchy and returns the first object of class c
it
finds.
x
, y
.
aComponent
true
if a component a
descends from a component b
a
contains b
aComponent
's window
public SwingUtilities()
public static final boolean isRectangleContainingRectangle(Rectangle a, Rectangle b)
a
contains b
public static Rectangle getLocalBounds(Component aComponent)
aComponent
public static Point convertPoint(Component source, Point aPoint, Component destination)
aPoint
in source
coordinate system to
destination
coordinate system.
If source>
is null,aPoint
is assumed to be in destination
's
root component coordinate system.
If destination
is null, aPoint
will be converted to source
's
root component coordinate system.
If both source
and destination
are null, return aPoint
without any conversion.
public static Point convertPoint(Component source, int x, int y, Component destination)
(x,y)
in source
coordinate system to
destination
coordinate system.
If source>
is null,(x,y)
is assumed to be in destination
's
root component coordinate system.
If destination
is null, (x,y)
will be converted to source
's
root component coordinate system.
If both source
and destination
are null, return (x,y)
without any conversion.
public static Rectangle convertRectangle(Component source, Rectangle aRectangle, Component destination)
aRectangle
in source
coordinate system to
destination
coordinate system.
If source>
is null,aRectangle
is assumed to be in destination
's
root component coordinate system.
If destination
is null, aRectangle
will be converted to source
's
root component coordinate system.
If both source
and destination
are null, return aRectangle
without any conversion.
public static Container getAncestorOfClass(Class c, Component comp)
comp
in the
component hierarchy and returns the first object of class c
it
finds. Can return null, if a class c
cannot be found.
public static Container getAncestorNamed(String name, Component comp)
comp
in the
component hierarchy and returns the first object of name
it
finds. Can return null, if name
cannot be found.
public static Component getDeepestComponentAt(Component parent, int x, int y)
x
, y
. If parent
is not a Container, it is
returned, otherwise this method is messaged again with the child
component at x
, y
.
public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination)
sourceEvent
except that its x
and y members have been converted to destination
's coordinate
system. If source
is null, sourceEvent
x and y members
are assumed to be into destination's root component coordinate system.
If destination
is null
, the
returned MouseEvent will be in source
's coordinate system.
sourceEvent
will not be changed. A new event is returned.
the source
field of the returned event will be set
to destination
if destination is non null
use the translateMouseEvent() method to translate a mouse event from
one component to another without changing the source.
public static void convertPointToScreen(Point p, Component c)
public static void convertPointFromScreen(Point p, Component c)
public static Window windowForComponent(Component aComponent)
aComponent
's window
public static boolean isDescendingFrom(Component a, Component b)
true
if a component a
descends from a component b
public static Rectangle computeIntersection(int x, int y, int width, int height, Rectangle dest)
public static Rectangle computeUnion(int x, int y, int width, int height, Rectangle dest)
public static Rectangle[] computeDifference(Rectangle rectA, Rectangle rectB)
rectA
that do not overlap with rectB
. If the
two Rects do not overlap, returns an empty array
public static boolean isLeftMouseButton(MouseEvent anEvent)
public static boolean isMiddleMouseButton(MouseEvent anEvent)
public static boolean isRightMouseButton(MouseEvent anEvent)
public static int computeStringWidth(FontMetrics fm, String str)
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)
public static void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
public static void paintComponent(Graphics g, Component c, Container p, Rectangle r)
public static void updateComponentTreeUI(Component c)
public static void invokeLater(Runnable doRun)
Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; SwingUtilities.invokeAndWait(doHelloWorld); System.out.println("Waiting ... ");If invokeAndWait is called from the event dispatching thread, e.g. from a JButtons ActionListener, the doRun.run() will still be deferred till all pending events have been processed. Note that if the doRun.run() throws an uncaught exception the event dispatching thread will unwind (not the current thread).
Additional documentation and examples for this method can be
found in .
public static void invokeAndWait(Runnable doRun) throws InterruptedException, InvocationTargetException
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();Note that if the Runnable.run() method throws an uncaught exception (on the event dispatching thread) it's caught and rethrown, as an InvocationTargetException, on the callers thread.
Additional documentation and examples for this method can be
found in .
public static boolean isEventDispatchThread()
public static int getAccessibleIndexInParent(Component c)
public static Accessible getAccessibleAt(Component c, Point p)
public static AccessibleStateSet getAccessibleStateSet(Component c)
public static int getAccessibleChildrenCount(Component c)
public static Accessible getAccessibleChild(Component c, int i)
public static Component findFocusOwner(Component c)
public static JRootPane getRootPane(Component c)
public static Component getRoot(Component c)
All Packages Class Hierarchy This Package Previous Next Index