JavaFX cover and uncover Button text in a Button field
<p>Okay, so when initializing the playboard for Minesweeper, my code iterates through all the buttons created in the pane and sets the text to either an X for bomb or a number (indicating how many bombs are neighbors). If it's neither it does nothing. But now I wonder how to hide that text when initializing the game so that it can be uncovered and later recovered by clicking the mouse?</p>

<p><a href="https://i.stack.imgur.com/gIZoD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gIZoD.png" alt="enter image description here"></a></p>

<p>Here's the iteration logic:</p>

<pre><code>//iterate through rows and columns to fill board with random bombs
for (int y = 0; y &lt; model.Y_FIELDS; y++) {
    for (int x = 0; x &lt; model.X_FIELDS; x++) {
        Field field = new Field(x, y, Math.random() &lt; 0.2, model);
        model.array[x][y] = field;
        root.getChildren().add(field);

    }
}

for (int y = 0; y &lt; model.Y_FIELDS; y++) {
    for (int x = 0; x &lt; model.X_FIELDS; x++) {
        Field field = model.array[x][y];

        if (field.isBomb())
            continue;

        long number = field.getSurrounding().stream().filter(f -&gt; f.isBomb()).count();

        if (number &gt; 0)
            field.board.setText(String.valueOf(number));
    }
}
</code></pre>

<p>I would like them to be blank at first. Where do I put <code>setText("")</code>? In a left mouse click event I want to uncover them. That would look something like <code>if(leftmouseclick)</code> then <code>set.Visible</code> or something like that...</p>