I have a questions about using array I have a method that creates JButton for a JPanel. I used JButton[] to store 7 buttons in it.
The problem is those buttons must be setEnable(false) initially. they are only enabled when openButton is clicked.
I would like to create another method that just take all elements from JButton[] and set them Enable. How can I do that?
private JButton filterButtons() {
//set layout for buttons
setLayout(new BorderLayout());
//Array to store description of buttons
final String[] filterNames = {myEdgeDetect.getDescription(),
myEdgeHighlight.getDescription(),
myFlipHorizontal.getDescription(),
myFlipVeritcal.getDescription(),
myGrayscale.getDescription(),
mySharpen.getDescription(),
mySoften.getDescription()};
final JButton[] filterButtons = new JButton[filterNames.length];
//This panel store buttons on north
final JPanel buttonPanel = new JPanel();
//Start to print buttons
for (int i = 0; i < filterNames.length; i++) {
filterButtons[i] = new JButton(filterNames[i]);
filterButtons[i].setEnabled(false);
filterButtons[i].addActionListener(null);
filterButtons[i].setActionCommand(" " + i);
buttonPanel.add(filterButtons[i]);
}