public final class StringUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
clipString(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth,
int clipLocation)
Clips the passed in String to the space provided.
|
static java.lang.String |
layoutCompoundLabel(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String text,
javax.swing.Icon icon,
int verticalAlignment,
int horizontalAlignment,
int verticalTextPosition,
int horizontalTextPosition,
java.awt.Rectangle viewR,
java.awt.Rectangle iconR,
java.awt.Rectangle textR,
int textIconGap,
int ellipsesLocation)
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.
|
public static java.lang.String layoutCompoundLabel(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap, int ellipsesLocation)
This method differs from the one in SwingUtilities as it offers a location for the string to clip at: LEADING, CENTER, TRAILING.
ellipsesLocation
- Where clipping will occur: SwingConstants.LEADING, TRAILING, CENTERSwingUtilities.layoutCompoundLabelImpl(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, int, int, int, int, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle, int)
public static java.lang.String clipString(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String string, int availTextWidth, int clipLocation)
This method differs from the one in SwingUtilities2 as it offers a location for the string to clip at: LEADING, CENTER, TRAILING.
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 inclipLocation
- where the string will clip: SwingConstants.LEADING/CENTER/TRAILINGSwingUtilities2.clipString(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String, int)