All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.SwingUtilities
java.lang.Object
|
+----com.sun.java.swing.SwingUtilities
- public class SwingUtilities
- extends Object
- implements SwingConstants
A collection of conveniences for Swing
-
SwingUtilities()
-
-
computeIntersection(int, int, int, int, Rectangle)
-
-
computeStringWidth(FontMetrics, String)
-
-
computeUnion(int, int, int, int, Rectangle)
-
-
convertMouseEvent(Component, MouseEvent, Component)
- Returns a MouseEvent similar to sourceEvent except that its x
and y members have been converted to destination's coordinate
system.
-
convertPoint(Component, int, int, Component)
- Convert the point (x,y) in source coordinate system to
destination coordinate system.
-
convertPoint(Component, Point, Component)
- Convert a aPoint in source coordinate system to
destination coordinate system.
-
convertRectangle(Component, Rectangle, Component)
- Convert the rectangle aRectangle in source coordinate system to
destination coordinate system.
-
getAncestorNamed(String, Component)
- Convience method for searching above comp in the
component hierarchy and returns the first object of name it
finds.
-
getAncestorOfClass(Class, Component)
- Convience method for searching above comp in the
component hierarchy and returns the first object of class c it
finds.
-
getDeepestComponentAt(Component, int, int)
- Returns the deepest child Component of parent that is at the location
x, y.
-
getLocalBounds(Component)
- Return the rectangle (0,0,bounds.width,bounds.height) for the component
aComponent
-
invokeAndWait(Runnable)
- Causes obj to have its run() method called in the dispatch
thread of the EventQueue.
-
invokeLater(Runnable)
- Causes obj to have its run() method called in the dispatch
thread of the EventQueue.
-
isDescendingFrom(Component, Component)
- Return
true
if a component a
descends from a component b
-
isLeftMouseButton(MouseEvent)
-
-
isMiddleMouseButton(MouseEvent)
-
-
isRectangleContainingRectangle(Rectangle, Rectangle)
- Return true if
a
contains b
-
isRightMouseButton(MouseEvent)
-
-
layoutCompoundLabel(FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle, Rectangle, int)
-
Compute and return the location of the icons origin, the
location of origin of the text baseline, and a possibly clipped
version of the compound labels string.
-
layoutMenuItem(FontMetrics, String, Icon, Icon, Icon, int, int, int, int, Rectangle, Rectangle, Rectangle, Rectangle, Rectangle, int, int)
-
Compute and return the location of the icons origin, the
location of origin of the text baseline, and a possibly clipped
version of the compound labels string.
-
paintComponent(Graphics, Component, Container, int, int, int, int)
-
Paint a component c on an abitrary graphics g in the
specified rectangle.
-
paintComponent(Graphics, Component, Container, Rectangle)
-
-
windowForComponent(Component)
- Return
aComponent
's window
SwingUtilities
public SwingUtilities()
isRectangleContainingRectangle
public static final boolean isRectangleContainingRectangle(Rectangle a,
Rectangle b)
- Return true if
a
contains b
getLocalBounds
public static Rectangle getLocalBounds(Component aComponent)
- Return the rectangle (0,0,bounds.width,bounds.height) for the component
aComponent
convertPoint
public static Point convertPoint(Component source,
Point aPoint,
Component destination)
- Convert a 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 destinationis null, aPoint will be converted to source's
root component coordinate system.
If both source and destination are null, return aPoint
without any conversion.
If both source and destination
convertPoint
public static Point convertPoint(Component source,
int x,
int y,
Component destination)
- Convert the point (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 destinationis 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.
If both source and destination
convertRectangle
public static Rectangle convertRectangle(Component source,
Rectangle aRectangle,
Component destination)
- Convert the rectangle 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 destinationis null, aRectangle will be converted to source's
root component coordinate system.
If both source and destination are null, return aRectangle
without any conversion.
If both source and destination
getAncestorOfClass
public static Container getAncestorOfClass(Class c,
Component comp)
- Convience method for searching above 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.
getAncestorNamed
public static Container getAncestorNamed(String name,
Component comp)
- Convience method for searching above comp in the
component hierarchy and returns the first object of name it
finds. Can return null, if name cannot be found.
getDeepestComponentAt
public static Component getDeepestComponentAt(Component parent,
int x,
int y)
- Returns the deepest child Component of parent that is at the location
x, y. If parent is not a Container, it is
returned, otherwise this method is messaged again with the child
component at x, y.
convertMouseEvent
public static MouseEvent convertMouseEvent(Component source,
MouseEvent sourceEvent,
Component destination)
- Returns a MouseEvent similar to 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 translateMouseEvent() to translate a mouse event from one component
to another without changing the source.
windowForComponent
public static Window windowForComponent(Component aComponent)
- Return
aComponent
's window
isDescendingFrom
public static boolean isDescendingFrom(Component a,
Component b)
- Return
true
if a component a
descends from a component b
invokeLater
public static void invokeLater(Runnable obj)
- Causes obj to have its run() method called in the dispatch
thread of the EventQueue. This will happen after all pending events
are processed.
invokeAndWait
public static void invokeAndWait(Runnable obj) throws InterruptedException, InvocationTargetException
- Causes obj to have its run() method called in the dispatch
thread of the EventQueue. This will happen after all pending events
are processed. The call blocks until this has happened. This is a
bad thing (tm) to do from within the dispatch thread of the
EventQueue.
computeIntersection
public static Rectangle computeIntersection(int x,
int y,
int width,
int height,
Rectangle dest)
computeUnion
public static Rectangle computeUnion(int x,
int y,
int width,
int height,
Rectangle dest)
isLeftMouseButton
public static boolean isLeftMouseButton(MouseEvent anEvent)
isMiddleMouseButton
public static boolean isMiddleMouseButton(MouseEvent anEvent)
isRightMouseButton
public static boolean isRightMouseButton(MouseEvent anEvent)
computeStringWidth
public static int computeStringWidth(FontMetrics fm,
String str)
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)
- Compute and return the location of the icons origin, the
location of origin of the text baseline, and a possibly clipped
version of the compound labels string. Locations are computed
relative to the viewR rectangle.
layoutMenuItem
public static String layoutMenuItem(FontMetrics fm,
String text,
Icon icon,
Icon checkIcon,
Icon arrowIcon,
int verticalAlignment,
int horizontalAlignment,
int verticalTextPosition,
int horizontalTextPosition,
Rectangle viewR,
Rectangle iconR,
Rectangle textR,
Rectangle checkIconR,
Rectangle arrowIconR,
int textIconGap,
int menuItemGap)
- Compute and return the location of the icons origin, the
location of origin of the text baseline, and a possibly clipped
version of the compound labels string. Locations are computed
relative to the viewR rectangle.
paintComponent
public static void paintComponent(Graphics g,
Component c,
Container p,
int x,
int y,
int w,
int h)
- Paint a component c on an abitrary graphics g in the
specified rectangle. The component is reparented to a private
container (whose parent becomes p) which prevents c.validate() and
and c.repaint() calls from propogating up the tree. The intermediate
container has no other effect.
paintComponent
public static void paintComponent(Graphics g,
Component c,
Container p,
Rectangle r)
All Packages Class Hierarchy This Package Previous Next Index