I have this code snippet (a part of code actually) where in one class I have all the Jbutton created for 26 alphabets. I have another class that keeps track of time and when the time is over or the game is over, I want to disable all the 26 JButtons in one shot.
here is the code for creating Jbuttons
public class DetailsPanel extends JPanel {
public DetailsPanel() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(" click here "));
JPanel letterPanel = new JPanel(new GridLayout(0, 5));
for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++) {
String buttonText = String.valueOf(alphabet);
JButton letterButton = new JButton(buttonText);
letterButton.addActionListener(clickedbutton());
letterPanel.add(letterButton, BorderLayout.CENTER);
}
add(letterPanel, BorderLayout.CENTER);
}
}
In my maincontrol class
, I want to turn off all the Jbuttons like in
public class maincontrol {
int counter;
DetailsPanel dp;
public maincontrol(DetailsPanel dp) {
this.dp = dp;
int counter = 0;
}
public void turnoff(){
if ( counter>10){
//turn off all here//
}
}
}