My code puts out the correct numbers, but some lines have one number on it and others have 3...There are so many lines output I can't see the top or bottom of the pane. Any help building my output message format would be appreciated.

import javax.swing.JOptionPane; public class findPrime { static Boolean isPrime (int num) { if (num % 2 == 0) return num == 2; int lim = (int) Math.sqrt(num); for (int i = 3; i <= lim; i+=2) if (num % i == 0) return false; return true; } public static void main (String args[]) { int counter = 1; String message = " "; for (int num = 2; num <= 1000; num++) { if (isPrime(num)) message += num + " "; if ((counter % 10) == 0) {message += "\n";} counter ++; } JOptionPane.showMessageDialog (null,"The first 1,000 primes are: " + message); } }