Java Project Questions

Java Project Questions

Hello sir ,I want Course Form in JAVA SWING that includes following contents-
1)Course Id -Numeric
2)Course NAME-TEXT
3)Course Duration-NUMBERS
4)Course Fees-NUMBERS
I want to to add,Update,Delete Course Details into to Access Database,and then this course table connected with Student Admission Form
that form includes Course Name(in JComboBox).
How i can Do that,plz Help Me Sir.
View Answers

March 3, 2010 at 4:52 PM

Hi Friend,

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

class Project {
JFrame f;
JPanel p1,p2,p3;
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,deletebtn ;

Project(){
f=new JFrame("Form");
p1=new JPanel(new GridLayout(5,2));
p2=new JPanel(new GridLayout(5,2));
p3=new JPanel(new GridLayout(2,2));
tp=new JTabbedPane();
l1=new JLabel("Course ID:");
l2=new JLabel("Course Name:");
l3=new JLabel("Duration:");
l4=new JLabel("Fees:");
l5=new JLabel("Enter Course ID:");
l7=new JLabel("Course ID:");
l8=new JLabel("Course Name:");
l9=new JLabel("Duration:");
l10=new JLabel("Fees:");
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");
deletebtn=new JButton("Delete");
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(deletebtn);
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){
int value1=Integer.parseInt(tf1.getText());
String value2=tf2.getText();
int value3=Integer.parseInt(tf3.getText());
int value4=Integer.parseInt(tf4.getText());
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
PreparedStatement st=con.prepareStatement("insert into course(id,name,duration,fees) values(?,?,?,?)");
st.setInt(1,value1);
st.setString(2,value2);
st.setInt(3,value3);
st.setInt(4,value4);
st.executeUpdate();
JOptionPane.showMessageDialog(p1,"Data is successfully inserted into database.");
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(p1,"Error in submitting data!");
}
}
});

March 3, 2010 at 4:53 PM

continue..

deletebtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=tf5.getText();
int ide=Integer.parseInt(value1);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
PreparedStatement st=con.prepareStatement("DELETE FROM course WHERE id = ?");
st.setInt(1,ide);
st.executeUpdate();
JOptionPane.showMessageDialog(p3,"Record is deleted successfully.");
con.close();
}
catch(Exception exp3){
JOptionPane.showMessageDialog(p3,"Error in deleting record.");
}
}
});
editbtn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){

String value=tf7.getText();
int ide=Integer.parseInt(value);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
PreparedStatement st=con.prepareStatement("select * from course where id=?");
st.setInt(1,ide);
ResultSet res=st.executeQuery();
res.next();
tf7.setText(Integer.toString(res.getInt(1)));
tf8.setText(res.getString(2));
tf9.setText(res.getString(3));
tf10.setText(Integer.toString(res.getInt(4)));
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(p2,"Can not edit data");
}
}
});
editbtn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){

try
{
int x=JOptionPane.showConfirmDialog(p2,"Confirm edit? All data will be replaced");
if(x==0){
try{
int value1=Integer.parseInt(tf7.getText());
String value2=tf8.getText();
int value3=Integer.parseInt(tf9.getText());
int value4=Integer.parseInt(tf10.getText());

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
System.out.println("update course set name='"+value2+"', duration='"+value3+"',fees='"+value4+"' where id='"+value1+"'");
st.executeUpdate("update course set name='"+value2+"' , duration="+value3+",fees="+value4+" where id="+value1+"");
JOptionPane.showMessageDialog(p2,"Updated successfully");
con.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(p2,"Error in updating edit fields");
}
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(p2,"Error");
}
}
});
}
void dis()
{
f.getContentPane().add(tp);
tp.addTab("Add Record",p1);
tp.addTab("Edit Record",p2);
tp.addTab("Delete Record",p3);

f.setSize(350,180);
f.setVisible(true);
f.setResizable(true);
}
public static void main(String z[]){
Project pro=new Project();
pro.dis();
}
}
Thanks









Related Tutorials/Questions & Answers:
Java Project Questions - Java Beginners
Java Project Questions  Hello sir ,I want Course Form in JAVA SWING that includes following contents- 1)Course Id -Numeric 2)Course NAME-TEXT 3)Course Duration-NUMBERS 4)Course Fees-NUMBERS I want to to add,Update,Delete
Java Project Questions - Java Beginners
Java Project Questions  Hello sir ,I want Course Form in JAVA SWING... java.awt.event.*; import java.sql.*; import java.util.*; class Project { JFrame f... ; Project(){ f=new JFrame("Form"); p1=new JPanel(new GridLayout(5,2)); p2=new
Advertisements
Java Project Questions - Java Beginners
Java Project Questions  Hello sir ,I want Course Form in JAVA SWING...*; import java.sql.*; import java.util.*; class Project { JFrame f...; JScrollPane sp1; JButton savebtn,resetbtn,editbtn1,editbtn2,deletebtn ; Project
Project Architecture - Java Interview Questions
Project Architecture  i want project architectre diagram and also flow plz explian in layers of the project architecture flow?i want discrpption for this one
project security tool - Java Interview Questions
project security tool  what are the security tools are available for online money transactions(through credit/debit cards)in the project? mean my project is insurance project,payments are through on line for this process we
thin-client project - Java Interview Questions
thin-client project  what is thin-client project??? Plz help me  Hi Friend, Please visit the following link: http://www.roseindia.net/linux/linux-thin-client-terminals.shtml Hope that it will be helpful for you
Java - Java Interview Questions
Java  Questions on Java
java questions - Java Interview Questions
java questions  HI ALL , how are all of u?? Plz send me the paths of java core questions and answers pdfs or interview questions pdfs or ebooks :) please favor me best books of interviews questions for craking
java - Java Interview Questions
Helpful Java Interview questions   Need Helpful Java Interview questions
JAVA QUESTIONS - Java Beginners
java questions asked in interview oracle  Hi all, Does anyone have a list of Java questions that is generally asked in Interview at Oracle
interview questions - Java Interview Questions
interview questions for Java  Hi Any one can u please post the interview point of questions.Warm Regards, Satish
interview - Java Interview Questions
interview  kindly guide me some interview questions of Java
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
jvm - Java Interview Questions
jvm  Can you provide some JVM Questions for Java Interview preparation
Struts - Java Interview Questions
Struts Interview Questions  I need Java Struts Interview Questions and examples
help me - Java Interview Questions
interview questions java pdf   Do you have any PDF for Java Interview questions
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
java questions
java questions  why java is not open source
java questions
java questions  why java is not open source
java questions
java questions  can i write an inner class in an interface
java questions
java questions  what is the proper way of code our program?   Have a look at the following link: Core Java Tutorials
Java Questions
Java Questions   How to dispaly my databsae records in my jsp page using collections My java class   Visit Here
Java Questions
Java Questions   How to dispaly my databsae records in my jsp page using collections My java class   Visit Here
java questions
java questions  what is the difference between wait() and sleep() methods in thread class
java questions
java questions  how is java platform independent? is jsp thread safe... (known as the Platform independent) is one of the important key feature of java language that makes java as the most powerful language. When Java Code
java Questions
java Questions  do we need to implement all methods interface if yes I want example code please send me
Java Questions
Java Questions  How can I set classpath for java classes through java.... There no general use of setting class path from the Java program.ADS... in Java class. Unless you are developing the applications like tomcat you really
java certification questions - Java Beginners
java certification questions  i need java certification questions
java - Java Interview Questions
Java Development  I need a Job in Java Development..so preparing for it. Can anyone please guide me how to prepare and what are the common questions that can be asked at interview
Interview Questions - What is Java?
Interview Questions - What is Java?  What is Java?   Hi, Java is high level programming langue developed by James Gosling. Now Java.... Check in detail at: What is Java? View all Java Interview Questions
java - Java Interview Questions
questins in java .wat normally v see in interviews (tech apptitude)is one line... simple 2 answer..but it becomes complicated wen v see questions in jumbled form... ...or any of the sites....which handles these kind of questions...   Hi
Java - Java Interview Questions
://www.roseindia.net/java/example/java/util/HashTable.shtml Thank you for posting questions. Rose India Team
JAVA - Java Interview Questions
JAVA  i need objective Questions and answers ( with 4 or 5 choice) in JAVA. Can anyone help me?   H1!! pl. mail your email id to [email protected]. I will send you within 2-3 days. Krishna
hint - Java Interview Questions
hint  Dear roseindia, i want the java interview question and the corresponding question answers.   Hi Friend, Please visit... of interview questions and their answers. Thanks  thanks for your
java - Servlet Interview Questions
Java Design Patterns Interview Questions and Answers  I need to know Java Design Patterns with the help of Interview Questions and Answers  Hi malli,GenericServlet is the super class of HttpServlet calssjava soft
java interview - JSP-Interview Questions
java interview  what type of questions would be asked to a 3 years experience person in java? can anyone please provide list of topics or interview questions for 3 years experience in java
java servlets - Servlet Interview Questions
java servlets  sir, i am doing a project of online examination. i have built a question page that has 25 questions. i have use four radio button for each question(ie four choices). how can i send value and name of each
java - Java Interview Questions
Java interview questions and answers for freshers  Please provide me the link of Java interview questions and answers for freshers  Hi friend,class Point{ int x, y; Point(){ System.out.println("default"
Java Questions & Java FAQ
Java Questions & Java FAQ  ... have listed the Java Questions which are commonly asked. Our collection... are the list of those Java Questions and FAQs. Question: It is said that the code
Interview Questions - Where Java is used?
Interview Questions - Where Java is used?  Hello, Where Java is used? Thanks   Hi, Java is used for creating various types... being Used?. View all interview questions at Java Interview Questions with Answers
java - Servlet Interview Questions
java  servlet interview questions  Hi friend, For Servlet interview Questions visit to : http://www.roseindia.net/interviewquestions/servlet/ Thanks
java - Java Interview Questions
java  i want to java&j2ee interview questions. Regards Akhilesh Kumar  Hi friend, I am sending you a link. This link will help you. Read for more information. http://www.roseindia.net/interviewquestions
Interview Questions - How Java is Used?
Interview Questions - How Java is Used?  Hi, How Java is Used... For Creating Applets Check: Where is Java being Used? View all interview questions at Java Interview Questions with Answers page. Thanks
Java interview questions and answers
Java interview questions and answers   what is garbage collection? What is the process that is responsible for doing that in java? Ans.Reclaiming... in Java? Ans. Runtime.getRuntime().exec(â?¦.) 5.What is the basic difference
java - JSP-Interview Questions
. These are all fairly fundamental questions, try purchasing any introduction to Java...java  whats meant by the following terms as applied in java:- 1.object oriented programming. 2.void 3.private 4.protected thanks homey.  
Questions in Swing - Java Beginners
Questions in Swing  I have created combobox in my program. I added MCA,MBA,others etc.. If i click others then a new textbox should open beside that combobox for that am in need of coding in java swing.  Hi Friend
Core Java Interview questions and answers
Core Java Interview questions and answers  .... So, we have tried to create most frequently asked Core Java Interview Questions and answers in one place.ADS_TO_REPLACE_1 These Core Java Interview Questions
Java interview questions
Java interview questions  Plz answer the following questions..... The type long can be used to store values in the following range: a. -263 to 263 - 1 b. -231 to 231 - 1 c. -264 to 264 d. -232 to 232 - 1 Which
java - Java Interview Questions
java  wh is abstract in project? how is module in java project
java - Java Interview Questions
Java Programming  What is Java Programming language

Ads