public abstract class CellRenderer extends Object
Note that there is not one CellRenderer per individual cell in the table-like presentation of a TreeView! Instead, a CellRenderer is an engine called upon to draw many cells. The Widget employing them will, by turn, set various properties (the actual data for the current cell in question would be what changes, though most of the rest of the properties would likely remain constant) and then ask the CellRenderer to return the rendered result.
You will see two types of setters in CellRenderers. The most important ones are those that take a DataColumn for an argument, and will adjust that property of the CellRenderer for each row of the model based on the value of the specified column.
While the whole point of the CellRenderers is to present the data from a given column of your data model, CellRenderers also offer a considerable number of properties that you don't need to vary row by row but want to set for the TreeViewColumn as a whole. For these you will notice a a setter which takes a conventional type as its argument; setting this property will set it for all rows in that column. (Occasionally you will see the setter for a property overloaded to offer you both a DataColumn driven mode and a fixed value mode for the rare occasions where both styles are useful, but in general it's fairly obvious that you use a property one way or the other).
It's easy to be tempted into thinking that CellRenderers are Widgets,
especially as they get pack()
ed into TreeViewColumns on their
way to being used in TreeViews. They are, however, merely utility elements
that are used to facilitate drawing, and not full power Widgets.
Do not try to reuse a CellRenderer between different TreeViewColumns.
Modifier and Type | Method and Description |
---|---|
void |
setAlignment(float xalign,
float yalign)
Set the alignment of this CellRenderer in the TreeViewColumn.
|
void |
setBackground(DataColumnString column)
Indicate the DataColumn containing the name of the colour to use as
background for this CellRenderer.
|
void |
setBackground(String colour)
Set the background colour to be used by this CellRenderer for all the
rows it draws.
|
void |
setVisible(DataColumnBoolean column)
Indicate if the CellRenderer should be visible, depending on the
content of a DataColumnBoolean.
|
void |
setWidth(int width)
Fix the width of this CellRenderer, specified in pixels.
|
public void setAlignment(float xalign, float yalign)
public void setBackground(DataColumnString column)
setBackground()
overload.public void setBackground(String colour)
public void setVisible(DataColumnBoolean column)
CellRendererToggle
was
visible in a TreeView where you want each of the leaf rows to have such
a Button but you do not want the parent node rows to have one.public void setWidth(int width)