#7 Flowy
Díky ale nevím proč mi to pořád nefunguje (pořád prázdná tabulka jen s názvy sloupců)
mport javafx.beans.property.SimpleStringProperty;
public class DataModel {
private final SimpleStringProperty column1;
private final SimpleStringProperty column2;
private final SimpleStringProperty column3;
private final SimpleStringProperty column4;
private final SimpleStringProperty column5;
private final SimpleStringProperty column6;
private final SimpleStringProperty column7;
private final SimpleStringProperty column8;
private final SimpleStringProperty column9;
private final SimpleStringProperty column10;
public DataModel(SimpleStringProperty column1,
SimpleStringProperty column2, SimpleStringProperty column3,
SimpleStringProperty column4, SimpleStringProperty column5,
SimpleStringProperty column6, SimpleStringProperty column7,
SimpleStringProperty column8, SimpleStringProperty column9,
SimpleStringProperty column10) {
this.column1 = column1;
this.column2 = column2;
this.column3 = column3;
this.column4 = column4;
this.column5 = column5;
this.column6 = column6;
this.column7 = column7;
this.column8 = column8;
this.column9 = column9;
this.column10 = column10;
}
public SimpleStringProperty getColumn1() {
return column1;
}
public SimpleStringProperty getColumn2() {
return column2;
}
public SimpleStringProperty getColumn3() {
return column3;
}
public SimpleStringProperty getColumn4() {
return column4;
}
public SimpleStringProperty getColumn5() {
return column5;
}
public SimpleStringProperty getColumn6() {
return column6;
}
public SimpleStringProperty getColumn7() {
return column7;
}
public SimpleStringProperty getColumn8() {
return column8;
}
public SimpleStringProperty getColumn9() {
return column9;
}
public SimpleStringProperty getColumn10() {
return column10;
}
}
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFxTable extends Application {
private TableView<DataModel> tableView = new TableView<DataModel>();
final ObservableList<DataModel> data = FXCollections.observableArrayList(
new DataModel(new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1")),
new DataModel(new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1")),
new DataModel(new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"),new SimpleStringProperty("1"))
);
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void start(Stage primaryStage) {
Group root = new Group();
int widthOfColumn = 44;
TableColumn col1 = new TableColumn("col1");
col1.setMinWidth(widthOfColumn);
TableColumn col2 = new TableColumn("col2");
col2.setMinWidth(widthOfColumn);
TableColumn col3 = new TableColumn("col3");
col3.setMinWidth(widthOfColumn);
TableColumn col4 = new TableColumn("col4");
col4.setMinWidth(widthOfColumn);
TableColumn col5 = new TableColumn("col5");
col5.setMinWidth(widthOfColumn);
TableColumn col6 = new TableColumn("col6");
col6.setMinWidth(widthOfColumn);
TableColumn col7 = new TableColumn("col7");
col7.setMinWidth(widthOfColumn);
TableColumn col8 = new TableColumn("col8");
col8.setMinWidth(widthOfColumn);
TableColumn col9 = new TableColumn("col9");
col9.setMinWidth(widthOfColumn);
TableColumn col10 = new TableColumn("col10");
col10.setMinWidth(widthOfColumn);
tableView.setMaxSize(442, 420);
tableView.getColumns().addAll(col1,col2,col3,col4,col5,col6,col7,col8,col9,col10);
tableView.setItems(data);
VBox vBox = new VBox();
vBox.setSpacing(10);
vBox.getChildren().add(tableView);
root.getChildren().add(vBox);
primaryStage.setScene(new Scene(root, 500, 500));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}