简体   繁体   English

JavaFX进度栏从单独的功能更改

[英]JavaFX progress bar changes from a seperate function

I have a JavaFX program that is essentially a button that fires off a function within the same class as main and start . 我有一个JavaFX程序,它实质上是一个按钮,它会在与mainstart相同的类中触发一个功能。 I'm trying to create a very basic, simple progress bar that lets the user know when the function is completed. 我正在尝试创建一个非常基本,简单的进度条,让用户知道该功能何时完成。

I fire off the function like so, where foo is my button and bar is my function that I also pass a numeric value to: 我像这样触发函数,其中foo是我的按钮, bar是我的函数,我也将数字值传递给:

foo.setOnAction(e -> bar("555"));

How do I pass a value like progress to and from the start function containing the button and progress bar and the foo function so my user can know when bar has finished running? 如何在包含按钮和进度栏以及foo函数的start函数之间传递诸如progress类的值,以便我的用户可以知道bar完成运行的时间?

Use the class inside javafx.property and bind two properties together. 使用javafx.property的类并将两个属性绑定在一起。

In the JavaDoc, ProgressIndictor and ProgressBar has progressProperty , which is an instance of DoubleProperty . 在JavaDoc中, ProgressIndictorProgressBar具有progressProperty ,它是DoubleProperty一个实例。 Property class has a bind method, which you can bind it to another ObservableValue or Property . Property类具有一个bind方法,您可以将其绑定到另一个ObservableValueProperty

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM