List of usage examples for javafx.scene.control TableColumn TableColumn
public TableColumn(String text)
From source file:Main.java
private TableView<Person> createEmployeeTableView(ObservableList<Person> teamMembers) { final TableView<Person> employeeTableView = new TableView<>(); employeeTableView.setPrefWidth(300); employeeTableView.setItems(teamMembers); TableColumn<Person, String> aliasNameCol = new TableColumn<>("Alias"); TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name"); TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name"); aliasNameCol.setEditable(true);/*from w w w .j av a 2 s.com*/ aliasNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3); firstNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3); lastNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3); aliasNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("aliasName")); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName")); lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName")); employeeTableView.getColumns().setAll(aliasNameCol, firstNameCol, lastNameCol); return employeeTableView; }
From source file:org.pdfsam.ui.selection.multiple.LoadingStatusColumn.java
public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() { TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>( getColumnTitle());/* ww w .ja v a2s .c o m*/ tableColumn.setCellFactory(cellFactory()); tableColumn.setCellValueFactory(cellValueFactory()); tableColumn.setSortable(false); tableColumn.setMaxWidth(22); tableColumn.setMinWidth(22); return tableColumn; }
From source file:Main.java
@Override public void start(Stage stage) { Callback<TableColumn<Person, String>, TableCell<Person, String>> cellFactory = ( TableColumn<Person, String> p) -> new EditingCell(); Scene scene = new Scene(new Group()); stage.setWidth(450);// ww w .ja va2s . co m stage.setHeight(550); table.setEditable(true); TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); firstNameCol.setCellFactory(cellFactory); firstNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> { ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue()); }); TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:com.bdb.weather.display.summary.RainSummary.java
@SuppressWarnings("LeakingThisInConstructor") public RainSummary(SummaryInterval interval, SummarySupporter supporter) { this.setPrefSize(500, 300); this.interval = interval; this.supporter = supporter; dataTable = new TableView(); Node component = createChartElements(); TableColumn<SummaryRecord, String> col = new TableColumn<>("Date"); col.setCellValueFactory(//from w w w . java2 s .c o m (rec) -> new ReadOnlyStringWrapper(DisplayConstants.formatDate(rec.getValue().getDate()))); dataTable.getColumns().add(col); TableColumn<SummaryRecord, Depth> rainfallColumn = new TableColumn<>("Rainfall"); rainfallColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper(rec.getValue().getTotalRainfall())); dataTable.getColumns().add(rainfallColumn); TableColumn<SummaryRecord, Depth> etColumn = new TableColumn<>("ET"); etColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper(rec.getValue().getTotalET())); dataTable.getColumns().add(etColumn); this.setTabContents(component, dataTable); }
From source file:com.bdb.weather.display.windrose.WindRosePane.java
/** * Constructor.//from www .j a v a2 s. co m */ public WindRosePane() { this.setPrefSize(300, 300); ChartFactory.getChartTheme().apply(chart); chartViewer.setMinHeight(10); chartViewer.setMinWidth(10); chartViewer.setPrefSize(300, 300); dataTable = new TableView(); FlowPane summaryPanel = new FlowPane(); summaryPanel.getChildren().add(new LabeledFieldPane<>("Date:", timeField)); timeField.setEditable(false); summaryPanel.getChildren().add(new LabeledFieldPane<>("% Winds are calm:", calmField)); calmField.setEditable(false); summaryPanel.getChildren().add(new Label("Speeds are in " + Speed.getDefaultUnit())); BorderPane p = new BorderPane(); p.setCenter(dataTable); p.setTop(summaryPanel); this.setTabContents(chartViewer, p); TableColumn<WindSlice, String> headingColumn = new TableColumn<>("Heading"); headingColumn.setCellValueFactory((rec) -> new ReadOnlyStringWrapper( Heading.headingForSlice(rec.getValue().getHeadingIndex(), 16).getCompassLabel())); dataTable.getColumns().add(headingColumn); TableColumn<WindSlice, String> percentOfWindColumn = new TableColumn<>("% of Wind"); percentOfWindColumn.setCellValueFactory( (rec) -> new ReadOnlyStringWrapper(String.format("%.1f", rec.getValue().getPercentageOfWind()))); dataTable.getColumns().add(percentOfWindColumn); TableColumn<WindSlice, Speed> avgSpeedColumn = new TableColumn<>("Avg Speed"); avgSpeedColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper<>(rec.getValue().getAvgSpeed())); dataTable.getColumns().add(avgSpeedColumn); TableColumn<WindSlice, Speed> maxSpeedColumn = new TableColumn<>("Max Speed"); maxSpeedColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper<>(rec.getValue().getMaxSpeed())); dataTable.getColumns().add(maxSpeedColumn); }
From source file:analyzer.code.FXMLAnalyzerController.java
@FXML private void calculateMetricButtonAction(ActionEvent event) { List<String> nameFiles = nameFile; ArrayList<List<String>> metrs; if (curLang == C) { analyzer.setMetricSettings(metricSettings.get(curLang)); }// w w w. jav a2 s.c o m //?? ? for (String src : source) { analyzer.solutMetrics(src); } // metrs = analyzer.getResult(); //? ?? nameFile.add(" "); // tableMetric.refresh(); tableMetric.getItems().clear(); tableMetric.getColumns().clear(); tableDescript.refresh(); tableDescript.getItems().clear(); tableDescript.getColumns().clear(); //? ? for (int i = 0; i < source.size() + 1; i++) { tableMetric.getItems().add(i); tableDescript.getItems().add(i); } //? ? ? TableColumn<Integer, String> nameFl = new TableColumn<>("Name File"); nameFl.setCellValueFactory(cellData -> { Integer rowIndex = cellData.getValue(); return new ReadOnlyStringWrapper(nameFiles.get(rowIndex)); }); tableMetric.getColumns().add(nameFl); //? ? // ? ? EnumNameMetricC[] enumName = EnumNameMetricC.values(); for (int i = 0; i < metrs.size(); i++) { List<String> list = metrs.get(i); TableColumn<Integer, String> nameColumn = new TableColumn<>(enumName[i].getName()); nameColumn.setCellValueFactory(cellData -> { Integer rowIndex = cellData.getValue(); return new ReadOnlyStringWrapper(list.get(rowIndex)); }); tableMetric.getColumns().add(nameColumn); } if (curLang == C) { tableDescript.getColumns().add(nameFl); TableColumn<Integer, String> columnDesc = new TableColumn<>("Count Operators"); columnDesc.setCellValueFactory(cellData -> { Integer rowIndex = cellData.getValue(); return new ReadOnlyStringWrapper(CountOperators.getMark(metricSettings.get(curLang).get(0).getMin(), metricSettings.get(curLang).get(0).getMax(), Double.valueOf(metrs.get(0).get(rowIndex)))); }); tableDescript.getColumns().add(columnDesc); TableColumn<Integer, String> columnDesc1 = new TableColumn<>("Level Nest"); columnDesc1.setCellValueFactory(cellData -> { Integer rowIndex = cellData.getValue(); return new ReadOnlyStringWrapper(LevelNesting.getMark(metricSettings.get(curLang).get(1).getMin(), metricSettings.get(curLang).get(1).getMax(), Double.valueOf(metrs.get(1).get(rowIndex)))); }); tableDescript.getColumns().add(columnDesc1); TableColumn<Integer, String> columnDesc2 = new TableColumn<>("Middle Len Ident"); columnDesc2.setCellValueFactory(cellData -> { Integer rowIndex = cellData.getValue(); return new ReadOnlyStringWrapper(MiddleLenIdent.getMark(metricSettings.get(curLang).get(2).getMin(), metricSettings.get(curLang).get(2).getMax(), Double.valueOf(metrs.get(2).get(rowIndex)))); }); tableDescript.getColumns().add(columnDesc2); double mark = analyzer.getMark(); labelMark.setText(": " + String.format(Locale.US, "%.2f", mark) + " 5"); labelMark.setVisible(true); } }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("java-buddy.blogspot.com"); tableView.setEditable(true);/* ww w . j a va 2 s .c o m*/ Callback<TableColumn, TableCell> cellFactory = new Callback<TableColumn, TableCell>() { @Override public TableCell call(TableColumn p) { return new EditingCell(); } }; btnNew.setOnAction(btnNewHandler); //init table //Un-editable column of "id" TableColumn col_id = new TableColumn("ID"); tableView.getColumns().add(col_id); col_id.setCellValueFactory(new PropertyValueFactory<Record, String>("id")); //Editable columns for (int i = 0; i < Day.length; i++) { TableColumn col = new TableColumn(Day[i]); col.setCellValueFactory(new PropertyValueFactory<Record, String>("value_" + String.valueOf(i))); tableView.getColumns().add(col); col.setCellFactory(cellFactory); } tableView.setItems(data); Group root = new Group(); VBox vBox = new VBox(); vBox.setSpacing(10); vBox.getChildren().addAll(btnNew, tableView); root.getChildren().add(vBox); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
From source file:org.pdfsam.ui.selection.multiple.LoadingColumn.java
@Override public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() { TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>( getColumnTitle());// w ww . j av a2 s .c o m tableColumn.setCellFactory(cellFactory()); tableColumn.setCellValueFactory(cellValueFactory()); tableColumn.setComparator(null); tableColumn.setSortable(false); tableColumn.setMaxWidth(26); tableColumn.setMinWidth(26); return tableColumn; }
From source file:context.ui.control.tabular.TabularViewController.java
private void initialTableData() { data.loadTableData();/* w w w . j av a 2 s .c o m*/ // double minWidth = tableView.getWidth() / data.getHeaders().size(); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); int index = 0; for (String header : data.getHeaders()) { final int j = index; TableColumn tableColumn = new TableColumn(header); tableColumn.setComparator(new Comparator<String>() { @Override public int compare(String s1, String s2) { if (NumberUtils.isNumber(s1) && NumberUtils.isNumber(s2)) { return Double.compare(Double.parseDouble(s1), Double.parseDouble(s2)); } return Collator.getInstance().compare(s1, s2); } }); tableColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<List<String>, String>, ObservableValue<String>>() { public ObservableValue<String> call(TableColumn.CellDataFeatures<List<String>, String> p) { final String val = p.getValue().get(j); if (isRoundDoubles() && NumberUtils.isNumber(val) && val.contains(".")) { DecimalFormat df = new DecimalFormat("#.##"); Double d = Double.parseDouble(val); return new SimpleStringProperty(df.format(d)); } else { return new SimpleStringProperty(val); } } }); index++; tableView.getColumns().add(tableColumn); // if (index < data.getHeaders().size() - 1) { // tableColumn.setMinWidth(minWidth); // } // System.out.println("width=" + tableColumn.getMinWidth()); } System.out.println("columns Count:" + tableView.getColumns().size()); // which will make your table view dynamic // ObservableList<ObservableList> csvData = FXCollections.observableArrayList(); // // for (List<StringProperty> dataList : data.getRows()) { // ObservableList<String> row = FXCollections.observableArrayList(); // for (StringProperty rowData : dataList) { // row.add(rowData.get()); // } // csvData.add(row); // add each row to cvsData // } System.out.println("Rows Count=" + data.getRows().size()); tableView.setItems(data.getRows()); // finally add data to tableview System.out.println("after Rows Count=" + tableView.getItems().size()); }
From source file:com.ggvaidya.scinames.summary.HigherStabilityView.java
private TableColumn<String, String> createTableColumn(String colName, Function<String, String> func) { TableColumn<String, String> tableColumn = new TableColumn<>(colName); tableColumn.setCellValueFactory(features -> new ReadOnlyStringWrapper(func.apply(features.getValue()))); tableColumn.setPrefWidth(100.0);//w w w. j a va 2 s. c om return tableColumn; }