[英]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程序,它实质上是一个按钮,它会在与
main
和start
相同的类中触发一个功能。 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中,
ProgressIndictor
和ProgressBar
具有progressProperty ,它是DoubleProperty
一个实例。 Property
class has a bind method, which you can bind it to another ObservableValue
or Property
. Property
类具有一个bind方法,您可以将其绑定到另一个ObservableValue
或Property
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.