Java Code Examples for javafx.scene.control.TableView#setItems()
The following examples show how to use
javafx.scene.control.TableView#setItems() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableSample.java From marathonv5 with Apache License 2.0 | 7 votes |
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); }
Example 2
Source File: AttachPane.java From Recaf with MIT License | 7 votes |
/** * Create a display for the given vm. * @param vm JVM to potentially attach to. * @return Node containing VM properties, and actions. */ private Node createVmDisplay(VMInfo vm) { BorderPane pane = new BorderPane(); HBox horizontal = new HBox(); horizontal.getStyleClass().add("vm-buttons"); horizontal.getChildren().addAll( new ActionButton(LangUtil.translate("ui.attach"), () -> attach(vm)), new ActionButton(LangUtil.translate("ui.attach.copy"), () -> copy(vm))); pane.setBottom(horizontal); TableView<Map.Entry<String,String>> table = new TableView<>(); table.getStyleClass().add("vm-info-table"); TableColumn<Map.Entry<String,String>, String> keyColumn = new TableColumn<>("Key"); TableColumn<Map.Entry<String,String>, String> valueColumn = new TableColumn<>("Value"); keyColumn.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getKey())); valueColumn.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getValue())); table.getColumns().add(keyColumn); table.getColumns().add(valueColumn); List<Map.Entry<String, String>> entries = new ArrayList<>(vm.getProperties().entrySet()); table.setItems(FXCollections.observableArrayList(entries)); valueColumn.prefWidthProperty().bind(pane.widthProperty().subtract(keyColumn.widthProperty()).subtract(15)); pane.setCenter(table); return pane; }
Example 3
Source File: AttributeNodeProvider.java From constellation with Apache License 2.0 | 6 votes |
private void filter(final TableView<AttributeEntry> table, final String newValue, final boolean st) { if (newValue.isEmpty()) { table.setItems(attributeInfo); table.scrollTo(0); table.getSelectionModel().clearSelection(); } else { final String lc = newValue.toLowerCase(); final ObservableList<AttributeEntry> items = FXCollections.observableArrayList(); attributeInfo.stream().forEach(si -> { final String nameLc = si.attr.getName().toLowerCase(); final boolean found = st ? nameLc.startsWith(lc) : nameLc.contains(lc); if (found) { items.add(si); } }); table.setItems(items); } }
Example 4
Source File: TableSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: TableScrollSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 6
Source File: TableSample1.java From marathonv5 with Apache License 2.0 | 5 votes |
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", "[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); }
Example 7
Source File: TestISSFStandardPistol.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
@Before public void setUp() throws UnsupportedEncodingException, ConfigurationException { new JFXPanel(); // Initialize the JFX toolkit stringOutStream = new PrintStream(stringOut, false, "UTF-8"); System.setProperty("shootoff.home", System.getProperty("user.dir")); TextToSpeech.silence(true); TrainingExerciseBase.silence(true); originalOut = System.out; System.setOut(stringOutStream); Configuration config = new Configuration(new String[0]); config.setDebugMode(true); CamerasSupervisor cs = new CamerasSupervisor(config); targets = new ArrayList<Target>(); TargetComponents tc = TargetIO.loadTarget(new File("targets/ISSF.target")).get(); TargetView issfTarget = new TargetView(tc.getTargetGroup(), tc.getTargetTags(), targets); targets.add(issfTarget); scoredRegionHit = new MockHit(issfTarget, (TargetRegion) issfTarget.getTargetGroup().getChildren().get(0), 0, 0); regionScore = Integer.parseInt(scoredRegionHit.getHitRegion().getTag("points")); issfExercise = new ISSFStandardPistol(targets); TableView<ShotEntry> shotTimerTable = new TableView<ShotEntry>(); ObservableList<ShotEntry> shotEntries = FXCollections.observableArrayList(); shotEntries .add(new ShotEntry(new DisplayShot(ShotColor.RED, 0, 0, 0, 2), Optional.empty(), Optional.empty(), false, false)); shotTimerTable.setItems(shotEntries); issfExercise.init(config, cs, null, shotTimerTable); issfExercise.init(0, 0); }
Example 8
Source File: ProposalResultsWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private GridPane createVotesTable() { GridPane votesGridPane = new GridPane(); votesGridPane.setHgap(5); votesGridPane.setVgap(5); votesGridPane.setPadding(new Insets(15)); ColumnConstraints columnConstraints1 = new ColumnConstraints(); columnConstraints1.setHalignment(HPos.RIGHT); columnConstraints1.setHgrow(Priority.ALWAYS); votesGridPane.getColumnConstraints().addAll(columnConstraints1); int gridRow = 0; TableGroupHeadline votesTableHeader = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header")); GridPane.setRowIndex(votesTableHeader, gridRow); GridPane.setMargin(votesTableHeader, new Insets(8, 0, 0, 0)); GridPane.setColumnSpan(votesTableHeader, 2); votesGridPane.getChildren().add(votesTableHeader); TableView<VoteListItem> votesTableView = new TableView<>(); votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData"))); votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); createColumns(votesTableView); GridPane.setRowIndex(votesTableView, gridRow); GridPane.setMargin(votesTableView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0)); GridPane.setColumnSpan(votesTableView, 2); GridPane.setVgrow(votesTableView, Priority.ALWAYS); votesGridPane.getChildren().add(votesTableView); votesTableView.setItems(sortedVotes); addCloseButton(votesGridPane, ++gridRow); return votesGridPane; }
Example 9
Source File: ManageMarketAlertsWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void addContent() { TableView<MarketAlertFilter> tableView = new TableView<>(); GridPane.setRowIndex(tableView, ++rowIndex); GridPane.setColumnSpan(tableView, 2); GridPane.setMargin(tableView, new Insets(10, 0, 0, 0)); gridPane.getChildren().add(tableView); Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData")); placeholder.setWrapText(true); tableView.setPlaceholder(placeholder); tableView.setPrefHeight(300); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); setColumns(tableView); tableView.setItems(FXCollections.observableArrayList(marketAlerts.getMarketAlertFilters())); }
Example 10
Source File: ClientList.java From Maus with GNU General Public License v3.0 | 4 votes |
public TableView getClientList() { tableView = new TableView(); tableView.setEditable(true); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm()); TableColumn<String, String> onlineStatus = new TableColumn<>("Status"); onlineStatus.setMaxWidth(70); onlineStatus.setResizable(false); onlineStatus.setCellValueFactory( new PropertyValueFactory<>("onlineStatus")); TableColumn<ClientObject, String> nickName = new TableColumn<>("Nickname"); nickName.setMinWidth(150); nickName.setMaxWidth(200); nickName.setResizable(false); nickName.setCellValueFactory(new PropertyValueFactory<>("nickName")); nickName.setCellFactory(TextFieldTableCell.forTableColumn()); nickName.setOnEditCommit( t -> t.getTableView().getItems().get( t.getTablePosition().getRow()).setNickName(t.getNewValue()) ); TableColumn<ClientObject, String> IP = new TableColumn<>("IP"); IP.setMinWidth(600); IP.setResizable(false); IP.setCellValueFactory(new PropertyValueFactory<>("IP")); IP.setCellFactory(col -> { final TableCell<ClientObject, String> cell = new TableCell<>(); cell.textProperty().bind(cell.itemProperty()); cell.setOnMouseClicked(event -> { if (event.getButton().equals(MouseButton.SECONDARY) && cell.getTableView().getSelectionModel().getSelectedItem() != null && cell.getTableView().getSelectionModel().getSelectedItem().getClient().isConnected()) { IPContextMenu.getIPContextMenu(cell, event); } }); return cell; }); ObservableList<ClientObject> list = FXCollections.observableArrayList(); list.addAll(CONNECTIONS.values()); tableView.setItems(list); tableView.getColumns().addAll(onlineStatus, nickName, IP); return tableView; }
Example 11
Source File: AnimatedTableRow.java From mars-sim with GNU General Public License v3.0 | 4 votes |
@Override public void start(Stage stage) { stage.setTitle("Table View Sample"); stage.setWidth(900); stage.setHeight(500); 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]") ); final TableView<Person> contactTable = createTable(); contactTable.setPlaceholder(new Label("No more contacts to select")); contactTable.setItems(data); final Node contactContainer = createTableContainer("Address Book", contactTable); final TableView<Person> toTable = createTable(); toTable.setPlaceholder(new Label("No contacts selected")); final Node toContainer = createTableContainer("Selected Contacts: ", toTable); final BorderPane root = new BorderPane(); final SplitPane splitPane = new SplitPane(); splitPane.getItems().addAll(contactContainer, toContainer); root.setCenter(splitPane); final Scene scene = new Scene(root); contactTable.setRowFactory(new Callback<TableView<Person>, TableRow<Person>>() { @Override public TableRow<Person> call(TableView<Person> tableView) { final TableRow<Person> row = new TableRow<>(); row.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() == 2 && row.getItem() != null) { moveDataWithAnimation(contactTable, toTable, root, row); } } }); return row ; } }); stage.setScene(scene); stage.show(); }
Example 12
Source File: FeatureTable.java From sis with Apache License 2.0 | 4 votes |
public FeatureTable(Resource res, int i) throws DataStoreException { TableView<AbstractFeature> ttv = new TableView<>(); final ScrollPane scroll = new ScrollPane(ttv); scroll.setFitToHeight(true); scroll.setFitToWidth(true); ttv.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY); ttv.setTableMenuButtonVisible(true); ttv.setFixedCellSize(100); scroll.setPrefSize(600, 400); scroll.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); setCenter(scroll); final List<AbstractFeature> list; if (res instanceof FeatureSet) { try (Stream<AbstractFeature> stream = ((FeatureSet) res).features(false)) { list = stream.collect(Collectors.toList()); ttv.setItems(FXCollections.observableArrayList(list)); for (AbstractIdentifiedType pt : list.get(0).getType().getProperties(false)) { final TableColumn<AbstractFeature, BorderPane> column = new TableColumn<>(generateFinalColumnName(pt)); column.setCellValueFactory((TableColumn.CellDataFeatures<AbstractFeature, BorderPane> param) -> { final Object val = param.getValue().getPropertyValue(pt.getName().toString()); if (val instanceof Geometry) { return new SimpleObjectProperty<>(new BorderPane(new Label("{geometry}"))); } else { SimpleObjectProperty<BorderPane> sop = new SimpleObjectProperty<>(); if (val instanceof CheckedArrayList<?>) { Iterator<String> it = ((CheckedArrayList<String>) val).iterator(); TreeItem<String> ti = new TreeItem<>(it.next()); while (it.hasNext()) { ti.getChildren().add(new TreeItem<>(it.next())); } BorderPane bp = new BorderPane(new TreeView<>(ti)); sop.setValue(bp); return sop; } else { sop.setValue(new BorderPane(new Label(String.valueOf(val)))); return sop; } } }); ttv.getColumns().add(column); } } } }