title: Default Table Model in JavaFX
body: <p>I have encountered some problem when trying to select single row from table view in JavaFX.</p>
  
  <p>Here is how I populate my table with data from database:</p>
  
  <pre><code>public void populateCategoryTable() {
      data = FXCollections.observableArrayList();
      try {
          db.getConnection();
          String sql = "SELECT * FROM sm_category";
          ResultSet rs = null;
          // Call readRequest to get the result
          rs = db.readRequest(sql);
  
          while (rs.next()) {
              ObservableList&lt;String&gt; row = FXCollections.observableArrayList();
              //All the rows are added here dynamically 
              row.add(rs.getString("categoryID"));
              data.add(row);
          }
          viewCategory.setItems(data);
          rs.close();
      } catch (SQLException ex) {
          ex.printStackTrace();
          System.out.println("Error SQL!!!");
          System.exit(0);
      }
  
      TableColumn id = new TableColumn("ID");
      id.setVisible(false);
      id.setCellValueFactory(new Callback&lt;TableColumn.CellDataFeatures&lt;ObservableList, String&gt;, ObservableValue&lt;String&gt;&gt;() {
          public ObservableValue&lt;String&gt; call(TableColumn.CellDataFeatures&lt;ObservableList, String&gt; param) {
              return new SimpleStringProperty(param.getValue().get(0).toString());
          }
      });
  
      viewCategory.getColumns().addAll(id);
  
      TableView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Error here
      TableView.TableViewSelectionModel selectionModel = viewCategory.getSelectionModel();
      ObservableList selectedCells = selectionModel.getSelectedCells();
      TablePosition tablePosition = (TablePosition) selectedCells.get(0);
      int row = tablePosition.getRow(); // yields the row that the currently selected cell is in
  
  }
  </code></pre>
  
  <p>However, when I tried to insert the setSelectionMode code, there is an error. It tells me that <strong>cannot find symbol
    symbol:   method setSelectionMode(int)
    location: class TableView</strong></p>
  
  <p>I remember when I did table in JavaSwing, I used this to set a model for table: DefaultTableModel tableModel = (DefaultTableModel) jTable.getModel();</p>
  
  <p>However, I cannot do this in javaFX. Anybody could help me fix this?</p>
  
  <p>Thanks in advance.</p>