TableView上的内容未显示

时间:2018-11-06 00:56:49

标签: java javafx tableview

我几天来一直遇到这个问题,但仍然无法解决。 所以我有这个TableView,我要在其中插入没有字符串属性或SimpleStringProperty的Person对象。到目前为止,我已经获得了名称,姓氏,操作和车牌(用于一个项目),但是我无法显示财务代码,因此我无法尝试所有操作。

这是代码(很抱歉,它是意大利语,希望您能收到):

     public static void Vedi() throws IOException
      {

         ArrayList<String> nomefile = new ArrayList<String>();
         nomefile.addAll(CreazioneFile.VediFileClienti());
         Stage stage = new Stage();
         TableView<ClienteRecord> table = new TableView<ClienteRecord>();
            table.setEditable(true);

            TableColumn<ClienteRecord,String> nomecol = new TableColumn<ClienteRecord,String>("Nome");
            nomecol.setCellValueFactory(new PropertyValueFactory<ClienteRecord,String> ("nome"));
            TableColumn<ClienteRecord,String> cognomecol = new TableColumn<ClienteRecord,String>("Cognome");
            cognomecol.setCellValueFactory(new PropertyValueFactory<ClienteRecord,String> ("cognome"));
            TableColumn<ClienteRecord,String> codicefiscalecol = new TableColumn<ClienteRecord,String>("Codice Fiscale");
            codicefiscalecol.setCellValueFactory(new PropertyValueFactory<ClienteRecord,String> ("CF"));
            TableColumn<ClienteRecord,String> interventicol = new TableColumn<ClienteRecord,String>("Interventi");
            interventicol.setCellValueFactory(new PropertyValueFactory<ClienteRecord,String> ("NumInt"));
            TableColumn<ClienteRecord,String> targaautocol = new TableColumn<ClienteRecord,String>("Targa");
            targaautocol.setCellValueFactory(new PropertyValueFactory<ClienteRecord,String> ("Targa"));
            codicefiscalecol.prefWidthProperty().bind(table.widthProperty().multiply(0.4));
            table.getColumns().addAll(nomecol, cognomecol, codicefiscalecol,interventicol,targaautocol);
            String nome = "C:\\\\Users\\\\Documents\\\\Compito\\\\Clienti\\\\";
           ArrayList<ClienteRecord> List = new ArrayList<ClienteRecord>();
            for (int i=0; i<nomefile.size();i++)
            {
                 LeggiFile.apriFile(nome+nomefile.get(i));
          List.add(LeggiFile.leggiRecord());
           System.out.println(List);
           System.out.println(List.get(i).getcf());
            ObservableList<ClienteRecord> data = FXCollections.observableArrayList(List);

            table.setItems(data);

            }
            LeggiFile.ChiudiFile();


            StackPane root = new StackPane();
            root.getChildren().add(table);

            Scene scene = new Scene (root,600,400);
            stage.setScene(scene);
            stage.setTitle("Vedi Clienti");
            stage.show();
      }

这是输出:

enter image description here

如您所见,会计代码已在记录中,但未显示。

0 个答案:

没有答案