borland Packages Class Hierarchy dbswing Package
java.lang.Object +----com.borland.dbswing.DBLabelDataBinder
Constructors Properties Methods
Implements AccessListener, ColumnAware, DataChangeListener, DataSetAware, Designable, NavigationListener, MouseListener, PropertyChangeListener, Serializable, EventListener
DBLabelDataBinder
synchronizes the text and/or icon of a JLabel
or a subclass of JLabel
with the values in a DataSet
. DBLabelDataBinder
is used to make the dbSwing JdbLabel
component data-aware.
To use DBLabelDataBinder
, set the JLabel
property to any JLabel
or class that extends JLabel
. DBLabelDataBinder
also binds the alignment
, background
, foreground
, and font
properties from those defined on Column
columnName
(if defined), unless these properties are explicitly set on the JLabel
itself. The label's horizontalAlignment
and verticalAlignment
properties are assumed to be in their default state if they are SwingConstants.LEFT
and SwingConstants.CENTER
, respectively.
Set DBLabelDataBinder's
dataSet
, columnName
, and columnNameIcon
properties to indicate the DataSet
and Columns
from which the text and icon are read. Note that at least one of the columnName
and columnNameIcon
properties must be set. The columnNameIcon
property should be the name of a DataSet
Column
of type Variant.OBJECT
or Variant.INPUTSTREAM
.
DBLabelDataBinder
ensures that the label's text is always consistent with the current value of the DataSet
Column
to which it is attached. Therefore, as the DataSet
is navigated and the text of the label is updated, the label's container (depending upon its current LayoutManager
) may adjust its layout to accommodate the label's new size.
If you explicitly set the label's text while it is still attached to the DataSet
, the text is overwritten the next time the DataSet
value changes.
JLabel jLabel = new JLabel(); DBLabelDataBinder dBLabelDataBinder = new DBLabelDataBinder(); // attach the label to dBLabelDataBinder dBLabelDataBinder.setJLabel(jLabel); // set the target DataSet and Column dBLabelDataBinder.setDataSet(DataSet); dBLabelDataBinder.setColumnName("Luminescence"); dBLabelDataBinder.setColumnNameIcon("JPG Image")
JdbLabel
public DBLabelDataBinder()Creates a
DBLabelDataBinder
. Calls the null
constructor of its superclass.
public DBLabelDataBinder(JLabel label)Creates a
DBLabelDataBinder
that makes the specified JLabel
component data aware. Calls the null
constructor of its superclass.
label
JLabel
that provides the label.
public String getColumnName() public void setColumnName(String columnName)Returns and sets the column name of the
DataSet
from which the label's text is read and to which the text is written.
columnNameIcon
, dataSet
public String getColumnNameIcon() public void setColumnNameIcon(String columnNameIcon)Returns and sets the column name of the
DataSet
from which the label's icon is to be read and to which the icon is to be written.
columnName
, dataSet
public DataSet getDataSet() public void setDataSet(DataSet dataSet)Returns and sets the
DataSet
from which the label's data is to be read and to which the data is to be written.
columnName
, columnNameIcon
public boolean isIconEditable() public void setIconEditable(boolean iconEditable)Returns and sets whether the label's icon can be changed at runtime. If
iconEditable
is true
, double-clicking the label displays a dialog box prompting the user to select an image file from which to set the icon. If a valid image file is selected, the label's icon is updated and saved to the DataSet
column.
Note that setting the icon directly using setIcon()
does not save the icon to the DataSet
. Use DataSet's setObject()
or setInputStream()
methods to save an icon programmatically to a DataSet
column.
public JLabel getJLabel() public void setJLabel(JLabel label)Returns and sets the
JLabel
that DBLabelDataBinder
makes data-aware. DBLabelDataBinder
also binds the alignment
, background
, foreground
, and font
properties from those defined on Column
columnName
(if defined), unless these properties are explicitly set on JLabel
itself.
public void putIcon(InputStream inputStream)Writes the image (assumed to be) contained in the specified
inputStream
to the columnOrdinalIcon
column.