检索 ComboBox 对象内的数组对象

huangapple 未分类评论46阅读模式
英文:

Retrieving array object inside a ComboBox object

问题

public class AddressSelector {

    private String name;
    private AddressInternalType[] types;
}

private ComboBox<AddressSelector> lvlTwoDen;

lvlTwoDen.valueProperty().addListener((observable, oldValue, newValue) -> {

    AddressItemExt address = lvlOneAddress.getValue();
    if(address != null){
        setupLvlTwoName(ServiceUtil.getAddress(address.getCode(), lvlTwoAddress.getEditor().getText() + "*", lvlTwoDen.getValue().getTypes()));
    }
});

I have a comboBox of a specific object. In that comboBox object I have an array object which I want to retrieve. I tried the following code snippet using `lvlTwoDen.getValue().getTypes()` however `lvlTwoDen.getValue()` returns null. How can I retrieve the Types from the combobox?

EDIT:

I have 2 comboboxes. lvlOneDen and lvlTwoDen. On selection of a value from lvlOneDen, I am setting a value in lvlTwoDen successfully using `lvlTwoDen.getSelectionModel().select(0)`.

like this:

lvlOneSiruta.valueProperty().addListener((observable, oldVal, newVal) -> {

                lvlTwoDenom.getSelectionModel().select(0);
});

However, since I've just selected the value in lvlOneDen and haven't clicked and selected any value in lvlTwoDen, I get lvlTwoDen.getValue() as null. Is there a way to set a 'value' for lvlTwoDen on selection of a value in lvlOneDen?
英文:
public class AddressSelector{

    private String name;
    private AddressInternalType[] types;
}

private ComboBox&lt;AddressSelector&gt; lvlTwoDen;


lvlTwoDen.valueProperty().addListener((observable, oldValue, newValue) -&gt; {

    AddressItemExt address = lvlOneAddress.getValue();
    if(address != null){
        setupLvlTwoName(ServiceUtil.getAddress(address.getCode(), lvlTwoAddress.getEditor().getText() + &quot;*&quot;, lvlTwoDen.getValue().getTypes()));
    }
});

I have a comboBox of a specific object. In that comboBox object i have an array object which I want to retrieve. I tried the following code snippet using lvlTwoDen.getValue().getTypes() however lvlTwoDen.getValue() returns null. How can I retrieve the Types from the combobox ?

EDIT :

I have 2 comboboxes. lvlOneDen and lvlTwoDen. On selection of a value from lvlOneDen i am setting a value in lvlTwoDen successfully using lvlTwoDen.getSelectionModel().select(0).

like this :

lvlOneSiruta.valueProperty().addListener((observable, oldVal, newVal) -&gt; {

                lvlTwoDenom.getSelectionModel().select(0);
});

However, since I'm just selecting the value in lvlOneDen and haven't clicked and selected any value in lvlTwoDen, I get lvlTwoDen.getValue() as null. Is there a way to set a 'value' for lvlTwoDen on selection of a value in lvlOneDen ?

huangapple
  • 本文由 发表于 2020年5月19日 20:10:34
  • 转载请务必保留本文链接:https://java.coder-hub.com/61890732.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定