Clear gridPane in JavaFX and Maintain Grid Line

I am trying to make a simple game (this is school work) in JavaFX, and I am trying to clear the panel from the board, and then just redraw it. I tried many methods, and this is the only one I found that removes all parts of the board (visually) without creating a visual error that shows a fragment that has already been deleted but is still displayed.

So, I declare gridPaneas follows:

private GridPane gridPecas;

@Override
public void start(Stage primaryStage)
{
    gridPecas = new GridPane();
    gridPecas.setGridLinesVisible(true);

    paintBoard();

    // rest of the code to create and paint the Stage
 }

 private void paintBoard()
 {
    gridPecas.getChildren().clear();
    // Code to fill the board with ImageView and Images of the pieces
 }

The problem with this method is that when "gridPecas.getChildren (). Clear ();" called i'm just losing the grid lines out GridPanel.

How can I solve this problem?

+5
source share
4 answers

setGridLinesVisible(boolean) intended for debugging only:

http://docs.oracle.com/javafx/2/api/javafx/scene/layout/GridPane.html#setGridLinesVisible(boolean)

gridLines.

, ,

yourPane.getChildren().clear();

, gridPecas.getChildren().removeAll(pecasFX[i][j]);

+3

GridPane Gridlines :

    Node node = grid.getChildren().get(0);
    grid.getChildren().clear();
    grid.getChildren().add(0,node);

Node * GridPane (* GridLinesVisible ?) Gridlines (, , ).

, Node

+3

a : grid.getChildren(). keepAll (grid.getChildren(). get (0));

+1

. imageViews . "" , "" .

0

All Articles