Java Project Questions

Ads

 
 

Share on Google+Share on Google+

sushant
Java Project Questions
2 Answer(s)      7 years ago
Posted in : Java Beginners
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.
Ads
View Answers

March 19, 2010 at 2:18 PM


Hi Friend,

Try the following code:

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 19, 2010 at 2:19 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

Ads









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 Project
Java Project  Java project using with collection and generic with observer design pattern
java project
java project  how many tables are required in backend for online examination system project in jsp If backend is SQL
java project
java project  i would like to get an idea of how to do a project by doing a project(hospital management) in java.so could you please provide me with tips,UML,source code,or links of already completed project with documentation
JAVA project
JAVA project  How to extract tags and their corresponding properties of a "cascading style sheet" file using JAVA
java - Java Interview Questions
Helpful Java Interview questions   Need Helpful Java Interview questions
java project
java project  Connecting to MySQL database and retrieving and displaying data in JSP page by using netbeans
Java Project
Java Project  how to write a program for competitive exams(for student practice purpose)? for example: first student have to login after login then he has to select the particular exam what he want to write i.e the exam may
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 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
Project
Project  How to show Questions randomly so that no two student get the same questions in online examination system project in Java Server Pages..., Either you can make 3 different tables consisting of different questions. Set
interview - Java Interview Questions
interview  kindly guide me some interview questions of Java
java certification questions - Java Beginners
java certification questions  i need java certification questions
Java Project - Java Beginners
Java Project  Dear Sir, Right now i am working in java image processing project. In that i have to split in one image like Texture, color..., Please visit the following links: http://www.roseindia.net/java/example
Java Project - Java Beginners
Java Project  Hello Sir I want Mini Student Admission System project in java with Source Code and Back end Database is MS Access. plz Give That Sir its Very Very Urgent
java project - Java Beginners
java project  how can i download the source code for the project college admission system
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
Java Project - Java Beginners
Java Project  I'm a III yr Engineering student. I've been ask 2 prepare a project on Java. Can u plz suggest me some topics ?   Hi friend... Java project topic with more information. 1. Asset Management 2. Shopping
java project - Java Beginners
java project  hi this amol i wish to do a project on banking software in java can u help   how can i help u .. and what the kind... adam certified java programmer certified websphere   ya sure!! what
Java Project - Java Beginners
Java Project  Hey, thanks for everything your doing to make us better. Am trying to work on a project in java am in my first year doing software Engineering and the project is m end of year project. Am really believing
java project - Java Beginners
java project  project for internet banking  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/jsp/bank.shtml Thanks
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
JAVA PROJECT - Java Beginners
JAVA PROJECT  Dear Sir, I going to do project in java " IT in HR, recruitment, Leave management, Appriasal, Payroll" Kindly guide me about... etc. I am doing project first time. waiting for your reply, Prashant
Java Project - Java Beginners
Java Project   Write a Java program to create simple Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division... the following link: http://www.roseindia.net/java/example/java/swing/calculator
java project - Java Beginners
java project  Can u pls suggest me any ideas for my B.E project? It's urgent... Front end---Java Back end----Oracle IDE---------Netbeans5.5 It should not be completely database oriented... I am not allowed to develop any

Ads

 
Advertisement null

Ads