JSON data in JavaFx tableview


Question

I am developing application in javaFX .I want to show json response in the tableview. I am not gettting how to do it

My files are as follows:

projects.fxml

<TableView fx:id="mytableTableView" layoutX="384.0" layoutY="54.0" prefHeight="210.0"     prefWidth="202.0" tableMenuButtonVisible="true">
  <columns>
    <TableColumn prefWidth="75.0" text="ID" fx:id="idColumn" />
    <TableColumn prefWidth="75.0" text="Name" fx:id="nameColumn" />
    <TableColumn prefWidth="75.0" text="Identifier" fx:id="identifierColumn" />
    <TableColumn prefWidth="75.0" text="Description" fx:id="descriptionColumn" />
    <TableColumn prefWidth="75.0" text="CreatedOn" fx:id="created_onColumn" />
  </columns>
</TableView>

project controller

@FXML
TableView<ProjectProperties> mytableTableView;
@FXML TableColumn<ProjectProperties,Integer> idColumn;
@FXML TableColumn<ProjectProperties,String> nameColumn;
@FXML TableColumn<ProjectProperties,String> identifierColumn;
@FXML TableColumn<ProjectProperties,String> descriptionColumn;
@FXML TableColumn<ProjectProperties,String> created_onColumn;


 public void initialize(URL url, ResourceBundle rb)
   {
 String responseJSON = HttpManager.getData(url, null);

  }

I get json response in responseJSON that I want to show in the table view.

I am not getting how to bind the json to the table view .

It is possible for me to convert json to the array.

But the setItems() method of tableview require the ObservableList .

So any suggesstions and example will be greately appriciated.

1
0
2/7/2013 5:33:04 AM

I think you can use the DataFx project which have method to feed your dataview with JSON : http://www.javafxdata.org/content/data-sources/

Another source using DataFx with Rest remote source : http://fxapps.blogspot.fr/2012/04/fetching-rest-data-sources-with-datafx.html

2
2/7/2013 1:57:15 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon