无需选择即可读取TableView单元格值| JavaFX

时间:2019-05-19 20:42:16

标签: javafx tableview

我有一个#include <iostream> constexpr int realToIntegerPeterShirley(const double value) { return int(255.99 * value); } #define F2B(f) ((f) >= 1.0 ? 255 : (int)((f)*256.0)) constexpr int realToIntegerInkredibl(const double value) { return F2B(value); } const int realToIntegerMarkByers(const double value) { return std::floor(value >= 1.0 ? 255 : value * 256.0); } constexpr int realToIntegerToolmakerSteve(const double value) { return std::round(value * 255.0); } constexpr int realToIntegerErichKitzmueller(const double value) { return value*255.999; } constexpr int realToInteger(const float value) { return realToIntegerInkredibl(value); } int main() { { double value = 0.906285; std::cout << realToIntegerMarkByers(value) << std::endl; // output '232' std::cout << realToIntegerPeterShirley(value) << std::endl; // output '231' } { double value = 0.18345; std::cout << realToIntegerInkredibl(value) << std::endl; // output '46' std::cout << realToIntegerToolmakerSteve(value) << std::endl; // output '47' } { double value = 0.761719; std::cout << realToIntegerVertexwahn(value) << std::endl; // output '195' std::cout << realToIntegerErichKitzmueller(value) << std::endl; // output '194' } } ,它以指定的时间间隔更新服务器中的数据。其中的一个字段是数字,如果该数字超过100,我想创建一个警报。如何在不让用户选择的情况下读取特定单元格的数据。

在逻辑上,我想在刷新表时检查条件。我有一个int main() { std::mt19937_64 rng; // initialize the random number generator with time-dependent seed uint64_t timeSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::seed_seq ss{uint32_t(timeSeed & 0xffffffff), uint32_t(timeSeed>>32)}; rng.seed(ss); // initialize a uniform distribution between 0 and 1 std::uniform_real_distribution<double> unif(0, 1); // ready to generate random numbers const int nSimulations = 1000000000; for (int i = 0; i < nSimulations; i++) { double currentRandomNumber = unif(rng); int firstProposal = realToIntegerMarkByers(currentRandomNumber); int secondProposal = realToIntegerErichKitzmueller(currentRandomNumber); if(firstProposal != secondProposal) { std::cout << "Different conversion with real " << currentRandomNumber << std::endl; return -1; } } } 填充表,所以我假设我把这段代码检查这里的数字是否超过100。

TableView

for loop是保存Player player = new Player(); monitoredPlayersTable.setItems(FXCollections.observableArrayList(player.updateMonitoredPlayers())); for (int i = 0; i < DisplayPlayers.OUTSTANDING_PLAYERS.size(); i++) { firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); highScoreCol.setCellValueFactory(new PropertyValueFactory<>("highscore")); //then i try to get the value of my highscore cell String highscore = (String) highScoreCol.getCellObservableValue(player).getValue(); if (Integer.parseInt(highscore) >100) { //show alert } } 数据的monitoredPlayersTable

我在if语句中有一个警报,但是即使单元格中的数据大于100,也没有显示该警报。我该如何实现这一目标?

0 个答案:

没有答案