Ok, so I've had my three classes, and nothing seems to be running for me. It compiles well, just my swing components don't appear.

Here's the code:

GUI Class

Code :

import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class StudentGUI extends JFrame implements ActionListener { static JButton[] action; static JFrame[] frame; static JPanel[] panel; static JTextArea[] area; public StudentGUI() { super("StudentGrades.java"); action = new JButton[10]; action[0] = new JButton("Construct"); action[0].addActionListener(this); action[0].setMnemonic(KeyEvent.VK_C); for(int i = 1; i < action.length; i++) { action[i] = new JButton("Action " + i); action[i].addActionListener(this); } area = new JTextArea[8]; for(int i = 0; i < area.length; i++) { area[i] = new JTextArea(); area[i].setLineWrap(true); area[i].setEditable(false); } Container c = getContentPane(); JPanel buttonPanel = new JPanel(new FlowLayout()); for(int i = 0; i < action.length; i++) { buttonPanel.add(action[i]); } c.setBackground(Color.white); c.add(buttonPanel, BorderLayout.CENTER); panel = new JPanel[9]; for(int i = 0; i < panel.length;) { panel[i] = new JPanel(new FlowLayout()); } frame = new JFrame[9]; for(int i = 0; i < frame.length; i++) { frame[i] = new JFrame("Action Window"); frame[i].getContentPane(); frame[i].setBounds(300,300,100,100); frame[i].setResizable(true); frame[i].setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame[1].setVisible(true); } for(int i = 0; i < panel.length; i++) { panel[i].add(area[i]); frame[i].add(panel[i], BorderLayout.CENTER); } } public void actionPerformed(ActionEvent e) { JButton button = (JButton)e.getSource(); Random r = new Random(); StudentGrades sg = null; int[] scores = null; int[] sorted = null; if(button == action[0]) { sg = new StudentGrades(r.nextInt(21)+1); } if(button == action[1]) { scores = sg.getTestGrades(); frame[0].setVisible(true); for(int i = 0; i < scores.length; i++) { area[0].append(scores[i] + " "); } } if(button == action[2]) { frame[0].setVisible(false); sorted = sg.selectionSortB(scores); frame[1].setVisible(true); for(int i = 0; i < sorted.length; i++) { area[1].append(sorted[i] + " "); } } /*if(button == action[3]) { frane[1].setVisible(false); frame[2].setVisible(true); area[2].append("The array is " + sg.isEqual(sorted)); }*/ if(button == action[4]) { frame[2].setVisible(false); frame[3].setVisible(true); int highest = sg.highestGrade(sorted); area[3].append("The Highest grade is " + highest); } if(button == action[5]) { frame[3].setVisible(false); frame[4].setVisible(true); int lowest = sg.lowestGrade(sorted); area[4].append("The Lowest grade is " + lowest); } if(button == action[6]) { frame[4].setVisible(false); frame[5].setVisible(true); double average = sg.averageGrade(sorted); area[5].append("The average grade is " + average); } if(button == action[7]) { frame[5].setVisible(false); frame[6].setVisible(true); int median = sg.medianGrade(sorted); area[6].append("The median grade is " + median); } if(button == action[8]) { frame[6].setVisible(false); frame[7].setVisible(true); int mode = sg.modeGrade(sorted); area[7].append("The mode is " + mode); } } }

Method class

Code :

import java.util.Random; public class StudentGrades { private int[] studentGrades; public StudentGrades(int students) { Random r = new Random(); studentGrades = new int[students]; for(int i = 0; i < studentGrades.length; i++) { studentGrades[i] = r.nextInt(101); } } public int[] getTestGrades() { int[] testGrades = new int[studentGrades.length]; for(int i = 0; i < studentGrades.length; i++) { testGrades[i]= studentGrades[i]; } return testGrades; } public int[] selectionSortB(int[] nums) { int size = nums.length; // Same as version A, but sorts in ascending order int first, current, least, temp; for(first = 0; first < size; first = first + 1) { least = first; for(current = first+1; current < size; current = current + 1) { if (nums[current] < nums[least]) { least = current; } } temp = nums[least]; nums[least] = nums[first]; nums[first] = temp; } return nums; } /*public boolean isEqual(int[] arr) { }*/ public int highestGrade(int[] arr) { int max = 0; for(int i = 0; i < arr.length; i++) { if(arr[i] > max) { max = arr[i]; } } return max; } public int lowestGrade(int[] arr) { int min = arr[0]; for(int i = 1; i < arr.length; i++) { if(arr[i] < min) min = arr[i]; } return min; } public double averageGrade(int[] arr) { double total = 0.0; for(int i = 0; i < arr.length; i++) { total += (double)arr[i]; } double avg = total / arr.length; return avg; } public int medianGrade(int[] arr) { int median = (arr[0] + arr[arr.length - 1]) / 2 ; return median; } public int modeGrade(int[] arr) { int[] count = new int[arr.length]; for(int i = 0; i < arr.length; i++) { count[i]++; } int max = 0; for(int i = 0; i < count.length; i++) { if(count[i] > max) { max = count[i]; } } return count[max]; } }

Client class

Code :

public class Student { public static void main(String[] args) { StudentGUI sgu = new StudentGUI(); sgu.setBounds(400,400,100,100); sgu.setVisible(true); sgu.setDefaultCloseOperation(sgu.EXIT_ON_CLOSE); sgu.setResizable(true); } }

Thanks for the help.