java, plz help me in doing this

Ads
 

java, plz help me in doing this

# Write a small record management application for a school. Tasks will be Add Record, Edit Record, Delete Record, List Records. Each Record contains: Name(max 100 char), Age, Notes(No Maximum Limit). No database should be used. All data must be stored in one or two files. Listing records should print the names of the users in alphabetical order. And the important thing is, total file should not be re-written for every add/delete operation.
View Answers

January 4, 2010 at 10:55 AM

Hi Friend,

Try the following code:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;

class StudentApplication {
JFrame f;
JPanel p1,p2,p3,p,p4;
JTabbedPane tp;
ImageIcon btnimg1,btnimg2;
JLabel l1, l2, l3, l4,l5,l6,l7,l8,l9,l10;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9,tf10;
JScrollPane sp1;
JButton savebtn,resetbtn,editbtn1,editbtn2,delBtn,viewBtn;
StudentApplication(){
f=new JFrame("Form");
p=new JPanel(new GridLayout(2,1));
p1=new JPanel(new GridLayout(5,2));
p2=new JPanel(new GridLayout(5,2));
p3=new JPanel(new GridLayout(2,2));
p4=new JPanel();
tp=new JTabbedPane();
l1=new JLabel("ID:");
l2=new JLabel("Name:");
l3=new JLabel("Age:");
l4=new JLabel("Notes:");
l5=new JLabel("Enter ID to delete Record:");
l7=new JLabel("ID:");
l8=new JLabel("Name:");
l9=new JLabel("Age:");
l10=new JLabel("Notes:");
tf1=new JTextField(12);
tf2=new JTextField(12);
tf3=new JTextField(12);
tf4=new JTextField(12);
tf5=new JTextField(12);
tf6=new JTextField(12);
tf7=new JTextField(12);
tf8=new JTextField(12);
tf9=new JTextField(12);
tf10=new JTextField(12);
savebtn=new JButton(" Add ");
resetbtn=new JButton(" Reset");
editbtn1=new JButton(" Edit ");
editbtn2=new JButton(" Save");
delBtn=new JButton("Delete");
viewBtn=new JButton("View");
final JTextArea area=new JTextArea(10,20);
final JScrollPane pane=new JScrollPane(area);
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p1.add(l3);
p1.add(tf3);
p1.add(l4);
p1.add(tf4);
p1.add(savebtn);
p1.add(resetbtn);
p2.add(l7);
p2.add(tf7);
p2.add(l8);
p2.add(tf8);
p2.add(l9);
p2.add(tf9);
p2.add(l10);
p2.add(tf10);
p2.add(editbtn1);
p2.add(editbtn2);
p3.add(l5);
p3.add(tf5);
p3.add(delBtn);
p.add(p3);
p4.add(pane);
p4.add(viewBtn);
pane.setVisible(false);

resetbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
}
});
savebtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=tf1.getText();
String value2=tf2.getText();
String value3=tf3.getText();
String value4=tf4.getText();
try{
File file=new File("school.txt");
FileWriter fstream = new FileWriter(file,true);
BufferedWriter out = new BufferedWriter(fstream);
out.write(value1+" "+value2+" "+value3+" "+value4);
out.newLine();
out.close();
JOptionPane.showMessageDialog(null,"Data is successfully inserted.");
}
catch(Exception e){}
}
});

January 4, 2010 at 10:56 AM

continue..

delBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
File f1=new File("new.txt");
File f2=new File("school.txt");
try{
String value=tf5.getText();
BufferedWriter output= new BufferedWriter(new FileWriter(f1));
BufferedReader freader =new BufferedReader(new FileReader(f2));
String s;
while ((s=freader.readLine())!=null){
String []f = s.split(" ");
String id = f[0];
String name = f[1];
String c = f[2];
String note = f[3];
if (!id.equals(value) ){
output.write(s );
output.newLine();
}
}
freader.close();
output.close();
}
catch(Exception e){}
f2.delete();
f1.renameTo(f2);
}
});
editbtn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=tf7.getText();
File f=new File("school.txt");
try{
BufferedReader freader =new BufferedReader(new FileReader(f));
String s;
while ((s=freader.readLine())!=null){

String []st = s.split(" ");
String id = st[0];
String name = st[1];
String c = st[2];
String note = st[3];
if (id.equals(value) ){
tf7.setText(id);
tf8.setText(name);
tf9.setText(c);
tf10.setText(note);
}
}
freader.close();
}
catch(Exception e){}

}
});
editbtn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String t1=tf7.getText();
String t2=tf8.getText();
String t3=tf9.getText();
String t4=tf10.getText();
File f3=new File("new.txt");
File f4=new File("school.txt");
try{

BufferedWriter output= new BufferedWriter(new FileWriter(f3));
BufferedReader freader =new BufferedReader(new FileReader(f4));
String s;
while ((s=freader.readLine())!=null){
String []f = s.split(" ");
String id = f[0];
String name = f[1];
String c = f[2];
String note = f[3];
if (!id.equals(t1) ){
output.write(s );
output.newLine();
}
}
freader.close();
output.write(t1+" "+t2+" "+t3+" "+t4);
output.close();
}
catch(Exception e){}
f4.delete();
f3.renameTo(f4);
}
});
viewBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
pane.setVisible(true);
try{
FileReader fr = new FileReader("school.txt");
BufferedReader myInput = new BufferedReader(fr);

String s;
StringBuffer b = new StringBuffer();
while ((s = myInput.readLine()) != null) {
b.append(s);
b.append("\n");
}
area.setText(b.toString());
}
catch(Exception e){}
}
});
f.getContentPane().add(tp);
tp.addTab("View Record",p4);
tp.addTab("Add Record",p1);
tp.addTab("Edit Record",p2);
tp.addTab("Delete Record",p);
f.setSize(450,180);
f.setVisible(true);
}
public static void main(String z[]){
StudentApplication app=new StudentApplication();
}
}
Hope that it will be helpful for you.
Thanks

March 9, 2010 at 8:32 PM

The answer above..giving me the error of NoClassDefFoundError...

Ads









Related Tutorials/Questions & Answers:
plz help me - Java Beginners
plz help me  deepak hw can i create a data grid in jsp and also how can i connect to the data base plz help me  to create data grid in jsp use html tables with borders. to connect to data base use scriptlets. ex
Help me plz in Probablity distribution of Java
Help me plz in Probablity distribution of Java  Hello, I have...% is insert or update queries. Which distribution to use and how to achieve it.. Plz help thanks for your time
Advertisements
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 ‚?§ 200; 3x1 + 5x2 ‚?§ 150; 5x1 + 4x2 ‚?• 100; 8x1 + 4x2 ‚?≠‚?• 80, x1 ‚?• 0, x2 ‚?• 0
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
Plz Help Me
Plz Help Me  Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40... traffic light on the frame. We have used java swing. It may help you. import
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
help me plz befor 27 februry
help me plz befor 27 februry  what is rung with this ?? help me plzzzz import java.util.Scanner; public class Initials { public static void main (String [] args) { String firstname,lastname
java coding help plz ?
java coding help plz ?  Given two integers N and M (N √Ę‚?į¬§ M), output all the prime numbers between N and M inclusive, one per line. N and M will be positive integers less than or equal to 1,000,000,000. The difference
interview question plz help me and thers
interview question plz help me and thers  A college is good if it satisfies the following conditions: 1.Its number of students is greater than 1000. 2.If the name ends wih a character 'e', then it should not start with character
plz Help me find the correct programs answers
plz Help me find the correct programs answers   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff... INDICA" and "TATA NANO" respectively. Plz mail me your answers
Plz provide me all the material for Java
Plz provide me all the material for Java  Plz provide me all the material for Java   Please go through the following link: Java Tutorials
help me plz:-Merge multiple jasper files into Single one
help me plz:-Merge multiple jasper files into Single one  how to Merge multiple jasper files into Single one word doc
Help me - Java Beginners
Help me  I m using session in my project session is activated and admin_home.jsp page will be display but data r not displayed plz guide what is incorrect my code
PLZ Need some help JAVA...HELP !!
PLZ Need some help JAVA...HELP !!  Create a class names Purchase Each purchase contains an invoice number, amount of sale and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set
help me .. Java
help me .. Java  ReadStudentsData that takes as parameters an array NAMES of String and another array SCORES of int. It should read an unspecified number of students‚?? scores and names. This method will return the number
population problem plz help me befor 16 March 2011 !!
population problem plz help me befor 16 March 2011 !!  the Q is : How can i count how many years it will take for the population of a town to go over 30.000 .. consider that it Increases 10% every year ?? And this is my code &
plz help me any one as fast as u can
plz help me any one as fast as u can  A thief Muthhooswamy planned to escape from **** jail. Muthhooswamy is basically a monkey man and he is able to jump across the wall. He practiced to cross a wall and he is able to jump 'X
plz help
plz help  what is the procedure and code to design an interactive GUI in java using swings
Plz Help
Plz Help  Hello Guys!! Plz. Help I need to write a program to display the astrological sign based on your birthday for example If we enter the date of birth in the following format from console--13/08/1990 it should give you
sir i want small project with of health care system with struts and hibernate plz help me
sir i want small project with of health care system with struts and hibernate plz help me  sir i want small project on health care system with struts and hibernate plz help me
plz help -java project very urgent
plz help -java project very urgent  ? Ford furniture is a local furniture store in acts, and they as CS graduate students to implement a software system to generate various reports for them at the end of each month. You

Ads