本文整理汇总了Java中javafx.collections.FXCollections类的典型用法代码示例。如果您正苦于以下问题:Java FXCollections类的具体用法?Java FXCollections怎么用?Java FXCollections使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FXCollections类属于javafx.collections包,在下文中一共展示了FXCollections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChoiceBoxColumnName
import javafx.collections.FXCollections; //导入依赖的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: init
import javafx.collections.FXCollections; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
new XYChart.Data<Double,Double>(0.0, 1.0),
new XYChart.Data<Double,Double>(1.2, 1.4),
new XYChart.Data<Double,Double>(2.2, 1.9),
new XYChart.Data<Double,Double>(2.7, 2.3),
new XYChart.Data<Double,Double>(2.9, 0.5)
)),
new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
new XYChart.Data<Double,Double>(0.0, 1.6),
new XYChart.Data<Double,Double>(0.8, 0.4),
new XYChart.Data<Double,Double>(1.4, 2.9),
new XYChart.Data<Double,Double>(2.1, 1.3),
new XYChart.Data<Double,Double>(2.6, 0.9)
))
);
LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
root.getChildren().add(chart);
}
示例3: mbushTabelen
import javafx.collections.FXCollections; //导入依赖的package包/类
public void mbushTabelen(){
Thread t = new Thread(new Runnable() {
public void run() {
try {
Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from Konsumatori");
ObservableList<TabelaKonsumatori> data = FXCollections.observableArrayList();
while (rs.next()){
data.add(new TabelaKonsumatori(rs.getInt("id"), rs.getString("emri"), rs.getString("mbiemri"),
rs.getString("makina"), rs.getString("komuna"), rs.getString("pershkrimi")));
}
table.setItems(data);
conn.close();
}catch (Exception ex){ex.printStackTrace();}
}
});
t.start();
}
示例4: searchFile
import javafx.collections.FXCollections; //导入依赖的package包/类
/**
* 搜索资源文件,忽略大小写
*/
public void searchFile(KeyEvent event) {
ArrayList<FileInfo> files = new ArrayList<FileInfo>();
String search = Checker.checkNull(searchTextField.getText());
logger.info("search file: " + search);
QiniuApplication.totalLength = 0;
QiniuApplication.totalSize = 0;
try {
// 正则匹配查询
Pattern pattern = Pattern.compile(search, Pattern.CASE_INSENSITIVE);
for (FileInfo file : QiniuApplication.data) {
if (pattern.matcher(file.getName()).find()) {
files.add(file);
QiniuApplication.totalLength++;
QiniuApplication.totalSize += Formatter.sizeToLong(file.getSize());
}
}
} catch (Exception e) {
logger.warn("pattern '" + search + "' compile error, message: " + e.getMessage());
}
setBucketCount();
resTable.setItems(FXCollections.observableArrayList(files));
}
示例5: BubbleChartSample
import javafx.collections.FXCollections; //导入依赖的package包/类
public BubbleChartSample() {
NumberAxis xAxis = new NumberAxis("X", 0d, 150d, 20d);
NumberAxis yAxis = new NumberAxis("Y", 0d, 150d, 20d);
ObservableList<BubbleChart.Series> bubbleChartData = FXCollections.observableArrayList(
new BubbleChart.Series("Series 1", FXCollections.observableArrayList(
new XYChart.Data(30d, 40d, 10d),
new XYChart.Data(60d, 20d, 13d),
new XYChart.Data(10d, 90d, 7d),
new XYChart.Data(100d, 40d, 10d),
new XYChart.Data(50d, 23d, 5d)))
,
new BubbleChart.Series("Series 2", FXCollections.observableArrayList(
new XYChart.Data(13d, 100d, 7d),
new XYChart.Data(20d, 80d, 13d),
new XYChart.Data(100d, 60d, 10d),
new XYChart.Data(30d, 40d, 6d),
new XYChart.Data(50d, 20d, 12d)
))
);
BubbleChart chart = new BubbleChart(xAxis, yAxis, bubbleChartData);
getChildren().add(chart);
}
示例6: displayData
import javafx.collections.FXCollections; //导入依赖的package包/类
private void displayData() {
ObservableList<BookEntity> data = book.getAllBooksList();
title.setCellValueFactory(new PropertyValueFactory<>("title"));
category.setCellValueFactory(new PropertyValueFactory<>("category"));
author.setCellValueFactory(new PropertyValueFactory<>("author"));
isbn.setCellValueFactory(new PropertyValueFactory<>("isbn"));
publisher.setCellValueFactory(new PropertyValueFactory<>("publisher"));
date.setCellValueFactory(new PropertyValueFactory<>("date"));
pages.setCellValueFactory(new PropertyValueFactory<>("pages"));
quantity.setCellValueFactory(new PropertyValueFactory<>("quantity"));
table.setItems(data);
ObservableList<String> options = FXCollections.observableArrayList("Title", "Category", "Author", "Publisher");
search_combo.setItems(options);
search_combo.getSelectionModel().selectFirst();
}
示例7: showPackageContents
import javafx.collections.FXCollections; //导入依赖的package包/类
private void showPackageContents(PackageContents packageContents) {
packageConfirmPanel.setVisible(false);
downloadingPane.setVisible(false);
analysisPane.setVisible(true);
pkgContents = packageContents;
downloadFileLabel.setText(packageContents.getFile().getPath());
fileCountLabel.setText(String.valueOf(packageContents.getFileCount()));
folderCountLabel.setText(String.valueOf(packageContents.getFolderCount()));
rootSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getBaseCounts().entrySet()));
typeSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getFilesByType().entrySet()));
downloadFileLabel.setOnMouseClicked(evt -> {
if (evt.getButton() == MouseButton.PRIMARY && evt.getClickCount() == 2) {
String path;
if (evt.isShiftDown() || evt.isControlDown()) {
path = packageContents.getFile().getParent();
} else {
path = packageContents.getFile().getPath();
}
HostServices services = ApplicationState.getInstance().getApplication().getHostServices();
services.showDocument(path);
}
});
}
示例8: refreshListView
import javafx.collections.FXCollections; //导入依赖的package包/类
protected void refreshListView () {
this.questionList.getItems().clear();
//create list with all questions
ObservableList<String> questions = FXCollections.observableArrayList();
//iterate through all questions
for (Map.Entry<String,QuestionEntry> entry : this.questionMap.entrySet()) {
//add question name to list
questions.add(entry.getKey());
}
Collections.sort(questions);
if (questions.size() <= 0) {
//hide delete button
this.deleteButton.setVisible(false);
} else {
//show delete button
this.deleteButton.setVisible(true);
}
this.questionList.setItems(questions);
}
示例9: setUpPrawnFile
import javafx.collections.FXCollections; //导入依赖的package包/类
private void setUpPrawnFile() {
shrimpRuns = FXCollections.observableArrayList(squidProject.getPrawnFileRuns());
setUpShrimpFractionList();
saveSpotNameButton.setDisable(false);
setFilteredSpotsAsRefMatButton.setDisable(false);
setFilteredSpotsAsConcRefMatButton.setDisable(false);
// filter runs to populate ref mat list
filterRuns(squidProject.getFilterForRefMatSpotNames());
updateReferenceMaterialsList(false);
// filter runs to populate concentration ref mat list
filterRuns(squidProject.getFilterForConcRefMatSpotNames());
updateConcReferenceMaterialsList(false);
// restore spot list to full population
filterRuns("");
}
示例10: initialize
import javafx.collections.FXCollections; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
software = new SoftwareEntity();
negocio = new Software(DAOFactory.getDAOFactory().getSoftwareDAO());
tbcDescricao.setCellValueFactory(new PropertyValueFactory<>("descricao"));
tbcLink.setCellValueFactory(new PropertyValueFactory<>("link"));
tbcId.setCellValueFactory(new PropertyValueFactory<>("id"));
tbcObservacao.setCellValueFactory(new PropertyValueFactory<>("observacaoInstalacao"));
tbcTipo.setCellValueFactory(new PropertyValueFactory<>("tipo"));
tbcVersao.setCellValueFactory(new PropertyValueFactory<>("versao"));
cbxManutencaoTipoSoftware.getItems().addAll(TipoSoftwareEnum.values());
cbxManutencaoTipoSoftware.getSelectionModel().selectFirst();
cbxSoftwareTipo.getItems().addAll(TipoSoftwareEnum.values());
listaSoftwares = FXCollections.observableArrayList();
listaSoftwares.addAll(negocio.buscarTodosSoftwares());
tblManutencaoSoftware.setItems(listaSoftwares);
tbpGerenciaSoftware.getSelectionModel().selectLast();
}
示例11: NotificationBarPane
import javafx.collections.FXCollections; //导入依赖的package包/类
public NotificationBarPane(Node content) {
super(content);
progressBar = new ProgressBar();
label = new Label("infobar!");
bar = new HBox(label);
bar.setMinHeight(0.0);
bar.getStyleClass().add("info-bar");
bar.setFillHeight(true);
setBottom(bar);
// Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
sceneProperty().addListener(o -> {
if (getParent() == null) return;
getParent().applyCss();
getParent().layout();
barHeight = bar.getHeight();
bar.setPrefHeight(0.0);
});
items = FXCollections.observableArrayList();
items.addListener((ListChangeListener<? super Item>) change -> {
config();
showOrHide();
});
}
示例12: searchApp
import javafx.collections.FXCollections; //导入依赖的package包/类
@FXML
void searchApp(KeyEvent event)
{
ArrayList<AbstractSteamAppWithKey> searchResult = new ArrayList<>();
String search = searchText.getText();
if (!search.isEmpty())
searchGraphic.setImage(new Image("/com/matthieu42/steamtradertools/bundles/images/close.png"));
else
searchGraphic.setImage(new Image("/com/matthieu42/steamtradertools/bundles/images/magnify.png"));
search = search.toLowerCase();
for (AbstractSteamAppWithKey curVal : currentAppList)
{
if (curVal.getName().toLowerCase().contains(search))
{
searchResult.add(curVal);
}
}
appList.setItems(FXCollections.observableArrayList(searchResult));
}
示例13: setValue
import javafx.collections.FXCollections; //导入依赖的package包/类
/**
* 装载面板数据.
*
* @param key 数据库中的键
*/
@Override
public void setValue(String key) {
ObservableList<TableEntity> values = FXCollections.observableArrayList();
Set<String> sets = redisSet.getMembersSet(key);
int i = 0;
for (String set : sets) {
TableEntity value = new TableEntity("" + i, key, set);
values.add(value);
i++;
}
this.dataTable.setItems(values);
this.rowColumn.setCellValueFactory(cellData -> cellData.getValue().rowProperty());
this.keyColumn.setCellValueFactory(cellData -> cellData.getValue().keyProperty());
this.valueColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
}
示例14: SimpleBookmarkStore
import javafx.collections.FXCollections; //导入依赖的package包/类
/**
* Create an instance of a {@link SimpleBookmarkStore}.
* <p>
* If it observed that the {@link org.dnacronym.hygene.parser.GfaFile} in {@link GraphStore} has changed, it will
* clear all current {@link SimpleBookmark}s and load the {@link Bookmark}s associated with the new
* {@link org.dnacronym.hygene.parser.GfaFile}.
* <p>
* It uses the {@link GraphDimensionsCalculator} as a reference for each internal {@link SimpleBookmark}.
*
* @param graphStore the {@link GraphStore} to be observed by this class
* @param graphVisualizer the {@link GraphVisualizer} to be used by this class
* @param graphDimensionsCalculator the {@link GraphDimensionsCalculator} to be used by this class
* @param sequenceVisualizer the {@link SequenceVisualizer} to be used by this class
* @see SimpleBookmark
*/
@Inject
public SimpleBookmarkStore(final GraphStore graphStore, final GraphVisualizer graphVisualizer,
final GraphDimensionsCalculator graphDimensionsCalculator,
final SequenceVisualizer sequenceVisualizer) {
this.graphDimensionsCalculator = graphDimensionsCalculator;
this.graphVisualizer = graphVisualizer;
this.sequenceVisualizer = sequenceVisualizer;
simpleBookmarks = new ArrayList<>();
observableSimpleBookmarks = FXCollections.observableList(simpleBookmarks);
observableSimpleBookmarks.addListener((ListChangeListener<SimpleBookmark>) listener -> graphVisualizer.draw());
graphStore.getGfaFileProperty().addListener((observable, oldValue, newValue) -> {
try {
fileBookmarks = new FileBookmarks(new FileDatabase(newValue.getFileName()));
simpleBookmarks.clear();
addBookmarks(fileBookmarks.getAll());
} catch (final SQLException | IOException e) {
LOGGER.error("Unable to load bookmarks from file.", e);
}
});
}
示例15: btnMapDevicesAction
import javafx.collections.FXCollections; //导入依赖的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();
}
}