Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.plaf.basic.BasicGraphicsUtils
public class BasicGraphicsUtils
extends Object
Constructor Summary | |
|
Method Summary | |
static void | |
static void |
|
static void | |
static void |
|
static void | |
static void |
|
static void |
|
static Insets |
|
static Insets |
|
static Dimension |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public BasicGraphicsUtils()
Constructor. It is utterly unclear why this class should be constructable, but this is what the API specification says.
public static void drawBezel(Graphics g, int x, int y, int width, int height, boolean isPressed, boolean isDefault, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
Draws a border that is suitable for buttons of the Basic look and feel.
![]()
- Parameters:
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.isPressed
-true
to draw the button border with a pressed-in appearance;false
for normal (unpressed) appearance.isDefault
-true
to draw the border with the appearance it has when hitting the enter key in a dialog will simulate a click to this button;false
for normal appearance.shadow
- the shadow color.darkShadow
- a darker variant of the shadow color.highlight
- the highlight color.lightHighlight
- a brighter variant of the highlight color.
public static void drawDashedRect(Graphics g, int x, int y, int width, int height)
Draws a rectangle, simulating a dotted stroke by painting only every second pixel along the one-pixel thick edge. The color of those pixels is the current color of the Graphicsg
. Any other pixels are left unchanged.
![]()
- Parameters:
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.
public static void drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
Draws a rectangle that appears etched into the surface, given four colors that are used for drawing.
![]()
- Parameters:
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting the outer side of the top and left edges.darkShadow
- the color that will be used for painting the inner side of the top and left edges.highlight
- the color that will be used for painting the inner side of the bottom and right edges.lightHighlight
- the color that will be used for painting the outer side of the bottom and right edges.
- See Also:
getEtchedInsets()
,EtchedBorder
public static void drawGroove(Graphics g, int x, int y, int width, int height, Color shadow, Color highlight)
Draws a rectangle that appears etched into the surface, given two colors that are used for drawing.
![]()
- Parameters:
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting the outer side of the top and left edges, and for the inner side of the bottom and right ones.highlight
- the color that will be used for painting the inner side of the top and left edges, and for the outer side of the bottom and right ones.
- See Also:
getGrooveInsets()
,EtchedBorder
public static void drawLoweredBezel(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
Draws a rectangle that appears lowered into the surface, given four colors that are used for drawing.
![]()
Compatibility with the Sun reference implementation: The Sun reference implementation seems to ignore the
x
andy
arguments, at least in JDK 1.3.1 and 1.4.1_01. The method always draws the rectangular area at location (0, 0). A bug report has been filed with Sun; its “bug ID” is 4880003. The GNU Classpath implementation behaves correctly, thus not replicating this bug.
- Parameters:
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting the inner side of the top and left edges.darkShadow
- the color that will be used for painting the outer side of the top and left edges.highlight
- the color that will be used for painting the inner side of the bottom and right edges.lightHighlight
- the color that will be used for painting the outer side of the bottom and right edges.
public static void drawString(Graphics g, String text, int underlinedChar, int x, int y)
Draws a String at the given location, underlining the first occurence of a specified character. The algorithm for determining the underlined position is not sensitive to case. If the character is not part oftext
, the text will be drawn without underlining. Drawing is performed in the current color and font ofg
.
![]()
- Parameters:
g
- the graphics into which the String is drawn.text
- the String to draw.underlinedChar
- the character whose first occurence intext
will be underlined. It is not clear why the API specification declares this argument to be of typeint
instead ofchar
. While this would allow to pass Unicode characters outside Basic Multilingual Plane 0 (U+0000 .. U+FFFE), at least the GNU Classpath implementation does not underline anything ifunderlinedChar
is outside the range ofchar
.x
- the x coordinate of the text, as it would be passed toGraphics.drawString(String,int,int)
.y
- the y coordinate of the text, as it would be passed toGraphics.drawString(String,int,int)
.
public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)
Draws a String at the given location, underlining the character at the specified index. Drawing is performed in the current color and font ofg
.
![]()
- Parameters:
g
- the graphics into which the String is drawn.text
- the String to draw.underlinedIndex
- the index of the underlined character intext
. IfunderlinedIndex
falls outside the range[0, text.length() - 1]
, the text will be drawn without underlining anything.x
- the x coordinate of the text, as it would be passed toGraphics.drawString(String,int,int)
.y
- the y coordinate of the text, as it would be passed toGraphics.drawString(String,int,int)
.
- Since:
- 1.4
public static Insets getEtchedInsets()
Determines the width of the border that gets painted bydrawEtchedRect(Graphics,int,int,int,int,Color,Color,Color,Color)
.
- Returns:
- an
Insets
object whosetop
,left
,bottom
andright
field contain the border width at the respective edge in pixels.
public static Insets getGrooveInsets()
Determines the width of the border that gets painted bydrawGroove(Graphics,int,int,int,int,Color,Color)
.
- Returns:
- an
Insets
object whosetop
,left
,bottom
andright
field contain the border width at the respective edge in pixels.
public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap)
Determines the preferred width and height of an AbstractButton, given the gap between the button’s text and icon.
- Parameters:
b
- the button whose preferred size is determined.textIconGap
- the gap between the button’s text and icon.
- Returns:
- a
Dimension
object whosewidth
andheight
fields indicate the preferred extent in pixels.