2017-01-04 48 views
-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。但是我的问题是关于图像。

回答

0

我认为你应该使用jeditorPane并使用html在其中显示图像