javaFx表只填充1个TableCollumn

时间:2017-07-25 21:36:52

标签: java javafx tableview fxml tablecolumn

场景/舞台在主要课堂上建立起来。我使用fxml进行设计并用控制器填充它。只是"名称"得到满满的"输入"是空的。

项目(名称,类型 的控制器:

imports...
public class Controller implements Initializable{

@FXML private TableView<Project> tabelle;
@FXML private TableColumn<Project,String> name;
@FXML private TableColumn<Project,String> type;

public void initialize(URL location, ResourceBundle resources) {
    type.setCellValueFactory(new PropertyValueFactory<Project, String>("type"));
    name.setCellValueFactory(new PropertyValueFactory<Project, String>("name"));


    tabelle.getItems().setAll(parseList());
}

protected List<Project> parseList(){
    List<DiaryEntry> lisz = entries.ent();
    List<Project> data =
            FXCollections.observableArrayList(

                    new Project("gw2","private"),
                    new Project("menu","private"),
                    new Project("gw2","internal"),
                    new Project("dance","internal")
            );
    return data;
}

FXML:

<VBox fx:id="a" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="800.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller">
<children>
    <TableView fx:id="tabelle" editable="true" layoutY="99.0" prefHeight="701.0" prefWidth="470.0">
     <columns>
        <TableColumn fx:id="name" prefWidth="150.0" text="CDNA" />
        <TableColumn fx:id="type" prefWidth="150.0" text="Type" />
     </columns></TableView>
</children>

,这是表:http://imgur.com/a/BYZV6(正常的javafx表,但只是&#34; NAME&#34;已填写) PROJECT:已更新

import java.util.Objects;

public class Project {

private String name;
private String type;

public Project(String name, String type) {
    this.name = name;
    this.type = type;
}

public String getName() {
    return name;
}

public boolean isInternal() {
    return "internal".equals(type);
}

@Override
public boolean equals(Object obj) {
    if (obj instanceof Project) {
        Project that = (Project) obj;
        return Objects.equals(name, that.name) && Objects.equals(type, that.type);
    }
    return false;
}

@Override
public int hashCode() {
    return Objects.hash(name, type);
}

}

0 个答案:

没有答案