Add the contracts to a StringBuilder in the loop and display the JOptionPane after the loop.