At first, im not a native speaker, so please excuse my mistakes ^^
I am writing a program that gets all primes up to a specific integer and want to print all primes in the end at a JOptionPane.
Actually, i do calculate all primes in a seperate function, return them all in one integer array, safe this array into a string and then print the string in the JOptionPane.
But unfortunately, I just get only one!! extremely long line where all the integers are printed, crossing both monitors. So when I print for example all primes up to 10000, I get all the primes in one line.
I want, that for example only 100 primes are in one line, and then the rest gets printed in the next line. But how can I achieve this?
check_button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int x = Integer.parseInt(InputField1.getText());
int prime_numbers[];
String all_prime_String = Arrays.toString(number_theory.primes(x));
System.out.println(Arrays.toString(number_theory.primes(x)));
JOptionPane.showMessageDialog(Math_Collection_Gui.this, all_prime_String, "Ergebnis", JOptionPane.INFORMATION_MESSAGE);
}
});
The number_theory.primes(x) function returns the array of all primes up to x, and then i safe this array in a string.
Like i said, my problem is, that all values of the array get printed in one line. So is it possible, to fix the lenght of the box or something, that the program is forced to jump to the next line? Or do you got any other tricks for me?