本文整理汇总了Java中javafx.scene.control.TableView.setItems方法的典型用法代码示例。如果您正苦于以下问题:Java TableView.setItems方法的具体用法?Java TableView.setItems怎么用?Java TableView.setItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableView
的用法示例。
在下文中一共展示了TableView.setItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableSample
import javafx.scene.control.TableView; //导入方法依赖的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);
}
示例2: VarsPanel
import javafx.scene.control.TableView; //导入方法依赖的package包/类
public VarsPanel(AppSession session) {
this.session = session;
table = new TableView();
table.setPrefWidth(300);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
setCenter(table);
TableColumn nameCol = new TableColumn("Variable");
nameCol.setMinWidth(120);
nameCol.setMaxWidth(250);
nameCol.setCellValueFactory(new PropertyValueFactory("name"));
nameCol.setCellFactory(c -> new StringTooltipCell());
TableColumn typeCol = new TableColumn("Type");
typeCol.setMinWidth(45);
typeCol.setMaxWidth(60);
typeCol.setCellValueFactory(new PropertyValueFactory("type"));
TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value");
valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue()));
valueCol.setCellFactory(c -> new VarValueCell());
table.getColumns().addAll(nameCol, typeCol, valueCol);
table.setItems(session.getVars());
table.setRowFactory(tv -> {
TableRow<Var> row = new TableRow<>();
row.setOnMouseClicked(e -> {
if (e.getClickCount() == 2 && !row.isEmpty()) {
Var var = row.getItem();
session.logVar(var);
}
});
return row ;
});
}
示例3: createClassifierTable
import javafx.scene.control.TableView; //导入方法依赖的package包/类
static <T> TableView<ClassifierResult<T>> createClassifierTable() {
TableView<ClassifierResult<T>> ret = new TableView<>();
ret.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn<ClassifierResult<T>, String> tab0 = new TableColumn<>("name");
tab0.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getName()));
ret.getColumns().add(tab0);
TableColumn<ClassifierResult<T>, String> tab1 = new TableColumn<>("score");
tab1.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore())));
ret.getColumns().add(tab1);
TableColumn<ClassifierResult<T>, Double> tab2 = new TableColumn<>("weight");
tab2.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getWeight()));
ret.getColumns().add(tab2);
TableColumn<ClassifierResult<T>, String> tab3 = new TableColumn<>("w. score");
tab3.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore() * data.getValue().getClassifier().getWeight())));
ret.getColumns().add(tab3);
ret.setItems(FXCollections.observableArrayList());
return ret;
}
示例4: TableScrollSample
import javafx.scene.control.TableView; //导入方法依赖的package包/类
public TableScrollSample() {
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);
ObservableList items = tableView.getItems();
for (int i = 0; i < 10; i++)
items.add(new Person("Name" + i, "Last" + i, "Email " + i));
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
示例5: btnMapDevicesAction
import javafx.scene.control.TableView; //导入方法依赖的package包/类
@FXML
private void btnMapDevicesAction()
{
try
{
FXMLLoader loader = new FXMLLoader(MainDisplay.class.getResource("/fxml/MapDevicesDialog.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root);
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(scene);
stage.show();
Node node = scene.lookup("#tblMapDevice");
if(node instanceof TableView)
{
TableView<Pair<String, String>> table = (TableView)node;
ArrayList<Pair<String, String>> pairList = new ArrayList<>();
dataContainer.getDeviceMap().entrySet().forEach(entry -> pairList.add(new Pair<String, String>(entry.getKey(), entry.getValue())));
ObservableList<Pair<String, String>> tableModel = FXCollections.<Pair<String, String>> observableArrayList(pairList);
table.setItems(tableModel);
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
示例6: createRegisterTable
import javafx.scene.control.TableView; //导入方法依赖的package包/类
private TableView<RegisterRow> createRegisterTable()
{
TableView<RegisterRow> table = new TableView<>();
table.setEditable(true);
TableColumn<RegisterRow, String> nameColumn = new TableColumn<>("Name");
nameColumn.setCellValueFactory(registerFactory("registerName"));
setPercentSize(table, nameColumn, 1.0 / 3.0);
table.getColumns().add(nameColumn);
TableColumn<RegisterRow, String> idColumn = new TableColumn<>("Register");
idColumn.setCellValueFactory(registerFactory("registerID"));
setPercentSize(table, idColumn, 1.0 / 3.0);
table.getColumns().add(idColumn);
TableColumn<RegisterRow, String> valueColumn = new TableColumn<>("Value");
valueColumn.setCellValueFactory(registerFactory("value"));
setPercentSize(table, valueColumn, 1.0 / 3.0);
table.getColumns().add(valueColumn);
table.setItems(registers);
table.setMinHeight(80);
return table;
}
示例7: createMemoryTable
import javafx.scene.control.TableView; //导入方法依赖的package包/类
private TableView<MemoryRow> createMemoryTable()
{
TableView<MemoryRow> table = new TableView<>();
table.setEditable(true);
TableColumn<MemoryRow, String> idColumn = new TableColumn<>("Address");
idColumn.setCellValueFactory(memoryFactory("address"));
setPercentSize(table, idColumn, 0.5);
table.getColumns().add(idColumn);
TableColumn<MemoryRow, String> valueColumn = new TableColumn<>("Value");
valueColumn.setCellValueFactory(memoryFactory("value"));
setPercentSize(table, valueColumn, 0.5);
table.getColumns().add(valueColumn);
table.setItems(memoryAddresses);
table.setMinHeight(80);
return table;
}
示例8: createRegisterTabContent
import javafx.scene.control.TableView; //导入方法依赖的package包/类
private TableView<RegisterRow> createRegisterTabContent()
{
TableView<RegisterRow> table = new TableView<>();
table.setEditable(true);
TableColumn<RegisterRow, String> nameColumn = new TableColumn<>("Register");
nameColumn.setCellValueFactory(registerFactory("register"));
setPercentSize(table, nameColumn, 1.0 / 3.0);
table.getColumns().add(nameColumn);
TableColumn<RegisterRow, String> contentsColumn = new TableColumn<>("Contents");
contentsColumn.setCellValueFactory(registerFactory("content"));
setPercentSize(table, contentsColumn, 1.0 / 3.0);
table.getColumns().add(contentsColumn);
TableColumn<RegisterRow, String> valueColumn = new TableColumn<>("Edit Contents");
valueColumn.setCellValueFactory(registerFactory("editContent"));
setPercentSize(table, valueColumn, 1.0 / 3.0);
table.getColumns().add(valueColumn);
table.setItems(registers);
return table;
}
示例9: makeTable
import javafx.scene.control.TableView; //导入方法依赖的package包/类
public static TableView<ViewRecordingFrame> makeTable(QuPathViewer viewer, ViewTracker tracker) {
TableView<ViewRecordingFrame> table = new TableView();
for (int i = 0; i < nCols(tracker); ++i) {
TableColumn<ViewRecordingFrame, Object> column = new TableColumn(getColumnName(i));
final int j = i;
column.setCellValueFactory(frame -> new SimpleObjectProperty(
getColumnValue((ViewRecordingFrame)frame.getValue(), j)));
table.getColumns().add(column);
}
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.getSelectionModel().selectedItemProperty().addListener((v, o, frame) -> {
if (frame != null) {
setViewerForFrame(viewer, frame);
}
});
ObservableList<ViewRecordingFrame> frameList = FXCollections.observableArrayList(
TrackerUtils.getFramesAsArrayList(tracker));
table.setItems(frameList);
return table;
}
示例10: TableSample1
import javafx.scene.control.TableView; //导入方法依赖的package包/类
public TableSample1() {
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]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "eth[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);
}
示例11: reload
import javafx.scene.control.TableView; //导入方法依赖的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));
}
}
示例12: createSectionView
import javafx.scene.control.TableView; //导入方法依赖的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;
}
示例13: createDisassemblyTabContent
import javafx.scene.control.TableView; //导入方法依赖的package包/类
private TableView<DisassemblyRow> createDisassemblyTabContent()
{
TableView<DisassemblyRow> table = new TableView<>();
table.setEditable(true);
TableColumn<DisassemblyRow, String> pcColumn = new TableColumn<>("PC");
pcColumn.setCellValueFactory(disassemblyFactory("pc"));
setPercentSize(table, pcColumn, 1.0 / 5.0);
table.getColumns().add(pcColumn);
TableColumn<DisassemblyRow, CheckBox> breakpointColumn = new TableColumn<>(
"Breakpoint");
breakpointColumn.setCellValueFactory(disassemblyFactoryCheckBox("checkBox"));
setPercentSize(table, breakpointColumn, 1.0 / 5.0);
table.getColumns().add(breakpointColumn);
TableColumn<DisassemblyRow, String> addressColumn = new TableColumn<>("Address");
addressColumn.setCellValueFactory(disassemblyFactory("address"));
setPercentSize(table, addressColumn, 1.0 / 5.0);
table.getColumns().add(addressColumn);
TableColumn<DisassemblyRow, String> instructionHexColumn = new TableColumn<>(
"Instruction (Hex)");
instructionHexColumn.setCellValueFactory(disassemblyFactory("instructionHex"));
setPercentSize(table, instructionHexColumn, 1.0 / 5.0);
table.getColumns().add(instructionHexColumn);
TableColumn<DisassemblyRow, String> instructionStatementColumn = new TableColumn<>(
"Instruction");
instructionStatementColumn
.setCellValueFactory(disassemblyFactory("instructionStatement"));
setPercentSize(table, instructionStatementColumn, 1.0 / 5.0);
table.getColumns().add(instructionStatementColumn);
table.setItems(disassembly);
return table;
}
示例14: createMemoryMapTabContent
import javafx.scene.control.TableView; //导入方法依赖的package包/类
private TableView<MemoryMapRow> createMemoryMapTabContent()
{
TableView<MemoryMapRow> table = new TableView<>();
table.setEditable(true);
TableColumn<MemoryMapRow, String> indexColumn = new TableColumn<>("Index");
indexColumn.setCellValueFactory(memoryMapFactory("index"));
setPercentSize(table, indexColumn, 1.0 / 5.0);
table.getColumns().add(indexColumn);
TableColumn<MemoryMapRow, String> moduleNameColumn = new TableColumn<>(
"Module Name");
moduleNameColumn.setCellValueFactory(memoryMapFactory("moduleName"));
setPercentSize(table, moduleNameColumn, 1.0 / 5.0);
table.getColumns().add(moduleNameColumn);
TableColumn<MemoryMapRow, String> startAddressColumn = new TableColumn<>(
"Start Address");
startAddressColumn.setCellValueFactory(memoryMapFactory("startAddress"));
setPercentSize(table, startAddressColumn, 1.0 / 5.0);
table.getColumns().add(startAddressColumn);
TableColumn<MemoryMapRow, String> endAddressColumn = new TableColumn<>(
"Instruction");
endAddressColumn.setCellValueFactory(memoryMapFactory("endAddress"));
setPercentSize(table, endAddressColumn, 1.0 / 5.0);
table.getColumns().add(endAddressColumn);
TableColumn<MemoryMapRow, CheckBox> enableColumn = new TableColumn<>("Enabled");
enableColumn.setCellValueFactory(memoryMapFactoryCheckBox("enable"));
setPercentSize(table, enableColumn, 1.0 / 5.0);
table.getColumns().add(enableColumn);
table.setItems(memoryMap);
return table;
}
示例15: start
import javafx.scene.control.TableView; //导入方法依赖的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();
}