You've got the grades array declared twice. Once locally within main(), and the second globally. When you ask for the user to input their grades, you assign the various positions to the array within main(). However, when you get the information in your addTextToPane(), you call on the globally declared grades array.
Once you delete the following in the main(), the problem is resolved.
int[] grades = new int[50];