为什么日期不显示在Tableview javafx中?

时间:2018-12-16 21:32:14

标签: javafx tableview localdate

我的问题是,当我编译代码时,日期列为空。我无法在任何网站上找到解决方案。代码在下面。我认为应该缺少该程序的fxml文件。我使用的编译器是Eclipse Photon Release(4.8.0)

fetch('mydata.zip').then(function(response) {
  return response.arrayBuffer();
}).then(function(zipData) {
  var Buffer = BrowserFS.BFSRequire('buffer').Buffer;

  BrowserFS.configure({
    fs: "MountableFileSystem",
    options: {
      "/zip": {
        fs: "ZipFS",
        options: {
          // Wrap as Buffer object.
          zipData: Buffer.from(zipData)
        }
      },
      "/tmp": { fs: "InMemory" },
      "/home": { fs: "IndexedDB" }
    }
  }, function(e) {
    if (e) {
      // An error occurred.
      throw e;
    }
    // Otherwise, BrowserFS is ready to use!
  });
});

下面是管理数据的代码:

import java.time.LocalDate;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;

import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class TableViewTest extends Application {

    private TableView<Conteudo> table = new TableView<Conteudo>();
    private final ObservableList<Conteudo> data = FXCollections.observableArrayList(new Conteudo(LocalDate.now(),"2","teste"),
            new Conteudo(LocalDate.of(2018, 1, 2), "3","teste2"));

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setTitle("Table View Sample");
        stage.setWidth(450);
        stage.setHeight(500);

        final Label label = new Label("Address Book");
        label.setFont(new Font("Arial", 20));

        table.setEditable(true);

        TableColumn<Conteudo, String> dataCol = new TableColumn<Conteudo, String>("DATA");
        dataCol.setMinWidth(100);
        dataCol.setCellValueFactory(new PropertyValueFactory<>("data"));

        TableColumn aulaCol = new TableColumn("AULAS");
        aulaCol.setMinWidth(100);
        aulaCol.setCellValueFactory(
                new PropertyValueFactory<Conteudo, String>("aula"));

        TableColumn conteudoCol = new TableColumn("CONTEUDOS");
        conteudoCol.setMinWidth(200);
        conteudoCol.setCellValueFactory(
                new PropertyValueFactory<Conteudo, String>("conteudo"));

        table.setItems(data);
        table.getColumns().addAll(dataCol, aulaCol, conteudoCol);

        final VBox vbox = new VBox();
        vbox.setSpacing(5);
        vbox.setPadding(new Insets(10, 0, 0, 10));
        vbox.getChildren().addAll(label, table);

        ((Group) scene.getRoot()).getChildren().addAll(vbox);

        stage.setScene(scene);
        stage.show();
    }
}

0 个答案:

没有答案