GUI HELP PLEASE !!! Passing an array from main to different search windows

Hi I am hoping someone can help me with a poblem I am having with my code. I have to make a windows menu with 4 different searches and an add student function.

My problem is that I have to first create an initial set of students in the array and then pass this to the four searches and the add and I am not sure how to go about it. I have the students created but am unsure what I now need to do with the array and the size.

Could someone please have a look at my code and give me a few pointers as to the direction i need to proceed in as I am totally stumped.

Cheers

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

publicclass SearchingMenuextends JFrameimplements ActionListener

{

private JMenuBar jmb;

private JMenu jmStudentDetails, jmSystem,jmDisplay;

private JMenuItem jmiAdd,jmiExit;

private JMenuItem jmiSequential, jmiProbability, jmiOrdered, jmiBinary;

privateint size;

private Student [] stud;

private AddStudentDetails asd;

private SequentialSearch sSearch;

private ProbabilitySearch pSearch;

private OrderedSearch oSearch;

private BinarySearch bSearch;

SearchingMenu()

{

Container c = getContentPane();

c.setBackground(Color.LIGHT_GRAY);

jmb =new JMenuBar();

jmStudentDetails =new JMenu("Student Details");

jmSystem =new JMenu("System");

jmDisplay =new JMenu("Display");

jmb.add(jmStudentDetails);

jmb.add(jmSystem);

jmiAdd =new JMenuItem("Add");

jmiAdd.addActionListener(this);

jmiExit =new JMenuItem("Exit");

jmiExit.addActionListener(this);

jmStudentDetails.add(jmiAdd);

jmStudentDetails.add(jmDisplay);

jmSystem.add(jmiExit);

jmiSequential =new JMenuItem("Sequential");

jmiSequential.addActionListener(this);

jmiProbability =new JMenuItem("Probability");

jmiProbability.addActionListener(this);

jmiOrdered =new JMenuItem("Ordered");

jmiOrdered.addActionListener(this);

jmiBinary =new JMenuItem("Binary");

jmiBinary.addActionListener(this);

jmDisplay.add(jmiSequential);

jmDisplay.add(jmiProbability);

jmDisplay.add(jmiOrdered);

jmDisplay.add(jmiBinary);

setJMenuBar(jmb);

//size = createStudentDetails(stud,20);

}

publicvoid createStudentDetails( Student [] stud ,int size)

{

stud[ 0] =new Student(1000,"Mrs","Smith","Sarah","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 1] =new Student(1001,"Mr","Smith","Stan","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 2] =new Student(1002,"Mrs","Jones","Maggie","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 3] =new Student(1003,"Mr","David","Larry","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 4] =new Student(1004,"Mrs","Collins","Carol","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 5] =new Student(1005,"Mr","Sweeney","Darren","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 6] =new Student(1006,"Mr","Mc Feely","Jay","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 7] =new Student(1007,"Miss","Lynch","Kate","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 8] =new Student(1008,"Mr","Wilkinson","Hugh","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[ 9] =new Student(1009,"Mrs","Henry","Sheila","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[10] =new Student(1010,"Mrs","Gorman","Sarah","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[11] =new Student(1011,"Mr","Smyth","Ian","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[12] =new Student(1012,"Mrs","Jade","Maureen","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[13] =new Student(1013,"Mr","Collins","Davitt","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[14] =new Student(1014,"Mrs","Colbert","Patsy","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[15] =new Student(1015,"Mr","Lynch","John","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[16] =new Student(1016,"Mr","Mc Feely","Kevin","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[17] =new Student(1017,"Miss","Windsor","Kate","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[18] =new Student(1018,"Mr","Wilkins","Johnny","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

stud[19] =new Student(1019,"Mrs","Power","Maxine","F","01/01/1965","39 Dunmore Gardens","Creggan Estate","Derry","BT48 9NL","02871 279477");

}

publicvoid actionPerformed(ActionEvent e)

{

String s = e.getActionCommand();

JOptionPane.showMessageDialog(null,"Option " +s);

if(s.equals("Add"))

{

asd =new AddStudentDetails();

asd.setTitle("Add Student Details");

asd.setSize(1280,1024);

asd.setLocation(0,0);

asd.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

asd.setVisible(true);

}

if(s.equals("Exit"))

{

System.exit(0);

}

if(s.equals("Sequential"))

{

sSearch =new SequentialSearch();

sSearch.setTitle("Sequential Search");

sSearch.setSize(1280,1024);

sSearch.setLocation(0,0);

sSearch.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

sSearch.setVisible(true);

}

if(s.equals("Probability"))

{

pSearch =new ProbabilitySearch();

pSearch.setTitle("Probability Search");

pSearch.setSize(1280,1024);

pSearch.setLocation(0,0);

pSearch.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

pSearch.setVisible(true);

}

if(s.equals("Ordered"))

{

oSearch =new OrderedSearch();

oSearch.setTitle("Ordered Search");

oSearch.setSize(1280,1024);

oSearch.setLocation(0,0);

oSearch.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

oSearch.setVisible(true);

}

if(s.equals("Binary"))

{

bSearch =new BinarySearch();

bSearch.setTitle("Sequential Search");

bSearch.setSize(1280,1024);

bSearch.setLocation(0,0);

bSearch.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

bSearch.setVisible(true);

}

}//End of ActionPerformed

publicstaticvoid main (String args[])

{

SearchingMenu sm =new SearchingMenu();

sm.setSize(1280,1024);

sm.setLocation(0,0);

sm.setTitle("Student Application");

sm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

sm.setVisible(true);

}

}//End of Class

[16306 byte] By [JP_Traininga] at [2007-10-3 8:24:56]
# 1
[url http://forum.java.sun.com/thread.jspa?threadID=780518&messageID=4440014#4440014]Crosspost.[/url]
CaptainMorgan08a at 2007-7-15 3:31:07 > top of Java-index,Desktop,Core GUI APIs...