2016-07-05 1 views
0

データベースからフェッチされたレコードごとにコンボボックスを表示しようとしていますが、期待した列にコンボボックスが見つかりません。ここでjavafxアプリケーションでComboboxTableCellを取得できません

は私のモデルクラスのコードです:ここで

public class Employee { 
    private final int id; 
    private final SimpleStringProperty ename; 
    private final SimpleStringProperty ecnic; 
    private final SimpleDoubleProperty ebalance; 
    private final SimpleDoubleProperty etotalpaid; 
    private SimpleStringProperty estatus; 
    public Employee(int id, String ename, String ecnic, Double ebalance, 
      Double etotalpaid, String estatus) { 
     super(); 
     this.id = id; 
     this.ename = new SimpleStringProperty(ename); 
     this.ecnic = new SimpleStringProperty(ecnic); 
     this.ebalance = new SimpleDoubleProperty(ebalance); 
     this.etotalpaid = new SimpleDoubleProperty(etotalpaid); 
     this.estatus = new SimpleStringProperty(estatus); 
    } 
    public String getEstatusproperty() { 
     return estatus.get(); 
    } 
    public String getEstatus() { 
     return estatus.get(); 
    } 
    public void setEstatus(String estatus) { 
     this.estatus = new SimpleStringProperty(estatus); 
    } 
    public int getId() { 
     return id; 
    } 
    public String getEname() { 
     return ename.get(); 
    } 
    public String getEcnic() { 
     return ecnic.get(); 
    } 
    public Double getEbalance() { 
     return ebalance.get(); 
    } 
    public Double getEtotalpaid() { 
     return etotalpaid.get(); 
    } 
} 

public void attendence() throws SQLException{ 
     employeelist = FXCollections.observableArrayList(); 
     ename.setCellValueFactory(new PropertyValueFactory<Employee,String>("ename")); 
     ecnic.setCellValueFactory(new PropertyValueFactory<Employee,String>("ecnic")); 
     ebalance.setCellValueFactory(new PropertyValueFactory<Employee,Double>("ebalance")); 
     etotalpaid.setCellValueFactory(new PropertyValueFactory<Employee,Double>("etotalpaid")); 
     estatus.setCellValueFactory(new PropertyValueFactory<Employee,String>("estatus")); 
     estatus.setCellFactory(ComboBoxTableCell.forTableColumn(new DefaultStringConverter(), attendenceoptions)); 
     estatus.setOnEditCommit(
       new EventHandler<CellEditEvent<Employee, String>>() { 
        @Override 
        public void handle(CellEditEvent<Employee, String> t) { 
         ((Employee) t.getTableView().getItems().get(t.getTablePosition().getRow())).setEstatus(t.getNewValue()); 
        }; 
     }); 
     estatus.setEditable(true); 
     stmt = conn.createStatement(); 
     sql = "select * from employe"; 
     rs = stmt.executeQuery(sql); 
     while(rs.next()){ 
      employeelist.add(new Employee(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getDouble(5),rs.getDouble(6),"Present")); 
      employeetable.setItems(employeelist); 
     } 
     stmt.close(); 
     rs.close(); 
    } 
} 
+0

表ビューと表の両方の列は編集できますか? – Itai

+0

ComboBoxは、値の編集を開始したときにのみ表示されることに注意してください。 –

+0

私のテーブルは編集可能に設定されていませんでした。私はそれを編集可能に設定しました。 –

答えて

0

は、問題を解決するための方法でこれを追加しました..私は、データベースからデータをフェッチするために呼び出す私のメソッドのコードです。

employeetable.setEditable(true); 
関連する問題