4 Replies - 1573 Views - Last Post: 03 September 2013 - 05:16 AM Rate Topic: -----

#1 benno2202  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 02-September 13

Need Help with displaying Arrays in GUI

Posted 02 September 2013 - 11:01 PM

I need help with a school assignment. I have to write a GUI Java Program that dislays students names and their relevant school results for a number of subjects. I have to have the students names and results for the subject dislplayed in four arrays.

Below is a hint provided by the teacher. The program must also have a sort student names alphabetically by use of a JButton and the same for a search student textfield and must also sort one of the 3 classes from highest to lowest, also with the use of a JButton.

Thanks a heap for any help, I have also attached a picture of what the finished program must look like

import...

public class AcademicManager extends JFrame
{
// student name, score variables declarartions- using one dimension array
private String [] names={"David Johnson","Michael Hack","William North",
"Linda Peterson","Amy Condor","Bob OConnor",
"Joshua Guy","Tracey Gubb","Helen Laffin",
"Nichloas Minz","Mark Malone","Kate Platt"};
private int [] scoreJP...........
………………………………………..
//button declararion, JTextArea declaration etc
private JButton sortByNameButton;
......................
//Constructor - you can call helper method inside the constructor
public AcademicManager()
{
//GUI component layout and inner class (or call a helper method) here
//inner class
class DoListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String actionString = e.getActionCommand();
if (actionString.equals("Sort by Name"))
{
sortByName(); //call method
}
..........................
..........................
}
}//end of inner class
}//end of constructor

//sort by name, bubble sort
private void sortByName()
{
//write your code
}
//sort results by English scores, bubble sort
private void sortByJP()
{
//write your code
}
//search a particular student result by entering name
private void search( )
{
//write your code
}
//display statistics
private void statistics()
{
//write your code
}//end of method
//find min value -- helper method
private int findMin(int[] a)
{
//write your code
}
// find max value -- helper method
private int findMax(int[] a)
{
//write your code
}
//display data on textAera
public void DisplayResultData()
{
//write your code.....
}
//main method
public static void main(String[] args)
{
JFrame frame = new AcademicManager();
.........
}
}// end of class definition

This post has been edited by GregBrannon: 03 September 2013 - 03:50 AM
Reason for edit:: Added code tags.


Is This A Good Question/Topic? 1
  • +

Replies To: Need Help with displaying Arrays in GUI

#2 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Need Help with displaying Arrays in GUI

Posted 03 September 2013 - 12:05 AM

You only have array of string, nothing else.
Did you try to write code for the rest of the methods?
Look here how many sorting methods Array class have. Start from here

This post has been edited by Michael26: 03 September 2013 - 12:08 AM

Was This Post Helpful? 0
  • +
  • -

#3 ChrisNt  Icon User is offline

  • cute bug

Reputation: 262
  • View blog
  • Posts: 896
  • Joined: 31-July 13

Re: Need Help with displaying Arrays in GUI

Posted 03 September 2013 - 12:09 AM

Also next time you post remember to post your code between code tags so its easier for everyone to read your code.

This post has been edited by ChrisNt: 03 September 2013 - 12:10 AM

Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3489
  • View blog
  • Posts: 15,769
  • Joined: 20-September 08

Re: Need Help with displaying Arrays in GUI

Posted 03 September 2013 - 03:42 AM

If your teachers are advocating the use of parallel arrays in the context of sorting, not only are they not teaching you object-oriented programming (in which case they shouldn't be using Java) but they are making your job much harder for the task in question
Was This Post Helpful? 0
  • +
  • -

#5 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Need Help with displaying Arrays in GUI

Posted 03 September 2013 - 05:16 AM

Make student class that has attributes(names, grades ... ) and methods (SortBy name, find Max, find Min ... ) then make list of Students. That would be OOP way.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1