لطفا کمک کنیییییییییییید (جاوا)
با سلام.
برنامه ی ثبت نام دانشجویی به زبان جاوا رو می خواستم.
البته خودم یه چیزایی نوشتم.
اگر کسی می تونه راهنمایی کنه.
مرسی.
کد:
package studentbank;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.Box;
import java.awt.Rectangle;
import javax.swing.JColorChooser;
import javax.swing.ButtonGroup;
import javax.swing.UIManager;
import java.io.*;
import javax.swing.JList;
import javax.swing.JComboBox;
import java.lang.*;
import java.lang.Object;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Applet1 extends Applet {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
ButtonGroup buttonGroup1 = new ButtonGroup();
ButtonGroup buttonGroup2 = new ButtonGroup();
CheckboxGroup checkboxGroup1 = new CheckboxGroup();
MenuBar menuBar1 = new MenuBar();
CheckboxGroup checkboxGroup2 = new CheckboxGroup();
CheckboxGroup checkboxGroup3 = new CheckboxGroup();
Button b1 = new Button();
Button b2 = new Button();
Button b3 = new Button();
Button b4 = new Button();
PopupMenu popupMenu1 = new PopupMenu();
TextField tf1 = new TextField();
TextField tf2 = new TextField();
TextField tf3 = new TextField();
TextField tf4 = new TextField();
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
TextField tf5 = new TextField();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
public class Student implements Serializable {
boolean packFrame = false;
public String name;
public int id;
public int ave;
public String LastName;
public String reshte;
}
Student ob1=new Student();
final static int m=20;
private static Student[] ob=new Student[m]; // public static void main(String args[]){
Choice choice1 = new Choice();
public void init(){
choice1.addItem("Name");
choice1.addItem("LastName");
choice1.addItem("ID");
choice1.addItem("average");
choice1.addItem("reshte");
int i=0;
/*DataOutputStream dos=new DataOutputStream(new FileOutputStream("c:\\st.txt"));
FileWriter fw = new FileWriter("c:\\f.txt");
for(i=0;i<20;i++){
fw.write(ob[i].name);
fw.write(ob[i].LastName);
fw.write(ob[i].id);
fw.write(ob[i].ave);
fw.write(ob[i].reshte);}
fw.close();
fw.flush();*/
try{jbInit();
FileWriter fw = new FileWriter("c:\\f.txt");
FileOutputStream f1=new FileOutputStream("c:\\ff.txt");
ObjectOutputStream inFile=new ObjectOutputStream(f1);
for( i=0;i<m;i++){
//ob1=(Student)inFile.writeUnshared();
fw.write("name="+ob1.name);
fw.write("id="+ob1.id);
fw.write("ave="+ob1.ave);
fw.write("LastName="+ob1.LastName);
fw.write("reshte="+ob1.reshte);
}//end of for
fw.close();
fw.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setLayout(null);
b1.setBackground(Color.green);
b1.setLabel("Add");
b1.setBounds(new Rectangle(19, 21, 67, 23));
b1.addActionListener(new Applet1_button1_actionAdapter(this));
b2.setBackground(new Color(255, 81, 154));
b2.setLabel("Remove");
b2.setBounds(new Rectangle(99, 21, 71, 23));
b2.addActionListener(new Applet1_button2_actionAdapter(this));
b3.setBackground(new Color(59, 132, 183));
b3.setLabel("search");
b3.setBounds(new Rectangle(186, 21, 65, 23));
b3.addActionListener(new Applet1_button3_actionAdapter(this));
b4.setBackground(Color.yellow);
b4.setLabel("Update");
b4.setBounds(new Rectangle(271, 21, 70, 23));
b4.addActionListener(new Applet1_button4_actionAdapter(this));
tf1.setBounds(new Rectangle(21, 66, 58, 22));
tf1.addActionListener(new Applet1_textField1_actionAdapter(this));
tf2.setBounds(new Rectangle(21, 111, 58, 21));
tf2.addActionListener(new Applet1_textField2_actionAdapter(this));
tf3.setBounds(new Rectangle(21, 161, 58, 23));
tf3.addActionListener(new Applet1_textField3_actionAdapter(this));
tf4.setBounds(new Rectangle(21, 212, 58, 24));
tf4.addActionListener(new Applet1_textField4_actionAdapter(this));
label1.setText("Name:");
label1.setBounds(new Rectangle(32, 45, 32, 19));
label2.setText("LastName:");
label2.setBounds(new Rectangle(21, 93, 52, 17));
label3.setText("ID:");
label3.setBounds(new Rectangle(37, 138, 23, 21));
label4.setText("average");
label4.setBounds(new Rectangle(19, 190, 63, 18));
label5.setText("reshte");
label5.setBounds(new Rectangle(24, 240, 39, 19));
tf5.setBounds(new Rectangle(21, 265, 58, 19));
choice1.setBounds(new Rectangle(187, 48, 63, 29));
choice1.addItemListener(new Applet1_choice1_itemAdapter(this));
this.add(b1);
this.add(b2);
this.add(b3);
this.add(b4);
this.add(tf1);
this.add(label2);
this.add(tf2);
this.add(tf3);
this.add(tf4);
this.add(tf5);
this.add(label5);
this.add(label4);
this.add(label1);
this.add(label3);
this.add(choice1);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
public void button1_actionPerformed(ActionEvent e) {
int i=0;
ob[i]=new Student();
for( i=0;i<m;i++)
{
ob[i].name=tf1.getText();
ob[i].LastName=tf2.getText();
ob[i].id=Integer.parseInt(tf3.getText());
ob[i].ave=Integer.parseInt(tf4.getText());
ob[i].reshte=tf5.getText();
if(i==20){System.out.println("*** LIST IS FULL ***");}
}//end of for
}
public void button2_actionPerformed(ActionEvent e) {
}
public void button3_actionPerformed(ActionEvent e) {
int i=0;
for(i=0;i<20;i++){
tf1.getText().compareTo(ob[i].name);
if(tf1.getText()==ob[i].name)
System.out.println(ob[i]);
}
}
public void button4_actionPerformed(ActionEvent e) {
}
public void textField1_actionPerformed(ActionEvent e) {
}
public void textField2_actionPerformed(ActionEvent e) {
}
public void textField3_actionPerformed(ActionEvent e) {
}
public void textField4_actionPerformed(ActionEvent e) {
}
public void textField5_actionPerformed(ActionEvent e) {
}
public void choice1_itemStateChanged(ItemEvent e) {
int i=0;
if ("Name".equals(choice1.getSelectedItem())){
//cardLayout1.show(lower, "panel1");
tf2.setVisible(false);
tf3.setVisible(false);
tf4.setVisible(false);
tf5.setVisible(false);
}
else if ("LastName".equals(choice1.getSelectedItem())){
// cardLayout1.show(lower, "panel2");
tf1.setVisible(false);
tf3.setVisible(false);
tf4.setVisible(false);
tf5.setVisible(false);
}
else if ("ID".equals(choice1.getSelectedItem())){
// cardLayout1.show(lower, "panel3");
tf1.setVisible(false);
tf2.setVisible(false);
tf4.setVisible(false);
tf5.setVisible(false);
}
else if ("average".equals(choice1.getSelectedItem())){
//cardLayout1.show(lower, "panel4");
tf1.setVisible(false);
tf2.setVisible(false);
tf3.setVisible(false);
tf5.setVisible(false);
}
else if ("reshte".equals(choice1.getSelectedItem())){
//cardLayout1.show(lower, "panel5");
tf1.setVisible(false);
tf2.setVisible(false);
tf3.setVisible(false);
tf4.setVisible(false);
}
}
}
class Applet1_choice1_itemAdapter implements ItemListener {
private Applet1 adaptee;
Applet1_choice1_itemAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.choice1_itemStateChanged(e);
}
}
class Applet1_textField4_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_textField4_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.textField4_actionPerformed(e);
}
}
class Applet1_textField3_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_textField3_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.textField3_actionPerformed(e);
}
}
class Applet1_textField2_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_textField2_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.textField2_actionPerformed(e);
}
}
class Applet1_textField1_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_textField1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.textField1_actionPerformed(e);
}
}
class Applet1_button4_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_button4_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button4_actionPerformed(e);
}
}
class Applet1_button3_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_button3_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button3_actionPerformed(e);
}
}
class Applet1_button2_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_button2_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button2_actionPerformed(e);
}
}
class Applet1_button1_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_button1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}