public final class GraphicUtils extends Object
GraphicsUtils
class defines common user-interface related utility
functions.Modifier and Type | Field and Description |
---|---|
protected static Component |
component |
static Color |
SELECTION_COLOR |
static Color |
TOOLTIP_COLOR |
protected static MediaTracker |
tracker |
Modifier and Type | Method and Description |
---|---|
static void |
centerWindowOnComponent(Window window,
Component over)
Centers the window over a component (usually another window).
|
static void |
centerWindowOnScreen(Window window)
Sets the location of the specified window so that it is centered on screen.
|
static ImageIcon |
createImageIcon(Image image) |
static String |
createToolTip(String text) |
static String |
createToolTip(String text,
int width) |
static void |
drawHighlightBorder(Graphics g,
int x,
int y,
int width,
int height,
boolean raised,
Color shadow,
Color highlight)
Draws a single-line highlight border rectangle.
|
static Component |
focusComponentOrChild(Component c)
Puts the focus on the first component in the tree of
c that
can accept the focus. |
static Component |
focusComponentOrChild(Component c,
boolean deepest)
Puts the focus on the first component in the tree of
c that
can accept the focus. |
static Component |
getFocusableComponentOrChild(Component c)
Deprecated.
replaced by
getFocusableComponentOrChild(Component, boolean) |
static Component |
getFocusableComponentOrChild(Component c,
boolean deepest)
Returns the first component in the tree of
c that can accept
the focus. |
static Insets |
getHighlightBorderInsets()
Return the amount of space taken up by a highlight border drawn by
drawHighlightBorder() . |
static Point |
getPopupMenuShowPoint(JPopupMenu popup,
int x,
int y)
Returns a point where the given popup menu should be shown.
|
static Point |
getPopupMenuShowPoint(JPopupMenu popup,
MouseEvent event)
Returns a point where the given popup menu should be shown.
|
static Rectangle[] |
getScreenBounds() |
static boolean |
isAncestorOfFocusedComponent(Component c) |
static Image |
loadFromResource(String imageName,
Class cls)
|
static void |
makeSameSize(JComponent[] comps) |
static String |
toHTMLColor(Color c)
Return the hexidecimal color from a java.awt.Color
|
public static final Color SELECTION_COLOR
public static final Color TOOLTIP_COLOR
protected static final Component component
protected static final MediaTracker tracker
public static void centerWindowOnScreen(Window window)
window
- The window to be centered.public static void drawHighlightBorder(Graphics g, int x, int y, int width, int height, boolean raised, Color shadow, Color highlight)
g
- The graphics context to use for drawing.x
- The left edge of the border.y
- The top edge of the border.width
- The width of the border.height
- The height of the border.raised
- true
if the border is to be drawn raised,
false
if lowered.shadow
- The shadow color for the border.highlight
- The highlight color for the border.EtchedBorder
,
BasicGraphicsUtils
public static Insets getHighlightBorderInsets()
drawHighlightBorder()
.Insets
needed for the highlight border.drawHighlightBorder(java.awt.Graphics, int, int, int, int, boolean, java.awt.Color, java.awt.Color)
public static Point getPopupMenuShowPoint(JPopupMenu popup, MouseEvent event)
popup
- the popup menuevent
- the mouse eventpublic static Point getPopupMenuShowPoint(JPopupMenu popup, int x, int y)
popup
- the popup menux
- the x position in screen coordinatey
- the y position in screen coordinatespublic static void centerWindowOnComponent(Window window, Component over)
public static boolean isAncestorOfFocusedComponent(Component c)
@Deprecated public static Component getFocusableComponentOrChild(Component c)
getFocusableComponentOrChild(Component, boolean)
c
that can accept
the focus.c
- the root of the component hierarchy to searchfocusComponentOrChild(java.awt.Component)
public static Component getFocusableComponentOrChild(Component c, boolean deepest)
c
that can accept
the focus.c
- the root of the component hierarchy to searchdeepest
- if deepest
is true the method will return the first and deepest component that can accept the
focus. For example, if both a child and its parent are focusable and deepest
is true, the child is
returned.focusComponentOrChild(java.awt.Component)
public static Component focusComponentOrChild(Component c)
c
that
can accept the focus.public static Component focusComponentOrChild(Component c, boolean deepest)
c
that
can accept the focus.c
- the root of the component hierarchy to searchdeepest
- if deepest
is true the method will focus the first and deepest component that can
accept the focus.
For example, if both a child and its parent are focusable and deepest
is true, the child is focused.getFocusableComponentOrChild(java.awt.Component)
public static Rectangle[] getScreenBounds()
public static final void makeSameSize(JComponent[] comps)
public static final String toHTMLColor(Color c)
c
- Copyright © 2003-2008 Jive Software.