情况:
这是代码: public class Controller实现Initializable {
@FXML
private ProgressBar mProgress1, mProgress2;
@FXML
private ProgressIndicator mProgressIndicator;
@FXML
private JFXSlider mSlider1 , mSlider2;
@FXML
private TextField mTextField;
@FXML
private Label mLabel;
@Override
public void initialize(URL location, ResourceBundle resources) {
mTextField.textProperty().bindBidirectional(mSlider1.valueProperty(),
NumberFormat.getNumberInstance());
mLabel.textProperty().bind(mTextField.textProperty().concat("%"));
mProgress1.progressProperty().bind(mSlider1.valueProperty());
mProgress2.progressProperty().bind(mSlider2.valueProperty());
mProgressIndicator.progressProperty().bind(mProgress1.progressProperty());
}
}
的xml:
<AnchorPane prefHeight="564.0" prefWidth="372.0"
xmlns="http://javafx.com/javafx/8.0.112"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="sample.Controller">
<children>
<AnchorPane fx:id="lowerPane" layoutX="6.0" layoutY="353.0"
prefHeight="211.0" prefWidth="361.0">
<children>
<ProgressBar fx:id="mProgress1" layoutX="78.0" layoutY="155.0"
prefWidth="205.0" progress="0.0" />
<ProgressBar fx:id="mProgress2" layoutX="84.0" layoutY="137.0"
prefWidth="193.0" progress="0.0" />
<Label fx:id="mLabel" layoutX="148.0" layoutY="189.0" text="
Progress" />
</children></AnchorPane>
<TextField fx:id="mTextField" layoutX="286.0" layoutY="270.0"
prefHeight="25.0" prefWidth="78.0" />
<ProgressIndicator fx:id="mProgressIndicator" layoutX="313.0"
layoutY="301.0"
progress="0.0" />
<JFXSlider fx:id="mSlider1" blockIncrement="0.0"
indicatorPosition="RIGHT"
layoutX="116.0" layoutY="275.0" max="1.0" />
<JFXSlider fx:id="mSlider2" layoutX="116.0" layoutY="233.0" max="1.0"
value="0.1" />
</children>
</AnchorPane>
答案 0 :(得分:0)
ProgressBar
和ProgressIndicator
的最小值为-1,最大值为1。
因此,如果您的JFoenixProgressBar
的最小值为0,最大值为1,则表示正常。
通常,ProgressIndicator
的值应为:
double indicatorValue=foenixProgressBarMaximumValue/foenixProgressBarCurrentValue;
如果foenixProgressBarCurrentValue
为0,还要添加一个。让它成为三元表达式:
double indicatorValue=((foenixProgressBarCurrentValue!=0)?foenixProgressBarMaximumValue/foenixProgressBarCurrentValue:0);
要使其作为绑定工作,您可以将其设为DoubleProperty
或使用Bindings
类方法。
提及如果最小值和最大值均为0,则需要修改上述内容。