Inputs an integer and finds all factors of that number.
int number = Integer.parseInt(s);
Converts the String s to an int (number).
if (number % fac == 0)
Calculates number mod fac (remainder of division).
If it's zero, then fac is an even factor of number.
public void findFactors()
Creates a method which can be executed in actionPerformed.
for (int fac=2; fac <= number; fac = fac+1 )
Makes a loop to count from 2 up to number
nums.add( fac + "");
Adds another line to the List nums. Must use fac+"" to
change the number fac into a String before adding it to the List.
Comments
The loop and other commands for finding factors could be written directly into the actionPerformed method. This makes a mess in larger programs, with more Buttons and longer algorithms. It is better to use actionPerformed like a "switch-board" to choose the desired method, but to code these methods separately.