简体   繁体   中英

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 当酒吧满了!

Bars when they're not full! 不显示

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

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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