2015-08-03 1 views
0

Je rencontre un problème graphique bizarre dans mon application. La situation est que je crée des GridPanes et les ajoute à un parent GridPane qui se trouve dans un ScrollPane. Cependant, lors du défilement, certains problèmes étranges commencent à se produire. Voici une photo: (Désolé d'avoir à utiliser des liens, je n'ai pas assez de réputation pour poster des images).JavaFX Graphical Glitch

http://s11.postimg.org/x9eg8bz4z/Glitch.png

Voici une photo de ce qu'il devrait ressembler à:

http://s11.postimg.org/cqjk39l7n/Normal.png

Voici mon code:

private static class Controller implements Initializable { 

    @FXML private GridPane projectsPane; 

    @Override 
    public void initialize(URL location, ResourceBundle resources) { 
    //I first create some objects to be used when 
    //creating the GridPanes in the following loop, 
    //but I have removed the code for simplicity 
    for(AvailableProject availableProject : availableProjects) { 
      GridPane projectPane = new GridPane(); 
      projectPane.setBackground(new Background(new BackgroundFill(Color.DARKGREY, CornerRadii.EMPTY, Insets.EMPTY))); 
      ColumnConstraints column1 = new ColumnConstraints(); 
      column1.setPercentWidth(50); 
      ColumnConstraints column2 = new ColumnConstraints(); 
      column2.setPercentWidth(50); 
      projectPane.getColumnConstraints().addAll(column1, column2); 
      projectPane.setPadding(new Insets(5)); 
      Label projectName = new Label(availableProject.projectName); 
      GridPane.setValignment(projectName, VPos.CENTER); 
      projectPane.add(projectName, 0, 0); 
      TextFlow description = new TextFlow(new Text(availableProject.description)); 
      description.setMaxSize(200, 100); 
      GridPane.setValignment(description, VPos.CENTER); 
      projectPane.add(description, 0, 1); 
      Label category = new Label(availableProject.category); 
      GridPane.setValignment(category, VPos.CENTER); 
      GridPane.setHalignment(category, HPos.RIGHT); 
      projectPane.add(category, 1, 0, 1, 2); 
      projectsPane.add(projectPane, 0, yRow); 
      yRow++; 
      Pane pane = new Pane(); 
      pane.setMinHeight(15); 
      projectsPane.addRow(yRow, pane); 
      yRow++; 
     } 
    } 
} 

J'ai essayé de simplifier le code pour le rendre nettoyeur, mais je posterai le reste si nécessaire.

Merci!

Répondre

0

Je semble avoir trouvé la solution. Par le regard, c'est vraiment un bug. Je rapporterai à Oracle plus tard. Il semble que le problème était que j'avais padding dans mon ScrollPane. Par mes tests, si le rembourrage était supérieur à 5, les problèmes se produiraient. Une solution de contournement consiste à affecter le remplissage au GridPane parent plutôt qu'au ScrollPane.