Hope I will get my question as clear as possible. I am working on a small java application using the JavaFX library for the gui. am doing a POP Connection and storing Messages as ObservableList. For this I am using javax.mail. I am passing this observablelist to a tableview and with the following i am passing the required values to the TableColumns:
fromColumn.setCellValueFactory(
new PropertyValueFactory<Message,String>("from")
);
subjectColumn.setCellValueFactory(
new PropertyValueFactory<Message,String>("subject")
);
dateColumn.setCellValueFactory(
new PropertyValueFactory<Message,String>("sentDate")
);
Subject and sentDate are beeing read-in perfectly. But unfortunately “from” is adding object-references to TableColumn, since the From-Attribute in the Message-Class is a InternetAdress-Object and its toString()-method isnt returning a string but probably a reference. And the result is the follwoing being shown in fromColumn:
[Ljavax.mail.internet.InternetAddress;@3596cd38
Anybody knows the solution how I could get the String-Value of the InternetAdress being showed in the mentioned Column?
Thanks in Advance
I think you need to define a custom cell value factory to get at the address information in the format you need rather than using the PropertyValueFactory.
The following sample is for a read only table – if the message data in the table needs to be editable, then the solution will be significantly more complicated.
Here is an executable sample (plus sample data files) which demonstrate use of the custom cell value factory. Place the sample data files in the same directory as the application java program and ensure your build system copies the sample files to the build output directory which contains the compiled class file for the application. You will need the javamail jar files on your path to compile and run the application.
msg_1.txt
msg_2.txt
msg_3.txt
Sample program output:
