Reputation: 71
this is in the css file
.yellow-bar { -fx-accent: yellow; }
.orange-bar{ -fx-accent: orange;}
.blue-bar{ -fx-accent: cyan;}
It show correctly the progress bar when its full but when it isnt it just appears with no progress!
double pro2 = obsModel.getCurrentShield()/obsModel.getMaxShield();
ColoredProgressBar pbShield = new ColoredProgressBar("blue-bar",pro2);
class ColoredProgressBar extends ProgressBar {
ColoredProgressBar(String styleClass, double progress) {
super(progress);
getStyleClass().add(styleClass);
}
Any idea why it won't show the progress when the progress isnt 1(100%) ?
Upvotes: 0
Views: 139
Reputation: 344
If the obsModel.getCurrentShield() and obsModel.getMaxShield() are integers, result will be either 0 or 1. If so, just cast one of them to double:
double pro2 = (double) obsModel.getCurrentShield()/obsModel.getMaxShield()
Upvotes: 1