I'm trying to make a program that has methods to manipulate student information in one class (student address, grades etc.), creates several Student objects in the driver class and then uses another class to format a GUI where all the information can be well organized and displayed to the user.
I'm totally stuck as to how to create a class that would create the GUI and let me pass parameters to it.
Do you know how to write methods like getString() and stuff like that? Just make a public getString() method in your Student class and then call it from the GUI class when you want to display it.
Here are my other 2 classes. I've never done a getString() method, how would I use it? The very last comment is where I'm having the bulk of my trouble:
Ok, then do you know how to do it using System.out.println? It looks like you only have to display the info once, which means you don't really have to do a Swing gui and get data from another class more than once. Do you know how to use a JOptionPane? Here's the API from Sun. Here's how you can use it:
Eric Daly wrote:Ok, then do you know how to do it using System.out.println? It looks like you only have to display the info once, which means you don't really have to do a Swing gui and get data from another class more than once. Do you know how to use a JOptionPane? Here's the API from Sun. Here's how you can use it:
Thanks for your help. I should have mentioned that the project specifically states that I need to use a GUI layout manager.
I'm just now realizing that my average comes out as 0 in every single case. As you can see I needed to overload two methods to get an average, but for some reason it's wrong?
For your averages, it looks you never called any of the average methods in your code, so the default value for average will be zero for each student, until you set an average grade. By the way you set up your average methods to take in either 2 or 3 int values to be averaged, which makes whatever test scores you set earlier pointless. The average method is only working with the values passed in when you call the average method. Maybe you should have just one average method with no parameters, and it can average the test scores that are stored in the Student object. Otherwise your code looks good.
As for Swing, you might want to just make a JFrame and add either JTextFields or JLabels, it really doesn't matter. Check out Sun's Swing Tutorial, especially HelloWorldSwing.java. Maybe just do a bunch of JLabels and add them all to your JFrame.