有一个田间工厂——
...
public IncomingFieldFactory(MainView app) {
hbnContainer = new HbnContainer<Incoming>(Incoming.class, app);
}
@Override
public Field createField(Container container, Object itemId,
Object propertyId, Component uiContext) {
final Field f = super.createField(container, itemId, propertyId, uiContext);
if(f != null) {
if(f instanceof TextField) {
TextField tf = (TextField) f;
tf.setWidth("100%");
}
if(propertyId.equals("incomingDate")) {
((DateField) f).setResolution(DateField.RESOLUTION_MIN);
f.setWidth("100%");
}
if(propertyId.equals("incomingBalance")) {
f.setEnabled(false);
}
if(propertyId.equals("incomingValue")) {
incomingValueT = f;
...
...
public Field getIncomingValueT() {
return incomingValueT;
}
...
我想将一些字段传递给另一个类来管理它们(启用/禁用),但是NullPointerException
在调用时得到 -
...
Field f = incomingFieldFactory.getIncomingValueT();
f.setEnabled(false);
...
我究竟做错了什么?