我需要帮助将图像显示到表格列。我有一个程序会询问用户(组织)的输入,其中一个是上传图像。上传图像后,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);
}
我可以通过这些代码行来查看其他数据,因为它们会在表格中显示字符串,但我不想显示URL而是显示图像:
//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。但我遇到的问题是关于图像。
答案 0 :(得分:0)
我认为您应该使用jeditorPane并使用html
在其中显示图像