Hello, i have a Label used as a tableview cell renderer. However, when using
it, i get a NullPointerException inside the pivot Terra skin. Is there a
limitation that Label can't be used as cell renderers?
the following is BXML code:
<TableView bxml:id="nodeACLs" tableDataKey="aces">
<columns>
<TableView.Column name="principal" headerData="who"
width="1*" >
<cellRenderer>
<ui:PrincipalCellRenderer/>
</cellRenderer>
</TableView.Column>
with PrincipalCellRender extending Label
public class PrincipalCellRenderer extends Label implements
TableView.CellRenderer{
@Override
public void render(Object row, int rowIndex, int columnIndex,
TableView tableView, String columnName, boolean selected,
boolean highlighted, boolean disabled) {
if (row !=null){
DavPrincipal principal = ((DavAce)row).getPrincipal();
System.out.println("Setting row to"+principal.getValue());
setText(principal.getValue());
} else
setText("");
}
@Override
public String toString(Object row, String columnName) {
if (row !=null){
DavPrincipal principal = ((DavAce)row).getPrincipal();
return principal.getValue();
}
return "";
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.apache.pivot.wtk.skin.LabelSkin.paint(LabelSkin.java:295)
at org.apache.pivot.wtk.Component.paint(Component.java:2060)
at
org.apache.pivot.wtk.skin.terra.TerraTableViewSkin.paint(TerraTableViewSkin.java:446)
at org.apache.pivot.wtk.Component.paint(Component.java:2060)
at org.apache.pivot.wtk.Container.paint(Container.java:410)
at org.apache.pivot.wtk.Container.paint(Container.java:410)
Eclipse point me to the following line of LabelSkin for exception
if (glyphVectors.getLength() > 0) {
I solved this by calling manually layout() during render(), but that seems
curious.
David Delbecq