com.jstatcom.component
Class MultiLineLabelUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.LabelUI
javax.swing.plaf.basic.BasicLabelUI
com.jstatcom.component.MultiLineLabelUI
- All Implemented Interfaces:
- java.beans.PropertyChangeListener, java.util.EventListener
public final class MultiLineLabelUI
- extends javax.swing.plaf.basic.BasicLabelUI
* Author: Zafir Anjum * http://codeguru.earthweb.com/java/articles/198.shtml * *
Use multi-line text in a JLabel. * To enable multi-line in a JLabel we have
to specify our own LabelUI * class that will render the multiple lines.
Although the code shown * below seems quite long, most of it is actually
Swing code being reused. * *
Method Summary |
static java.awt.Dimension |
computeMultiLineDimension(java.awt.FontMetrics fm,
java.lang.String[] strs)
|
static java.lang.String |
layoutCompoundLabel(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)
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. |
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)
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. |
Methods inherited from class javax.swing.plaf.basic.BasicLabelUI |
createUI, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, propertyChange, uninstallUI |
Methods inherited from class javax.swing.plaf.ComponentUI |
contains, getAccessibleChild, getAccessibleChildrenCount, update |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiLineLabelUI
public MultiLineLabelUI()
computeMultiLineDimension
public static java.awt.Dimension computeMultiLineDimension(java.awt.FontMetrics fm,
java.lang.String[] strs)
layoutCompoundLabel
public static java.lang.String layoutCompoundLabel(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)
- 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. This layoutCompoundLabel() does not know how to handle
LEADING/TRAILING values in horizontalTextPosition (they will default to
RIGHT) and in horizontalAlignment (they will default to CENTER). Use the
other version of layoutCompoundLabel() instead.
layoutCompoundLabel
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)
- 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. The JComponents orientation (LEADING/TRAILING) will also be
taken into account and translated into LEFT/RIGHT values accordingly.