JavaFX Gridpane边框阴影和厚度似乎有所不同

JavaFX Gridpane边框阴影和厚度似乎有所不同,java,css,javafx,gridpane,Java,Css,Javafx,Gridpane,创建GridPane并在其上调用Snapshot()后,我得到的图像的网格线在颜色和宽度上似乎有所不同。越薄的越亮,越厚的越暗。有什么想法吗 //Create the gridpane GridPane gPane = new GridPane(); gPane.setSnapToPixel(true); //Set background, padding, and hgap and vgap to create the "border" gP

创建
GridPane
并在其上调用
Snapshot()
后,我得到的图像的网格线在颜色和宽度上似乎有所不同。越薄的越亮,越厚的越暗。有什么想法吗

     //Create the gridpane
     GridPane gPane = new GridPane();
     gPane.setSnapToPixel(true);

     //Set background, padding, and hgap and vgap to create the "border"
     gPane.setStyle("-fx-background-color: DARKGREY; -fx-padding: 1;"
                    +"-fx-hgap: 1; -fx-vgap: 1;");

     //Populate the gridpane with colored rectangles
     for(int i=0; i<mainApp.getItemList().size(); i++){ // rows
         for(int j=0; j<mainApp.getItemList().get(0).size(); j++){ //columns


             Color color = mainApp.getItemList().get(i).get(j).getValue().getDisplayColor();
                int r = (int) (color.getRed() * 255);
                int g = (int) (color.getGreen() * 255);
                int b = (int) (color.getBlue() * 255);

             Rectangle rect = new Rectangle(5,5);

             rect.setStyle("-fx-fill: rgb(" + r + "," + g + "," + b + ");");
             gPane.add(rect, j, i);
         }
     }
//创建网格窗格
GridPane gPane=新的GridPane();
gPane.setSnapToPixel(真);
//设置背景、填充、hgap和vgap以创建“边框”
gPane.setStyle(“-fx背景色:暗灰色;-fx填充:1;”
+“-fx hgap:1;-fx vgap:1;”;
//用彩色矩形填充网格窗格

对于(int i=0;我是否尝试过使用
setGridLinesVisible(true)
而不是背景色技巧?是的。它们不会显示在
snapshot()
中。我可能还应该提到我创建的图像已调整大小。据我所知
setGridLinesVisible(true)
应该只用于开发目的,因此我不会用它做任何事情,比如
snapshot()
。我认为这是JavaFX的一个渲染问题,但我不太确定,因此只是一个注释。我认为这实际上是大小调整算法的问题。如果导出并调整较小大小的网格,问题就会消失。