the problem is with your code order you added the buttons to contentpane before initializing them, change them as below:

jbArray = new JButton [countryArray.length];

for (int i = 0; i<jbArray.length; i++)
    jbArray[i] = new JButton(alist.get(i).getName());
    ImageIcon ic = new ImageIcon (alist.get(i).getName() +".png");


for (int i = 0; i< jbArray.length; i++)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top