我正在開發.NET和Java的業務應用程序。在.NET中,我開發了一個使用basicHttpBinding
的web服務。我正在Java客戶端中使用這個Web服務。 Web服務工作正常,在Java代碼中調用它會返回Holding
類的ArrayList
集合。這個類描述如下:如何在Swing中將由Web服務返回的集合(ArrayList)綁定到JTable?
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Holding", propOrder = {
"companyName",
"price",
"quantity",
"scripCode"
})
public class Holding {
@XmlElementRef(
name = "CompanyName",
namespace = "http://schemas.datacontract.org/2004/07/JavaLIB",
type = JAXBElement.class)
protected JAXBElement<String> companyName;
@XmlElementRef(
name = "Price",
namespace = "http://schemas.datacontract.org/2004/07/JavaLIB",
type = JAXBElement.class)
protected JAXBElement<String> price;
@XmlElementRef(
name = "Quantity",
namespace = "http://schemas.datacontract.org/2004/07/JavaLIB",
type = JAXBElement.class)
protected JAXBElement<String> quantity;
@XmlElement(name = "ScripCode")
protected Integer scripCode;
/**
* Gets the value of the companyName property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public JAXBElement<String> getCompanyName() {
return companyName;
}
/**
* Sets the value of the companyName property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public void setCompanyName(JAXBElement<String> value) {
this.companyName = ((JAXBElement<String>) value);
}
/**
* Gets the value of the price property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public JAXBElement<String> getPrice() {
return price;
}
/**
* Sets the value of the price property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public void setPrice(JAXBElement<String> value) {
this.price = ((JAXBElement<String>) value);
}
/**
* Gets the value of the quantity property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public JAXBElement<String> getQuantity() {
return quantity;
}
/**
* Sets the value of the quantity property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public void setQuantity(JAXBElement<String> value) {
this.quantity = ((JAXBElement<String>) value);
}
/**
* Gets the value of the scripCode property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getScripCode() {
return scripCode;
}
/**
* Sets the value of the scripCode property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setScripCode(Integer value) {
this.scripCode = value;
}
}
我的問題是,我不知道如何綁定這些ArrayList<Holding>
爲JTable
- 我還沒有下過功夫上搖擺。
如果有人可以提供一個很好的教程的鏈接(除了Sun網站上的 - 我已經看到了),或者可以快速指導我如何實現一個TableModel
類,這將是一件好事。
我還必須在每隔5秒的時間間隔後從網絡服務獲取數據,因此還請提供描述如何重新綁定的教程。