In JavaFX how to add combobox with data in table view

两盒软妹~` 提交于 2019-12-02 10:39:12
Gaali Prabhakar

This is Just basic functionality . when you duble click on cell combobox will visible then you can select value.to see direct Combobox you have write own TableCell class see this you ll understand. I hope this will help you. any ?s post a comment

private void editable() {
    try {
        ObservableList<String> names = FXCollections.observableArrayList();
        ObservableList<Users> datas = FXCollections.observableArrayList();
        String sql = "select * from itemsadd";
        pst = gc.getConnection().prepareStatement(sql);
        rs = pst.executeQuery();
        while (rs.next()) {
            String name = rs.getString("itemcode");
            names.add(name);
            System.out.println("probs" + names);
        }
        ResultSet rs2 = gc.getConnection().createStatement()
                .executeQuery("SELECT * FROM itemsadd WHERE itemcode=1001");

        while (rs2.next()) {
            datas.add(new Users(rs2.getString("itemcode")));
        }
        c1.setCellValueFactory(new PropertyValueFactory("Itemc"));
        c1.setCellFactory(ComboBoxTableCell.forTableColumn(name));
        table.setEditable(true);
        table.getItems().clear();
        table.setItems(datas);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Error on Building Data");
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!