public class MySwingUtilities2
extends java.lang.Object
本类中的各方法都是自动据JVM版本不同对SwingUtilities2进行反射调用 实现的,以便解决兼容性问题。.
| 构造器和说明 |
|---|
MySwingUtilities2() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.lang.String |
clipString(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
Clips the passed in String to the space provided.
|
static java.lang.String |
clipStringIfNecessary(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
Clips the passed in String to the space provided.
|
static void |
drawString(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String text,
int x,
int y)
Draws the string at the specified location.
|
static void |
drawStringUnderlineCharAt(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String text,
int underlinedIndex,
int x,
int y)
Draws the string at the specified location underlining the specified
character.
|
static boolean |
drawTextAntialiased(boolean aaText)
Returns whether or not text should be drawn antialiased.
|
static java.awt.FontMetrics |
getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g)
Returns the FontMetrics for the current Font of the passed
in Graphics.
|
static java.awt.FontMetrics |
getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g,
java.awt.Font font)
Returns the FontMetrics for the specified Font.
|
static java.awt.Graphics2D |
getGraphics2D(java.awt.Graphics g)
Gets the graphics2 d.
|
static java.lang.String |
getSwingUtilities2ClassName()
Gets the swing utilities2 class name.
|
static java.lang.Object |
invokeSwingUtilities2StaticMethod(java.lang.String methodName,
java.lang.Class[] paramsType,
java.lang.Object[] paramsValue)
Invoke swing utilities2 static method.
|
static int |
stringWidth(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string)
Returns the width of the passed in String.
|
public static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g)
Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not readily available at the time of painting.
This does not necessarily return the FontMetrics from the Graphics.
c - JComponent requesting FontMetrics, may be nullg - Graphics Graphicspublic static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g,
java.awt.Font font)
Callers should pass in a non-null JComonent, the exception to this is if a JComponent is not readily available at the time of painting.
This does not necessarily return the FontMetrics from the Graphics.
c - Graphics Graphicsg - the gfont - Font to get FontMetrics forpublic static int stringWidth(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string)
c - JComponent that will display the string, may be nullfm - FontMetrics used to measure the String widthstring - String to get the width ofpublic static void drawString(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String text,
int x,
int y)
c - JComponent that will display the string, may be nullg - Graphics to draw the text totext - String to displayx - X coordinate to draw the text aty - Y coordinate to draw the text atpublic static boolean drawTextAntialiased(boolean aaText)
aaText - Whether or not aa text has been turned on for the
component.public static java.awt.Graphics2D getGraphics2D(java.awt.Graphics g)
g - the gpublic static void drawStringUnderlineCharAt(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String text,
int underlinedIndex,
int x,
int y)
c - JComponent that will display the string, may be nullg - Graphics to draw the text totext - String to displayunderlinedIndex - Index of a character in the string to underlinex - X coordinate to draw the text aty - Y coordinate to draw the text atpublic static java.lang.String clipStringIfNecessary(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
c - JComponent that will display the string, may be nullfm - FontMetrics used to measure the String widthstring - String to displayavailTextWidth - Amount of space that the string can be drawn inpublic static java.lang.String clipString(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
c - JComponent that will display the string, may be nullfm - FontMetrics used to measure the String widthstring - String to displayavailTextWidth - Amount of space that the string can be drawn inpublic static java.lang.Object invokeSwingUtilities2StaticMethod(java.lang.String methodName,
java.lang.Class[] paramsType,
java.lang.Object[] paramsValue)
methodName - the method nameparamsType - the params typeparamsValue - the params valuepublic static java.lang.String getSwingUtilities2ClassName()