如何将类中的Array添加到JLIST JAVA?

时间:2017-05-18 11:51:17

标签: java swing

我想将类中的数组名称添加到jList中,如下所示。

怎么可能?

这是显示类

中的方法
    public void dataToLocal(List<XDataObject> data, XServiceType xst, XServiceOperation operation) {
            if(operation.getName().equals(SNOWTAMSubscriberServiceInterface.OP_PUBLISSNOWTAM)) {    
    SNOWTAMPublication snowtamPublication = 
    (SNOWTAMPublication)data.get(0).getValue(); //This read an array with 5 values.

        SNOWTAM snowtam = snowtamPublication.getSNOWTAM()[0]; //This read read the array and its contents.

        jList1.add((Component) Arrays.asList((snowtamPublication.getSNOWTAM()[0]).toString())); //Here I want to add the name of Array to be as below
    }
}

这是SNOWTAMPublication,它只是数组的get和set方法。

protected SNOWTAM[] snowtam;

public SNOWTAM[] getSNOWTAM() {
    if(snowtam == null)
    {
        snowtam = new SNOWTAM[0];
    }
    return snowtam;
}

public void setSNOWTAM(SNOWTAM[] _value) {
    this.snowtam = _value;
}

图片

enter image description here

1 个答案:

答案 0 :(得分:-1)

你可以尝试:

<instance>.getClass().getSimpleName()