Captain Prinny
Captain Prinny

Reputation: 469

JavaFX: TableViewCol set editable does not allow editting

I have an editable table and I've cloned that code to another pane and it will not let me edit it.

  <TableView fx:id="queueTable" layoutX="5.0" layoutY="388.0" prefHeight="200.0" prefWidth="406.0">
    <columns>
      <TableColumn fx:id="materialCol" editable="false" prefWidth="224.0" text="Material">
            <cellFactory>
                <TextFieldTableCell fx:factory="forTableColumn" />
            </cellFactory>
                <cellValueFactory>
            <PropertyValueFactory property="symbol" />
                </cellValueFactory>
      </TableColumn>
      <TableColumn fx:id="sourceCol" editable="false" prefWidth="111.0" text="Source">
            <cellFactory>
                <TextFieldTableCell fx:factory="forTableColumn" />
            </cellFactory>                
            <cellValueFactory>
                <PropertyValueFactory property="weight" />
            </cellValueFactory>
        </TableColumn>
      <TableColumn fx:id="indexCol" prefWidth="70.0" text="Index">
            <cellFactory>
              <TextFieldTableCell fx:factory="forTableColumn" />
            </cellFactory>                
            <cellValueFactory>
              <PropertyValueFactory property="atom" />
            </cellValueFactory>
      </TableColumn>   
    </columns>
  </TableView>

When double clicking on the table cell, nothing happens to indicate that I've done anything, and I'm not sure how to diagnose this, because the table code works elsewhere in the same program. The only difference here being that the other table is fully editable, and this table only only column should be.

The intent is to allow the "index" value to be changed by the user, and the rest of the information static.

Upvotes: 0

Views: 365

Answers (1)

James_D
James_D

Reputation: 209225

TableView is not editable by default, so you need

 <TableView fx:id="queueTable" editable="true" layoutX="5.0" layoutY="388.0" prefHeight="200.0" prefWidth="406.0">

With everything else as it is, this will make indexCol editable and the other two columns not editable.

Upvotes: 1

Related Questions