com.ideanest.swing
Class BoundFormattedLabelAdapter
java.lang.Object
|
+--com.ideanest.swing.BoundFormattedLabelAdapter
- public class BoundFormattedLabelAdapter
- extends java.lang.Object
An adapter that hooks up a bound property of some source object to
a JLabel , updating its string representation with a
formatter each time the property changes value. You provide the
label and formatter. You must also provide the source object and
the property name to track. The appropriate method for retrieving
the property is found through the object's class's bean descriptor.
If you want the formatted string to include some kind of message (say,
a prefix in front of the value), you'll need to use a MessageFormat .
Since a MessageFormat requires an array of objects to format,
you might be interested in using the OneArgMessageFormatAdapter .
Warning: This adapter will install a property change listener
on the source object. The listener will not be automatically
removed even if the label is disposed of, which could lead to a memory
leak. To ensure that the listener is removed, set the label to null
when the adapter is no longer needed. This deficiency should be fixed
in the future, once JDK 1.4 becomes available.
- See Also:
OneArgMessageFormatAdapter
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BoundFormattedLabelAdapter
public BoundFormattedLabelAdapter()
BoundFormattedLabelAdapter
public BoundFormattedLabelAdapter(javax.swing.JLabel label,
java.text.Format format)
BoundFormattedLabelAdapter
public BoundFormattedLabelAdapter(javax.swing.JLabel label,
java.text.Format format,
java.lang.Object source,
java.lang.String propertyName)
getFormat
public java.text.Format getFormat()
getLabel
public javax.swing.JLabel getLabel()
getPropertyName
public java.lang.String getPropertyName()
getSource
public java.lang.Object getSource()
setFormat
public void setFormat(java.text.Format format)
setLabel
public void setLabel(javax.swing.JLabel label)
setProperty
public void setProperty(java.lang.Object source,
java.lang.String propertyName)
|