Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Urgent Help - Java Ass'ment

0 views
Skip to first unread message

Sandra

unread,
Aug 1, 2000, 3:00:00 AM8/1/00
to
To anyone that can help me really, really soon!! I am so poor at programming
but I have this one and only subject to clear before graduating. Please
please please pleeeeeeaseee help this poor individual (ME!).

I need help developing a simple java application prg for a school ass'ment.
I need an answer no later than the next 24hrs. Can anyone help me?

I have done the interface part of the program and I now need an array to
store and sort the records.
I also haven't put the listeners or events on most of the butons

I am using JDK 1.2.2 version downloaded from the sun microsystems web page

thank you so much and I hope to hear from someone of you soon!!!!!!!!
you can post your kind, wonderful, caring response in the newsgroup rather
than emailing me!
my source code so far: (if you don't want to run or read the source code, is
there anyone or a web site you can refer me to?)


import javax.swing.*;
import javax.swing.table.*;
import javax.swing.text.*;
import javax.swing.event.*;

import java.awt.*;
import java.awt.event.*;
import java.awt.Toolkit;

public class Student3 implements MouseListener, ItemListener,
ActionListener{

private Frame f1, f2;
private MenuBar mb1, mb2;
private Menu m1, m2, m3, m4, m5, m6, m7, m8;
private MenuItem mi11, mi12, mi41, mi42, mi61, mi62;
private CheckboxMenuItem cbi1, cbi2, cbi3, cbi4, cbi5, cbi6;

private Label l1, l2, l3, l4, l5, l6, l7;
private TextField name, ic, ph, id, email;

JSplitPane p1;
JPanel one, two, three;
JTabbedPane tabArea;
JLabel studentFormTabLabel, displayTabLabel;


file://FUNCTION "MAIN"
public static void main(String args[]) {
Student3 std3 = new Student3();
std3.go();
}


file://METHOD go
public void go() {
f1 = new Frame("STUDENT MENU");
MenuBar mb1 = new MenuBar();
Menu m1 = new Menu("File");
MenuItem mi11 = new MenuItem("New");
mi11.addActionListener(this);
MenuItem mi12 = new MenuItem("Open File");
m1.add(mi11);
m1.addSeparator();
m1.add(mi12);

Menu m2 = new Menu("Quit");

Menu m3 = new Menu("Help");

mb1.add(m1);
mb1.add(m2);
mb1.add(m3);
f1.setMenuBar(mb1);


file://CREATE NEW FRAME TO INPUT DETAILS
f2 = new Frame ("STUDENT DETAILS DIRECTORY");

MenuBar mb2 = new MenuBar();

Menu m4 = new Menu("File");
MenuItem mi41 = new MenuItem("New");
mi11.addActionListener(this);
MenuItem mi42 = new MenuItem("Open File");
m4.add(mi41);
m4.addSeparator();
m4.add(mi42);

Menu m5 = new Menu("Sort");
CheckboxMenuItem cbi1 = new CheckboxMenuItem("Ascending -NAME",false);
CheckboxMenuItem cbi2 = new CheckboxMenuItem("Descending -NAME",false);
CheckboxMenuItem cbi3 = new CheckboxMenuItem("Ascending -IC", false);
CheckboxMenuItem cbi4 = new CheckboxMenuItem("Descending -IC", false);
CheckboxMenuItem cbi5 = new CheckboxMenuItem("Ascending -ID", false);
CheckboxMenuItem cbi6 = new CheckboxMenuItem("Descending -ID", true);
m5.add(cbi1);
m5.addSeparator();
m5.add(cbi2);
m5.addSeparator();
m5.add(cbi3);
m5.addSeparator();
m5.add(cbi4);
m5.addSeparator();
m5.add(cbi5);
m5.addSeparator();
m5.add(cbi6);

cbi1.addItemListener(this);
cbi2.addItemListener(this);
cbi3.addItemListener(this);
cbi4.addItemListener(this);
cbi5.addItemListener(this);
cbi6.addItemListener(this);

Menu m6 = new Menu("Save");
MenuItem mi61 = new MenuItem("Yes");
MenuItem mi62 = new MenuItem("No");
m6.add(mi61);
m6.addSeparator();
m6.add(mi62);
Menu m7 = new Menu("Quit");

Menu m8 = new Menu("Help");

mb2.add(m4);
mb2.add(m5);
mb2.add(m6);
mb2.add(m7);
mb2.add(m8);
f2.setMenuBar(mb2);

file://Tab Panel, p1 & three
JTabbedPane tabArea = new JTabbedPane(JTabbedPane.TOP);
ImageIcon icon = new ImageIcon("iconSmileySmall.gif");
JLabel studentFormTabLabel = new JLabel("New Student Form");
JLabel displayTabLabel = new JLabel("Display Student Records");
studentFormTabLabel.setHorizontalAlignment(JLabel.CENTER);
displayTabLabel.setHorizontalAlignment(JLabel.CENTER);

JSplitPane p1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, one, two);
p1.setDividerLocation(200);
one = new JPanel(new GridLayout(0,1,10,60));
two = new JPanel(new GridLayout(0,1,10,60));
l2 = new Label("STUDENT DETAILS");
Font fontLb = new Font("SansSerif",Font.BOLD,16);
Font fontTxt = new Font("SansSerif",Font.BOLD|Font.ITALIC,16);

l3 = new Label("Student Name: ");
l3.setFont(fontLb);
name = new TextField("",10);
name.setForeground(Color.blue);
name.setFont(fontTxt);

l4 = new Label("IC Number: ");
l4.setFont(fontLb);
ic = new TextField("",60);
ic.setForeground(Color.blue);
ic.setFont(fontTxt);


l5 = new Label("Telephone Number: ");
l5.setFont(fontLb);
ph = new TextField("",60);
ph.setForeground(Color.blue);
ph.setFont(fontTxt);


l6 = new Label("Infromatics ID: ");
l6.setFont(fontLb);
id = new TextField("",60);
id.setForeground(Color.blue);
id.setFont(fontTxt);


l7 = new Label("Email Address (optional): ");
l7.setFont(fontLb);
email= new TextField("",60);
email.setForeground(Color.blue);
email.setFont(fontTxt);


one.add(l3);
two.add(name);

one.add(l4);
two.add(ic);

one.add(l5);
two.add(ph);

one.add(l6);
two.add(id);

one.add(l7);
two.add(email);

three = new JPanel(new BorderLayout());
three.add(displayTabLabel);

p1.add(one);
p1.add(two);
tabArea.addTab("New Student Form",icon, p1);
tabArea.addTab("Display All Records",icon, three);
tabArea.setSelectedIndex(0);
f2.add(tabArea);
f2.pack();

file://DISPLAY THE FIRST FRAME f1
f1.addWindowListener(w1);
f1.setBackground(Color.blue);
f2.addWindowListener(w1);
f1.setSize(640,480);
f2.setSize(640,480);
f1.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
f2.setVisible(true);
f1.setVisible(false);
}

public void itemStateChanged (ItemEvent ev) {
String state = "deselected";
if (ev.getStateChange() == ItemEvent.SELECTED){
state = "selected";
}
}


file://MouseListener EVENTS
public void mouseClicked(MouseEvent e) {
}

public void mouseEntered(MouseEvent e) {
}

public void mouseExited(MouseEvent e) {
}

public void mousePressed(MouseEvent e) {
}

public void mouseReleased(MouseEvent e) {
}


file://WindowListener inner class
WindowListener w1 = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};

}


0 new messages