JavaFX Gridpane border shades and thickness appear to vary

819 views Asked by At

After creating a GridPane and calling Snapshot() on it, the image that I get has gridlines that appear to vary in color and width. The thinner ones are lighter, the thicker are darker. Any thoughts?

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

There are 0 answers