Keep a reference to your DetailsPanel. Add a method to it to disable the buttons, such as:
public class DetailsPanel extends JPanel {
private final JPanel letterPanel;
public DetailsPanel() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(" click here "));
letterPanel = new JPanel(new GridLayout(0, 5));
...
}
public void disableButtons() {
for (Component c : letterPanel.getComponents()) {
if (c instanceof JButton) c.setEnabled(false);
}
}
}
call it when you want to disable the buttons. Or be a little more clever, and do it based on the number of turns internally, which you pass in:
private static final int MAX_TURNS = 10;
public void updateButtons(int turn) {
for (Component c : letterPanel.getComponents()) {
if (c instanceof JButton) c.setEnabled(turn <= MAX_TURNS);
}
}