MrSano43
MrSano43

Reputation: 71

Progress bar doesn´t show progress if not full

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);
        }

Bars when its full1 When bars are full!

Bars when they're not full! Doesn't show

Any idea why it won't show the progress when the progress isnt 1(100%) ?

Upvotes: 0

Views: 139

Answers (1)

Andrew Fomin
Andrew Fomin

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

Related Questions