Adding JButton using loop (for) does nothing <p>I'm trying to add various JButtons to a JPanel using "for" but doesn't work. No compilation or other errors. Buttons just won't appear. </p> <p>A bit of context, I create an ArryList in another class ("GestorFrigo") that gets data from DataBase, this works fine, the array has all the data and there's no problem getting back the data from the array.</p> <p>This is my code: Thanks in advance.</p> <pre><code> import gestor.GestorFrigo; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseListener; import java.util.ArrayList; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import javax.swing.JScrollBar; @SuppressWarnings("serial") public class VentanaInterior extends JFrame { private JPanel contentPane; private JButton btnPerfiles; private JButton btnAadir; private JButton btnRecetas; private JScrollBar scrollBar; private GestorFrigo frigo; private ArrayList&lt;JButton&gt; botones; private ArrayList&lt;Object&gt; boton; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { VentanaInterior frame = new VentanaInterior(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public VentanaInterior() { //Componentes setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 556, 363); setLocationRelativeTo(null); setTitle("Tu Frigorífico Inteligente"); setIconImage(new ImageIcon(getClass().getResource("img/logo.png")).getImage()); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); btnPerfiles = new JButton("Perfiles"); btnPerfiles.setBounds(0, 302, 96, 23); contentPane.add(btnPerfiles); btnAadir = new JButton("A\u00F1adir alimento"); btnAadir.setBounds(369, 302, 148, 23); contentPane.add(btnAadir); btnRecetas = new JButton("Recetas"); btnRecetas.setBounds(96, 302, 103, 23); contentPane.add(btnRecetas); scrollBar = new JScrollBar(); scrollBar.setBounds(523, 0, 17, 325); contentPane.add(scrollBar); JButton btnQueso = new JButton(); btnQueso.setBounds(24, 35, 62, 61); contentPane.add(btnQueso); frigo = new GestorFrigo(); //creamos el gestor String imagen = frigo.getArray().get(1).getImagen(); //cogemos la imagen asociada al alimento btnQueso.setIcon(new ImageIcon("src/img/"+imagen)); for(int i=0;i&lt;frigo.getArray().size();i++){ JButton boton = new JButton(); String imagen2 = frigo.getArray().get(i).getImagen(); boton.setIcon(new ImageIcon("src/img/"+imagen2)); contentPane.add(boton); } } } </code></pre>