2014-09-26 75 views
0

我使用controlsfx http://fxexperience.com/controlsfx/features/#rating .i'm的评价功能,试图从数据库中获取的评价值的每个文件。尽管返回的值未在星号上设置。评价值不设置

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

    } 
+0

是ratval'的'接收到的值,当你分析它有什么问题报告? – SimY4 2014-09-26 12:42:04

+0

@ ratval的SimY4值为4.5 – 2014-09-26 12:44:21

+0

@KumaranathFernado也应该工作,除非你得到任何异常或在另一个循环中添加'rathboxar'别的地方 – ItachiUchiha 2014-09-26 12:51:16

回答

1

这是一个错误:它是从source code for the skin相当清楚,当partialRating设置为true,它不处理更新时,在界面的评级调整编程。

你应该在文件https://bitbucket.org/controlsfx/controlsfx/issues?status=new&status=open

+0

啊!是的,它不适用于部分评级。我不知道如何去忽视了这么长时间:) – ItachiUchiha 2014-09-26 13:12:58

+0

我[转贴提出的修正(https://bitbucket.org/controlsfx/controlsfx/issue/377/set-rating-doesnt-work-when-partialrating#评论 - 12591583)为RatingSkin,如果你需要一个快速修复。我建议至少等到乔纳森推一个官方回购。 – 2014-09-26 15:52:17