java类javafx.collections.FXCollections的实例源码

MediaLibrary.java 文件源码 项目:boomer-tuner 阅读 19 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private void readSerializedLibrary(final File location) {
    try {
        FileInputStream fileIn = new FileInputStream(location);
        ObjectInputStream in = new ObjectInputStream(fileIn);
        songs = FXCollections.observableList((List<Song>) in.readObject());
        playlists = FXCollections.observableList((List<Playlist>) in.readObject());
        videos = FXCollections.observableList((List<Video>) in.readObject());
        images = FXCollections.observableList((List<Image>) in.readObject());
        for (Song song : songs) {
            if (!artists.contains(song.getArtist())) {
                artists.add(song.getArtist());
            }
            if (!albums.contains(song.getAlbum())) {
                albums.add(song.getAlbum());
            }
        }

        Collections.sort(albums, Comparator.comparing(Album::getName));
        Collections.sort(artists, Comparator.comparing(Artist::getName));
        Collections.sort(songs, Comparator.comparing(Song::getTitle));
        Collections.sort(images, Comparator.comparing(Image::getName));

        in.close();
        fileIn.close();
    } catch (IOException | ClassNotFoundException e) {
        e.printStackTrace();
    }
}
PatientGetway.java 文件源码 项目:Dr-Assistant 阅读 24 收藏 0 点赞 0 评论 0
public ObservableList<Patient> searchPatient(Paginate paginate, String query) {
    DBConnection connection = new DBConnection();
    Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    ObservableList<Patient> listData = FXCollections.observableArrayList();
    con = connection.geConnection();
    try {
        pst = con.prepareStatement("select * from patient where name like ? or phone like ? or email like ? limit " + paginate.getStart() + "," + paginate.getEnd());
        pst.setString(1, query + "%");
        pst.setString(2, query + "%");
        pst.setString(3, query + "%");
        rs = pst.executeQuery();
        while (rs.next()) {
            listData.add(new Patient(
                    rs.getInt(1),
                    rs.getString(2),
                    rs.getString(3),
                    LocalDate.parse(rs.getString(4)),
                    rs.getInt(5),
                    rs.getString(6),
                    rs.getString(7),
                    rs.getString(8),
                    rs.getString(9),
                    totalPrescriptionByPatient(rs.getInt(1))
            ));
        }
        rs.close();
        pst.close();
        con.close();
        connection.con.close();
    } catch (SQLException ex) {
        Logger.getLogger(PatientGetway.class.getName()).log(Level.SEVERE, null, ex);
    }
    return listData;
}
TableDialog.java 文件源码 项目:OneClient 阅读 28 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
public TableDialog(Collection<T> files) {
    dialogPane = getDialogPane();
    setResizable(true);
    this.table = new TableView<>(FXCollections.observableArrayList(files));
    this.table.setMaxWidth(Double.MAX_VALUE);

    GridPane.setHgrow(table, Priority.ALWAYS);
    GridPane.setFillWidth(table, true);

    label = createContentLabel(dialogPane.getContentText());
    label.setPrefWidth(Region.USE_COMPUTED_SIZE);
    label.textProperty().bind(dialogPane.contentTextProperty());

    this.grid = new GridPane();
    this.grid.setHgap(10);
    this.grid.setMaxWidth(Double.MAX_VALUE);
    this.grid.setAlignment(Pos.CENTER_LEFT);

    dialogPane.contentTextProperty().addListener(o -> updateGrid());
    updateGrid();

    setResultConverter((dialogButton) -> {
        ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
        return data == ButtonBar.ButtonData.OK_DONE ? table.getSelectionModel().getSelectedItem() : null;
    });
}
HomeController.java 文件源码 项目:Shield 阅读 27 收藏 0 点赞 0 评论 0
@FXML
private void refreshSongs(){
    ArrayList<String[]> songs = Functions.addRandomSongs();
    ObservableList<String[]> dataobv = FXCollections.observableArrayList();
    dataobv.addAll(songs);
    songList.setItems(dataobv);

}
Officebar.java 文件源码 项目:gatepass 阅读 15 收藏 0 点赞 0 评论 0
@SuppressWarnings({ "unchecked", "rawtypes" })
private ObservableList<XYChart.Series<String, Double>> getChartData() {
       double aValue = 0;
       ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList();
       Series<String, Double> aSeries = new Series<String, Double>();
       aSeries.setName("dates");

       String qcount= "SELECT date, COUNT(date) FROM  officeentry GROUP BY date";
    DBConnect.connect();
    try 
    {
        ResultSet rec = DBConnect.stmt.executeQuery(qcount);
        while(rec.next())
        {
            String date = rec.getString("date");
            int count= rec.getInt("COUNT(date)");
            aSeries.getData().add(new XYChart.Data(date, count));
            aValue = aValue + Math.random() - .5;
        }

    } catch (SQLException e) 
    {
        ErrorMessage.display("SQL Error", e.getMessage()+"\n error");
        e.printStackTrace();
    }

       answer.addAll(aSeries);
       return answer;
   }
StackedBarChartSample.java 文件源码 项目:marathonv5 阅读 16 收藏 0 点赞 0 评论 0
public StackedBarChartSample() {
    String[] years = {"2007", "2008", "2009"};
    CategoryAxis xAxis = CategoryAxisBuilder.create()
            .categories(FXCollections.<String>observableArrayList(years)).build();
    NumberAxis yAxis = NumberAxisBuilder.create()
                       .label("Units Sold")
                       .lowerBound(0.0d)
                       .upperBound(10000.0d)
                       .tickUnit(1000.0d).build();
    ObservableList<StackedBarChart.Series> barChartData = FXCollections.observableArrayList(
        new StackedBarChart.Series("Region 1", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 567d),
           new StackedBarChart.Data(years[1], 1292d),
           new StackedBarChart.Data(years[2], 1292d)
        )),
        new StackedBarChart.Series("Region 2", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 956),
           new StackedBarChart.Data(years[1], 1665),
           new StackedBarChart.Data(years[2], 2559)
        )),
        new StackedBarChart.Series("Region 3", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 1154),
           new StackedBarChart.Data(years[1], 1927),
           new StackedBarChart.Data(years[2], 2774)
        ))
    );

    StackedBarChart chart = new StackedBarChart(xAxis, yAxis, barChartData, 25.0d);
    getChildren().add(chart);
}
IFXContentBindingTest.java 文件源码 项目:infxnity 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void listInitializationTest()
{
    final ObservableList<Model> collection1 = FXCollections.observableArrayList(new Model("value1"),
                                                                                new Model("value2"),
                                                                                new Model("value3"),
                                                                                new Model("value4"));
    final List<String> collection2 = new ArrayList<>();

    IFXContentBinding.bind(collection2, collection1, Model::getText);

    assertEquals(Arrays.asList("value1", "value2", "value3", "value4"), collection2);
}
ProductController.java 文件源码 项目:campingsimulator2017 阅读 25 收藏 0 点赞 0 评论 0
public void sell(Product lastClickedValue) {
    ObservableList<Client> choices = FXCollections.observableArrayList();
    GenericDAO<Client, Integer> clientDao = new GenericDAO<>(Client.class);
    for (Client c : clientDao.findAll())
        choices.add(c);

    SellProductDialog dialog = new SellProductDialog(choices, lastClickedValue, this);
    dialog.showAndWait();

    dao.update(lastClickedValue);
}
InformationPane.java 文件源码 项目:Goliath-Overclocking-Utility-FX 阅读 25 收藏 0 点赞 0 评论 0
public InformationPane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);

    infoTable = new TableView<>(FXCollections.observableArrayList(InstanceProvider.getAttributes()));

    if(AppSettings.getShowExtraAttributeInfo())
    {
        cmdName = new TableColumn<>("Cmd Name");
        cmdName.setCellValueFactory(new PropertyValueFactory("cmdName"));

        cmdValue = new TableColumn<>("Cmd Value");
        cmdValue.setCellValueFactory(new PropertyValueFactory("cmdValue"));
    }

    displayName = new TableColumn<>("Name");
    displayName.setCellValueFactory(new PropertyValueFactory("displayName"));

    displayValue = new TableColumn<>("Value");
    displayValue.setCellValueFactory(new PropertyValueFactory("displayValue"));

    if(!AppSettings.getShowExtraAttributeInfo())
        infoTable.getColumns().addAll(displayName, displayValue);
    else
        infoTable.getColumns().addAll(cmdName, displayName, cmdValue, displayValue);

    infoTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    infoTable.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    infoTable.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    infoTable.setEditable(false);

    super.getChildren().add(infoTable);
}
SecondPageController.java 文件源码 项目:in-store-api-java-sdk 阅读 28 收藏 0 点赞 0 评论 0
private void initPendingTransactionsButton() {
    pendingTransactions.setOnAction(event -> {
        clearTable();
        result.setText("");

        // ==> Here is how the api in store requests are invoked. The Rx Observable pattern is used.
        // here a re some reference:
        //  - http://reactivex.io
        //  - https://github.com/ReactiveX/RxJava
        persistenceProtoCore
                .getTransactionHistory(20, null, "proposed")
                .subscribeOn(Schedulers.newThread())
                .take(1)
                .subscribe(historyTransactionsModel ->
                        Platform.runLater(() -> {
                                    acceptButton.setDisable(false);
                                    refuseButton.setDisable(false);
                                    refundButton.setDisable(true);

                                    transactionsTable.setItems(
                                            FXCollections.observableList(historyTransactionsModel.getList())
                                    );
                                    transactionsTable.refresh();
                                }
                        )
                );
    });
}


问题


面经


文章

微信
公众号

扫码关注公众号