Using JavaFx 2 and Netbeans IDE 8.0 with Java 8.
I am extracting data from a FileMaker
database and adding it as a "Ticket" object to an observableArrayList
(called "row" here). I am then passing that list to the table to show what has been found.
I have the observableArrayList
populated, but I cannot get it to display in the table.
I have my table view built in FXML:
<TableView fx:id="ticketData" layoutX="-3.0" layoutY="351.0" prefHeight="203.0" prefWidth="554.0">
<columns>
<TableColumn fx:id="ticket" editable="false" prefWidth="59.0" text="Ticket" />
<TableColumn fx:id="dates" prefWidth="72.0" text="Date(s)" />
<TableColumn fx:id="files" editable="false" prefWidth="114.0" text="File(s) Found" />
<TableColumn fx:id="notes" prefWidth="297.0" text="Notes" />
</columns>
</TableView>
My Java Class that has my setters/getters, etc:
public class Ticket
{
private SimpleStringProperty ticketType;
private SimpleObjectProperty<Date> executionDate;
private SimpleBooleanProperty gotFile;
private SimpleStringProperty statusMessage;
public Ticket(String tt, Date done, boolean gf, String stat)
{
this.ticketType = new SimpleStringProperty (tt);
this.executionDate = new SimpleObjectProperty<Date>(done) {};
this.gotFile = new SimpleBooleanProperty(gf);
this.statusMessage = new SimpleStringProperty(stat);
}
public String getTicketType() {
return ticketType.get();
}
public void setTicketType(String tt) {
ticketProperty().set(tt);
}
public StringProperty ticketProperty() {
if (ticketType == null) ticketType = new SimpleStringProperty(this, "ticketType");
return ticketType;
}
public Date getExecutionDate() {
return executionDate.get();
}
public void setExecutionDate(Date done) {
executionDate.set(done);
}
public SimpleObjectProperty dateProperty() {
if (executionDate == null) executionDate = new SimpleObjectProperty(this, "executionDate");
return executionDate;
}
public boolean getGotFile(){
return gotFile.get();
}
public void setGotFile(boolean gf){
gotFile.set(gf);
}
public SimpleBooleanProperty gotProperty() {
if (gotFile == null) gotFile = new SimpleBooleanProperty(this, "gotFile");
return gotFile;
}
public String getStatusMessage() {
return statusMessage.get();
}
public void setStatusMessage(String stat) {
statusMessage.set(stat);
}
public StringProperty statusProperty() {
if (statusMessage == null) statusMessage = new SimpleStringProperty(this, "statusMessage");
return statusMessage;
}
}
Method used to gather the resultset
data I need from FileMaker
:
public void accumulate(String type, Date essential, boolean got, String msg)
{
Ticket ticket;
ticket = new Ticket(type, essential, got, msg);
row.add(ticket);
}
After I've completed my search for what I need I then in my controller, set my tableview
("ticketData" here), to hold the items, with each column having a CellValueFactory
that correlates to the Ticket class.
ticketData = new TableView();
ticket.setCellFactory(TextFieldTableCell.forTableColumn());
ticket.setCellValueFactory(
new PropertyValueFactory<>("ticketType"));
dates.setCellFactory(TextFieldTableCell.forTableColumn());
dates.setCellValueFactory(
new PropertyValueFactory<>("executionDate"));
files.setCellFactory(TextFieldTableCell.forTableColumn());
files.setCellValueFactory(
new PropertyValueFactory<>("gotFile"));
notes.setCellFactory(TextFieldTableCell.forTableColumn());
notes.setCellValueFactory(
new PropertyValueFactory<>("statusMessage"));
ticketData.getColumns().addAll(ticket,dates,files,notes);
//System.out.println(Arrays.deepToString(row.toArray()));
ticketData.setItems(row);
I can do a print on the observableArrayList
and see the entries in it, but the tableview
remains blank.
Any suggestions? Have I missed something? I'm at a loss.