I am trying to create a grid of buttons. This is my code to create the grid (which works), but if I want to access a single button later on how would I go about doing that?
for(int i = 1; i<= row; i++){
for( int p=1; p<= col; p++){
boardPanel.add(new JButton());
}
}
Many Thanks
A Clements;
boardPanel?getSource()on the Event to find the button that fired the event. It really boils down to how you want to access the button, i.e. what are your requirements?