java - 未设置评级值

标签 java javafx rating controlsfx

我正在使用controlsfx的评级功能http://fxexperience.com/controlsfx/features/#rating .我正在尝试从数据库中获取每个文件的评级值。虽然返回的值没有设置在星星上。

enter image description here

这是我的代码:

File apps = new File("D:\\SERVER\\Server Content\\Apps");
    File[] applist = apps.listFiles();
    ArrayList<File> applistar = new ArrayList<>();
    rathboxar = new ArrayList<>();

    for (File f : applist) {
        applistar.add(f);
    }

    try {
        for (File file : applistar) {
            if (!file.getName().equals("icons")) {
                String appname = file.getName();
                System.out.println("app name:" + appname);
                *String strat = downloadcontroller.getThatRating(appname);* //retrieving rating value for each file
                System.out.println("Rating string:" + strat);
                double ratval = Double.parseDouble(strat);
                rating = new Rating();
                rating.setPartialRating(true);
                *rating.setRating(ratval);*// setting the value on stars
                rating.setMaxSize(100, 20);
                ratinghbox = new HBox();
                ratinghbox.getChildren().add(rating);
                rathboxar.add(ratinghbox);
            }
        }

    } catch (RemoteException ex) {
        Logger.getLogger(HomeUI_2Controller.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(HomeUI_2Controller.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(HomeUI_2Controller.class.getName()).log(Level.SEVERE, null, ex);
    }

    File tempfile2 = new File("D:\\client\\Temp\\appicons");
    File[] filelist1 = tempfile2.listFiles();

    gridpane.setAlignment(Pos.CENTER);
    gridpane.setPadding(new Insets(20, 20, 20, 20));

    gridpane.setHgap(20);
    gridpane.setVgap(20);

    ColumnConstraints columnConstraints = new ColumnConstraints();
    columnConstraints.setFillWidth(true);
    columnConstraints.setHgrow(Priority.ALWAYS);
    gridpane.getColumnConstraints().add(columnConstraints);

    int imageCol = 0;
    int imageRow = 0;

    for (int i = 0; i < filelist1.length; i++) {
        //System.out.println(filelist1[i].getName());

        image = new Image(filelist1[i].toURI().toString());

        pic = new ImageView();
        pic.setFitWidth(130);
        pic.setFitHeight(130);


        pic.setImage(image);
        vb = new VBox();
        *vb.getChildren().addAll(pic, (Button) btnar.get(i), (HBox) rathboxar.get(i));*//adding rathboxar to vbox

        gridpane.add(vb, imageCol, imageRow);
        GridPane.setMargin(pic, new Insets(2, 2, 2, 2));
        imageCol++;

        // To check if all the 3 images of a row are completed
        if (imageCol > 2) {
            // Reset Column
            imageCol = 0;
            // Next Row
            imageRow++;
        }

    }

最佳答案

这是一个错误:从 source code for the skin 可以清楚地看出当 partialRating 设置为 true 时,当评级以编程方式更改时,它不会处理更新 UI。

您应该在 https://bitbucket.org/controlsfx/controlsfx/issues?status=new&status=open 提交问题报告

关于java - 未设置评级值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26059490/

相关文章:

javafx-2 - 在全屏 JavaFX 中更改场景

javafx - 如何使用 JavaFX 为未装饰的舞台添加阴影?

php - 在 Woocommerce 中以编程方式添加带有评分的产品评论

java - 屏幕上有图像 "wrap around"。 JavaFX

java - 为什么在使用 gradle 的子项目中使用时缺少 jackson 库依赖项?

Java - 如何找到类和其他级别的依赖关系

java - 通过程序动态启用或禁用特定 EditText View 的验证

android - 在android的评分栏中将初始值设置为第一颗星

php - 计算评级系统的平均值

java - Android GridLayout - 屏幕的一半