-2
我需要幫助才能將圖像顯示到表格列。我有一個程序會詢問用戶(組織)的輸入,其中一個是上傳圖像。一旦他們上傳他們的圖片,URL將根據他們所填寫的其他細節被保存到一個文件,這是模型組織(組織)的數據代碼的一部分:如何從本地URL在表格列中顯示圖像?
final static ObservableList<OrgData> data = FXCollections.observableArrayList();
public OrgData(String email, String pw, String name, String contact, String address, String type,
String desc,String status,String url) {
super();
this.email = email;
this.pw = pw;
this.name = name;
this.contact = contact;
this.address = address;
this.type = type;
this.desc = desc;
this.status=status;
this.url=url;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPw() {
return pw;
}
public void setPw(String pw) {
this.pw = pw;
}
public String getPw2() {
return pw2;
}
public void setPw2(String pw2) {
this.pw2 = pw2;
}
public String getName() {
return name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public void setName(String name) {
this.name = name;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String toString(){
return email+","+pw+","+name+","+contact+","+address+","+type+","+desc+","+status+","+url;
}
這是部分在文件中保存數據的代碼:
String Type = ""+type;
System.out.println(Type);
String Desc = desc.getText();
String url = imageURL;
url = url.substring(6,url.length());
System.out.println(url);
InputStream d = new FileInputStream(new File(url));
url=output(d);
System.out.println(url);
OrgData table = new OrgData(Email,Password,Name, Contact,Address,Type,Desc,null,url);
OrgDataDAO dao = new OrgDataDAO();
dao.createOrg(table);
}
我能夠做的代碼,因爲他們將在表中顯示的字符串,這些線可以查看其他數據,但我不希望顯示的網址但圖片:
//data in table
OrgDataDAO dao=new OrgDataDAO();
data = dao.getAllOrg();
//List Of table column
email.setCellValueFactory(new PropertyValueFactory<OrgData, String>("email"));
Orgname.setCellValueFactory(new PropertyValueFactory<OrgData, String>("name"));
contact.setCellValueFactory(new PropertyValueFactory<OrgData, String>("contact"));
address.setCellValueFactory(new PropertyValueFactory<OrgData, String>("address"));
category.setCellValueFactory(new PropertyValueFactory<OrgData, String>("type"));
description.setCellValueFactory(new PropertyValueFactory<OrgData, String>("desc"));
//displaying pic from url code here
pic.setCellValueFactory(new PropertyValueFactory<OrgData, ImageView>("url"));
status.setCellValueFactory(new PropertyValueFactory<>("DUMMY"));
注意它說pic.setCellValue ....代碼行將只顯示圖像的URL從文件中的數據,而不是圖像本身,所以我需要改變以顯示圖像的桌子?由於在該列中將存在單選按鈕,因此可以忽略DUMMY。但是我的問題是關於圖像。