本文整理汇总了Java中javafx.scene.control.TableColumn.setCellValueFactory方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setCellValueFactory方法的具体用法?Java TableColumn.setCellValueFactory怎么用?Java TableColumn.setCellValueFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setCellValueFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChoiceBoxColumnName
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
TableColumn column = new TableColumn(name);
column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
ObservableList list = FXCollections.observableArrayList();
if(items!=null) list.addAll(items.getList());
column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
column.setOnEditCommit( t -> {
int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
});
columnMap.put(name, column);
return column;
}
示例2: TableSample
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public TableSample() {
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]" ),
new Person("Isabella", "Johnson", "[email protected]" ),
new Person("Ethan", "Williams", "[email protected]" ),
new Person("Emma", "Jones", "[email protected]" ),
new Person("Michael", "Brown", "[email protected]" )
);
TableColumn firstNameCol = new TableColumn();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn lastNameCol = new TableColumn();
lastNameCol.setText("Last");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn emailCol = new TableColumn();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableView tableView = new TableView();
tableView.setItems(data);
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
示例3: start
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getLayout("server.fxml"));
StackPane root = new StackPane();
root.getChildren().add((Node)loader.load());
s = new Scene(root, 800, 480);
primaryStage.setScene(s);
primaryStage.show();
this.primaryStage = primaryStage;
this.table = (TableView<TX>) s.lookup("#table");
this.model = FXCollections.observableArrayList();
this.table.setItems(model);
ObservableList<TableColumn<TX, ?>> cols = this.table.getColumns();
TableColumn<TX, Integer> id = (TableColumn<TX, Integer>)cols.get(0);
id.setCellValueFactory(cellData -> cellData.getValue().id.asObject());
TableColumn<TX, String> pin = (TableColumn<TX, String>)cols.get(1);
pin.setCellValueFactory(cellData -> cellData.getValue().pin);
TableColumn<TX, String> desc = (TableColumn<TX, String>)cols.get(2);
desc.setCellValueFactory(cellData -> cellData.getValue().desc);
TableColumn<TX, String> status = (TableColumn<TX, String>)cols.get(3);
status.setCellValueFactory(cellData -> cellData.getValue().status);
TableColumn<TX, String> amount = (TableColumn<TX, String>)cols.get(4);
amount.setCellValueFactory(cellData -> cellData.getValue().amount);
TableColumn<TX, Long> time = (TableColumn<TX, Long>)cols.get(5);
time.setCellValueFactory(cellData -> cellData.getValue().timeFilled.asObject());
primaryStage.setOnCloseRequest((WindowEvent event) -> System.exit(0));
onRequestReceived(-1, "Test TX", new BigDecimal(1));
CryptoServer server = new CryptoServer(location, this);
Thread t = new Thread(server);
t.start();
}
示例4: JavaDialog
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public JavaDialog() {
super(JavaUtil.getAvailableInstalls());
TableColumn<JavaUtil.JavaInstall, String> paths = new TableColumn<>("Paths");
paths.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().path));
table.getColumns().addAll(paths);
setTitle("Java Detection");
dialogPane.setHeaderText("Please Choose a Java Version");
dialogPane.getStyleClass().add("java-dialog");
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
}
示例5: reload
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void reload() {
tabs.getTabs().clear();
for (Path path: PathController.getItems()) {
// create one tab per path
VBox container = new VBox(8);
container.setPadding(new Insets(20));
Text header = new Text("" + path.getMailman());
TableView<Path.PathStep> pathTable = new TableView<Path.PathStep>();
pathTable.setItems(FXCollections.observableList(path.getSteps()));
TableColumn<Path.PathStep, String> shipmentCol = new TableColumn<Path.PathStep, String>("Envois");
shipmentCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("shipment"));
TableColumn<Path.PathStep, String> distanceToNextCol = new TableColumn<Path.PathStep, String>("Distances au suivant (km)");
distanceToNextCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("distanceToNext"));
TableColumn<Path.PathStep, String> sumDistanceCol = new TableColumn<Path.PathStep, String>("Distances cumulées (km)");
sumDistanceCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("sumDistance"));
pathTable.getColumns().setAll(shipmentCol, distanceToNextCol, sumDistanceCol);
container.getChildren().addAll(header, pathTable);
String tabName = path.getMailman().getName().charAt(0) + ". " + path.getMailman().getLastName() + " (" + path.size() + ")";
tabs.getTabs().add(new Tab(tabName, container));
}
}
示例6: initStatusTable
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private void initStatusTable() {
ObservableList<TableColumn<ProbeStatus, ?>> statusColumns = statusTable.getColumns();
statusColumns.get(0).setCellValueFactory(new PropertyValueFactory<>("id"));
statusColumns.get(1).setCellValueFactory(new PropertyValueFactory<>("status"));
statusColumns.get(2).setCellValueFactory(new PropertyValueFactory<>("ip"));
TableColumn<ProbeStatus,String> actionCol = new TableColumn<>("操作");
actionCol.setPrefWidth(250);
actionCol.setCellValueFactory(new PropertyValueFactory<>("DUMMY"));
actionCol.setCellFactory(param -> new TableCell<ProbeStatus,String>() {
final Button btn = new Button("管理");
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
setText(null);
} else {
btn.setOnAction(event -> {
ProbeStatus probeStatus = getTableView().getItems().get(getIndex());
try {
URI uri = new URI(probeStatus.getIp());
Desktop.getDesktop().browse(uri);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
}
});
setGraphic(btn);
setText(null);
}
}
});
statusColumns.add(actionCol);
}
示例7: init
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
VBox vbox = new VBox(5);
vbox.setPadding(new Insets(12));
TableView tableView = new TableView();
Button button = new Button("Refresh");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
service.restart();
}
});
vbox.getChildren().addAll(tableView, button);
Region veil = new Region();
veil.setStyle("-fx-background-color: rgba(0, 800, 0, 0.3)");
ProgressIndicator p = new ProgressIndicator();
p.setMaxSize(150, 150);
//Define table columns
TableColumn idCol = new TableColumn();
idCol.setText("ID");
idCol.setMinWidth(150);
idCol.setCellValueFactory(new PropertyValueFactory<>("dailySalesId"));
tableView.getColumns().add(idCol);
TableColumn qtyCol = new TableColumn();
qtyCol.setText("Qty");
qtyCol.setMinWidth(150);
qtyCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
tableView.getColumns().add(qtyCol);
TableColumn dateCol = new TableColumn();
dateCol.setText("Date");
dateCol.setCellValueFactory(new PropertyValueFactory<>("date"));
dateCol.setMinWidth(150);
tableView.getColumns().add(dateCol);
p.progressProperty().bind(service.progressProperty());
veil.visibleProperty().bind(service.runningProperty());
p.visibleProperty().bind(service.runningProperty());
tableView.itemsProperty().bind(service.valueProperty());
StackPane stack = new StackPane();
stack.getChildren().addAll(vbox, veil, p);
root.getChildren().add(stack);
service.start();
}
示例8: createSectionView
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableView<QuickViewEntry> createSectionView(QuickViewSection section)
{
String title = section.getTitle();
String contentHeader = section.getContentHeader();
String descriptionHeader = section.getDescriptionHeader();
TableView<QuickViewEntry> table = new TableView<>();
table.setEditable(false);
table.setMouseTransparent(true);
table.setFocusTraversable(false);
table.getStylesheets().add("/noScrollTableView.css");
TableColumn<QuickViewEntry, String> headerColumn = new TableColumn<>(title);
table.getColumns().add(headerColumn);
TableColumn<QuickViewEntry, String> contentColumn = new TableColumn<>(
contentHeader);
contentColumn.setCellValueFactory(cellFactory("content"));
setPercentSize(table, contentColumn, 0.4);
headerColumn.getColumns().add(contentColumn);
TableColumn<QuickViewEntry, String> descriptionColumn = new TableColumn<>(
descriptionHeader);
descriptionColumn.setCellValueFactory(cellFactory("description"));
setPercentSize(table, descriptionColumn, 0.6);
headerColumn.getColumns().add(descriptionColumn);
ObservableList<QuickViewEntry> entries = FXCollections.observableArrayList();
entries.addAll(section.getEntries());
table.setItems(entries);
int headerHeight = 50;
int rows = entries.size();
table.setPrefHeight(rows * 24 + headerHeight);
return table;
}
示例9: initialize
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
sdf = new SimpleDateFormat(Constants.TIMEFORMAT);
TableColumn dateCol = new TableColumn("Date");
TableColumn startCol = new TableColumn("Start");
TableColumn endCol = new TableColumn("End");
TableColumn durCol = new TableColumn("Duration");
dateCol.setCellValueFactory(
new PropertyValueFactory<>("date")
);
startCol.setCellValueFactory(
new PropertyValueFactory<>("startTime")
);
endCol.setCellValueFactory(
new PropertyValueFactory<>("endTime")
);
durCol.setCellValueFactory(
new PropertyValueFactory<>("duration")
);
presTable.getColumns().addAll(dateCol, startCol, endCol, durCol);
intervalCB.setItems(GraphInterval.INTERVALS);
intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (sensor != null) {
sensor.setGraphInterval(newValue);
}
});
intervalCB.getSelectionModel().select(1);
}
示例10: MemberPane
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public MemberPane(Organization organization, EditOrganizationStage oms) {
super();
this.organization = organization;
this.eos = oms;
members = FXCollections.observableArrayList();
forceUpdateMemberList();
memberTable = new TableView<>(members);
TableColumn<MemberView, String> nameCol = new TableColumn<>("Name");
nameCol.setCellValueFactory(new PropertyValueFactory<>("username"));
ColumnConstraints cc = new ColumnConstraints();
cc.setPercentWidth(100);
memberTable.getColumns().add(nameCol);
memberTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
buttonPane = new GridPane();
buttonPane.setPadding(new Insets(10, 0, 0, 0));
buttonPane.setHgap(5);
addMember = new Button("Add Member...");
removeMember = new Button("Remove selected");
transfertOwnership = new Button("Transfert Ownership");
buttonPane.addRow(0, addMember, removeMember, transfertOwnership);
addMember.setOnAction(this::addMemberAction);
removeMember.setOnAction(this::removeMemberAction);
transfertOwnership.setOnAction(this::transferOwnershipAction);
removeMember.setDisable(true);
transfertOwnership.setDisable(true);
Label title = new Label("Members :");
title.setPadding(new Insets(0, 0, 10, 0));
setTop(title);
setCenter(memberTable);
setBottom(buttonPane);
memberTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
if (newSelection == null || newSelection.isYou()) {
removeMember.setDisable(true);
transfertOwnership.setDisable(true);
} else {
removeMember.setDisable(false);
transfertOwnership.setDisable(false);
}
});
}
示例11: getLastNameColumn
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public static TableColumn<Person, String> getLastNameColumn() {
TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
PropertyValueFactory<Person, String> lastNameCellValueFactory = new PropertyValueFactory<>("lastname");
lastNameCol.setCellValueFactory(lastNameCellValueFactory);
return lastNameCol;
}
示例12: AddMemberDialog
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public AddMemberDialog(Organization organization) {
super();
this.organization = organization;
this.setTitle("Add a member");
this.setHeaderText("Search user");
ButtonType addButtonType = new ButtonType("Add selected", ButtonData.OK_DONE);
this.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);
BorderPane mainPane = new BorderPane();
GridPane queryPane = new GridPane();
queryField = new TextField();
Button searchButton = new Button("Search");
searchButton.setOnAction(this::searchAction);
queryField.setOnAction(this::searchAction);
searchList = FXCollections.observableArrayList();
TableView<MemberView> searchResult = new TableView<>(searchList);
searchResult.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn<MemberView, String> nameCol = new TableColumn<>("Name");
nameCol.setCellValueFactory(new PropertyValueFactory<>("username"));
searchResult.getColumns().add(nameCol);
queryPane.addRow(0, queryField, searchButton);
queryPane.setHgap(5);
resultCount = new Label();
queryPane.setPadding(new Insets(0, 0, 10, 0));
resultCount.setPadding(new Insets(10, 0, 0, 0));
mainPane.setTop(queryPane);
mainPane.setCenter(searchResult);
mainPane.setBottom(resultCount);
this.getDialogPane().setContent(mainPane);
this.setResultConverter(dialogButton -> {
if (dialogButton == addButtonType) {
Member result = searchResult.selectionModelProperty().get().getSelectedItem().getMember();
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to add " + result.getUsername() + " to your organization ?");
Optional<ButtonType> answer = conf.showAndWait();
if (answer.isPresent() && answer.get() == ButtonType.OK)
return result;
else
return null;
}
return null;
});
}
示例13: getInstrumentationColumn
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public static TableColumn<MusicalWork, String> getInstrumentationColumn() {
TableColumn<MusicalWork, String> instrumentationCol = new TableColumn<>("Instrumentation");
PropertyValueFactory<MusicalWork, String> instrumentationCellValueFactory = new PropertyValueFactory<>("instrumentation");
instrumentationCol.setCellValueFactory(instrumentationCellValueFactory);
return instrumentationCol;
}
示例14: start
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
if (primaryStage == null) {
return;
}
DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle("Select CTF trace directory");
File dir = dirChooser.showDialog(primaryStage);
if (dir == null) {
return;
}
Path tracePath = dir.toPath();
CtfTrace trace = new CtfTrace(tracePath);
// FIXME Reading all events into memory
List<CtfTraceEvent> events = new ArrayList<>();
try (TraceIterator<CtfTraceEvent> iter = trace.iterator()) {
Iterators.addAll(events, iter);
}
ObservableList<CtfTraceEvent> eventList = FXCollections.observableList(events);
/* Setup the filter text field */
TextField filterField = new TextField();
FilteredList<CtfTraceEvent> filteredData = new FilteredList<>(eventList, p -> true);
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(event -> {
// If filter text is empty, display everything
if (newValue == null || newValue.isEmpty()) {
return true;
}
if (event.toString().toLowerCase().contains(newValue.toLowerCase())) {
return true;
}
return false;
});
});
/* Setup the table */
TableColumn<CtfTraceEvent, String> col1 = new TableColumn<>("Timestamp");
col1.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getTimestamp()));
col1.setSortable(false);
TableColumn<CtfTraceEvent, String> col2 = new TableColumn<>("CPU");
col2.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getCpu()));
col2.setSortable(false);
TableColumn<CtfTraceEvent, String> col3 = new TableColumn<>("All");
col3.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().toString()));
col3.setSortable(false);
TableView<CtfTraceEvent> tableView = new TableView<>();
tableView.setFixedCellSize(24);
tableView.setCache(true);
tableView.setCacheHint(CacheHint.SPEED);
tableView.getColumns().addAll(col1, col2, col3);
tableView.setItems(filteredData);
/* Setup the full scene */
Label filterLabel = new Label("Filter:");
filterLabel.setPadding(new Insets(5));
HBox filterBox = new HBox(filterLabel, filterField);
filterBox.setAlignment(Pos.CENTER_LEFT);
filterBox.setPadding(new Insets(5));
BorderPane borderPane = new BorderPane();
borderPane.setTop(filterBox);
borderPane.setCenter(tableView);
primaryStage.setScene(new Scene(borderPane, 800, 350));
primaryStage.setTitle("tableview");
primaryStage.show();
}
示例15: initResultTable
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") private void initResultTable() {
resultTable.setId("resultTable");
setLabel();
TableColumn<Failure, String> messageColumn = new TableColumn<>("Message");
messageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
messageColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.50));
TableColumn<Failure, String> fileNameColumn = new TableColumn<>("File");
fileNameColumn.setCellValueFactory(new PropertyValueFactory<>("fileName"));
fileNameColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.245));
TableColumn<Failure, String> locationColumn = new TableColumn<>("Location");
locationColumn.setCellValueFactory(new PropertyValueFactory<>("lineNumber"));
locationColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.249));
failuresList.addListener(new ListChangeListener<Failure>() {
@Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends Failure> c) {
if (failuresList.size() == 0) {
clearButton.setDisable(true);
} else {
clearButton.setDisable(false);
}
}
});
resultTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && newValue.getMessage() != null) {
showMessageButton.setDisable(false);
} else {
showMessageButton.setDisable(true);
}
});
resultTable.setRowFactory(e -> {
TableRow<Failure> tableRow = new TableRow<>();
tableRow.setOnMouseClicked(event -> {
if (event.getClickCount() == 2 && !tableRow.isEmpty()) {
SourceLine[] traceback = tableRow.getItem().getTraceback();
if (traceback.length > 0) {
fireResultPaneSelectedEvent(traceback[0]);
}
}
});
return tableRow;
});
resultTable.setItems(failuresList);
resultTable.getColumns().addAll(messageColumn, fileNameColumn, locationColumn);
VBox tableContent = new VBox(tableLabel, resultTable);
VBox.setVgrow(tableContent, Priority.ALWAYS);
VBox.setVgrow(resultTable, Priority.ALWAYS);
resultPaneLayout.setCenter(tableContent);
}