Here's some Java Application Coding For Minor Projects......Just Copy The Below Code....
1.Student Management system.
Main.java
import java.sql.*;
public class Main {
Connection con;
Statement st;
ResultSet rs;
public String bitu;
public Main(){
connect();
}
public void connect(){
try {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String db3 ="jdbc:odbc:db4";
con = DriverManager.getConnection(db3);
//st =con.createStatement();
st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch(Exception ex){
}
}
public static void main(String[] args) {
// TODO code application logic here
new Main();
//new s_info();
//new ad_login();
//new acd_info();
new base_file();
}
}
---------------------------------------------------------------------------------------------------------------
ad_login.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//import java.sql.*;
public class ad_login extends Main {
JFrame f;
JLabel uname;
JLabel pass;
JLabel age;
JTextField t;
JTextField t1;
JButton b1 = new JButton("Login");
JButton b2 = new JButton("Cancel");
public ad_login(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(300,200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
uname = new JLabel("User Name");
pass = new JLabel("Password");
t = new JTextField(15);
t1 = new JPasswordField(10);
JPanel p = new JPanel();
p.add(uname);
p.add(t);
p.add(pass);
p.add(t1);
p.add(b1);
p.add(b2);
f.add(p);
try{
}catch(Exception ex){
}
}
public void btnAction(){
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
//new s_info();
String us1 =t.getText();
String pw1 =t1.getText();
//JOptionPane.showMessageDialog(null,us1);
try{
String sql = "select * from ad_login where username ='" + us1+"' and password='" + pw1+"'";
//JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next())
{
//JOptionPane.showMessageDialog(null, rs.getString(1));
new ad_work();
}
while(!rs.next()){
JOptionPane.showMessageDialog(null,"invalid login");
break;
}
//String us2 =rs.getString("username");
//String ps2 =rs.getString("password");
/*if(rs.next()){
if(us1.equals(us2)){
JOptionPane.showMessageDialog(null,"no more record");
}}
else{
JOptionPane.showMessageDialog(null,"record");
}*/
//rs.getString();
//rs = st.executeQuery(sql2);
// t.setText(rs.getString("username"));
// t1.setText(rs.getString("password"));
// }
} catch (Exception ex) {
}
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//JOptionPane.showMessageDialog(null,"record");
}
});
}
}
---------------------------------------------------------------------------------------------------------------
ad_work.java
import java.sql.SQLException;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ad_work extends Main{
JFrame f;
JLabel fname;
JLabel lname;
JLabel faname;
JLabel mname;
JLabel address;
JLabel contact;
JLabel occ;
JLabel course;
JLabel sem;
JLabel fee;
JLabel marks;
JLabel sub;
JLabel sex;
JTextField t;
JTextField t1;
JTextField t2;
JTextField t3;
JTextField t4;
JTextField t5;
JTextField t6;
JTextField t7;
JTextField t8;
JTextField t9;
JTextField t0;
JTextField tt;
JTextField sx;
JButton si = new JButton("Show Info");
JButton ud = new JButton("Update");
JButton del = new JButton("Delete");
JButton cl = new JButton("Cancel");
JButton cn = new JButton("Create New");
JRadioButton r1 = new JRadioButton("Male");
JRadioButton r2 = new JRadioButton("Female");
public ad_work(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(600,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fname = new JLabel("Student Name");
lname = new JLabel("Last Name");
address = new JLabel("Address");
contact = new JLabel("Contact No.");
faname =new JLabel("Father`s name");
mname =new JLabel("Mother`s name");
occ = new JLabel("Occupation");
fee = new JLabel("Fee Paid");
marks = new JLabel("Marks in %");
course =new JLabel("Course Title");
sem =new JLabel("Semester");
sub = new JLabel("Subject");
sex = new JLabel("Sex");
t = new JTextField(10);
t1 = new JTextField(10);
t2 = new JTextField(20);
t3 = new JTextField(10);
t4 = new JTextField(20);
t5 = new JTextField(20);
t6 = new JTextField(10);
t7 = new JTextField(10);
t8= new JTextField(10);
t9 = new JTextField(10);
t0 = new JTextField(10);
tt = new JTextField(10);
sx = new JTextField(10);
ButtonGroup BG = new ButtonGroup();
BG.add(r1);
BG.add(r2);
r1.setSelected(true);
r2.setSelected(true);
JPanel p = new JPanel();
p.add(fname);
p.add(t);
p.add(lname);
p.add(t1);
p.add(faname);
p.add(t2);
p.add(mname);
p.add(t3);
p.add(sex);
p.add(sx);
//p.add(r1);
//p.add(r2);
p.add(occ);
p.add(t4);
p.add(address);
p.add(t5);
p.add(contact);
p.add(t6);
p.add(course);
p.add(t7);
p.add(sem);
p.add(t8);
p.add(marks);
p.add(t9);
p.add(sub);
p.add(t0);
p.add(fee);
p.add(tt);
p.add(si);
p.add(ud);
p.add(del);
p.add(cn);
p.add(cl);
f.add(p);
try{
/*String sql = "select * from s_info";
rs = st.executeQuery(sql);
rs.next();
t.setText(rs.getString("sname"));*/
//t1.setText(rs.getString("lname"));
//t2.setText(rs.getString("Age"));
}catch(Exception ex){
}
}
public void btnAction(){
si.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String us1 =t.getText();
try{
String sql = "select * from s_info where sname ='" + us1+"'";
//JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next())
{
t1.setText(rs.getString("lname"));
t2.setText(rs.getString("faname"));
t3.setText(rs.getString("moname"));
t4.setText(rs.getString("occ"));
t5.setText(rs.getString("add"));
t6.setText(rs.getString(7));
t7.setText(rs.getString("course"));
t8.setText(rs.getString("sem"));
t9.setText(rs.getString("marks"));
t0.setText(rs.getString("sub"));
tt.setText(rs.getString("fee"));
sx.setText(rs.getString("sex"));
// JOptionPane.showMessageDialog(null, "call");
}
while(!rs.next()){
JOptionPane.showMessageDialog(null,"Record not found");
break;
}
}catch(Exception ex){}
}
});
del.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String us2 =t.getText();
try{
String sql = "select * from s_info where sname ='" + us2+"'";
//JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next())
{
rs.deleteRow();
JOptionPane.showMessageDialog(null, "record deleted");
t.setText(" ");
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
t5.setText(" ");
t6.setText(" ");
t7.setText(" ");
t8.setText(" ");
t9.setText(" ");
t0.setText(" ");
tt.setText(" ");
sx.setText(" ");
}
}catch(Exception ex){}
}
});
cl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//new s_info();
}
});
ud.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String fname = t.getText();
String lname = t1.getText();
String faname = t2.getText();
String moname = t3.getText();
String sex = sx.getText();
String occ = t4.getText();
String add = t5.getText();
String con = t6.getText();
String course = t7.getText();
String sem = t8.getText();
String marks = t9.getText();
String sub = t0.getText();
String fee = tt.getText();
try{
String sql = "select * from s_info where sname ='" + fname+"'";
//JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next()){
rs.updateString(1, fname);
rs.updateString(2, lname);
rs.updateString(3, faname);
rs.updateString(4, moname);
rs.updateString(5, occ);
rs.updateString(6, add);
rs.updateString(7, con);
rs.updateString(8, course);
rs.updateString(9, sem);
rs.updateString(10, marks);
rs.updateString(11, sub);
rs.updateString(12, fee);
rs.updateString(13, sex);
rs.updateRow();
JOptionPane.showMessageDialog(null,"record updated");
}
}catch(Exception ex){}
}
});
cn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
new s_info();
}
});
}
}
---------------------------------------------------------------------------------------------------------------
base_file.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class base_file extends Main{
JFrame f;
JButton b1 = new JButton("Student Login");
JButton b2 = new JButton("Admin Login");
// JButton b4 = new JButton("Close");
//JButton b5 = new JButton("Delete");
public base_file(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(650,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add(b1);
p.add(b2);
// p.add(b3);
// p.add(b4);
//p.add(b5);
f.add(p);
}
public void btnAction(){
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
//new s_infob();
// new base_file2();
new s_login();
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
new ad_login(); // yha pr search wala code pst krna h......
}
});
/*b3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
new s_infob(); //yha pr search wala code pst krna h......
}
});*/
}
}
---------------------------------------------------------------------------------------------------------------------------------
login.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//import java.sql.*;
public class login extends Main {
JFrame f;
JLabel uname;
JLabel pass;
JLabel age;
JTextField t;
JTextField t1;
JButton b1 = new JButton("Login");
JButton b2 = new JButton("Cancel");
public login(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(300,200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
uname = new JLabel("User Name");
pass = new JLabel("Password");
t = new JTextField(15);
t1 = new JTextField(15);
JPanel p = new JPanel();
p.add(uname);
p.add(t);
p.add(pass);
p.add(t1);
p.add(b1);
p.add(b2);
f.add(p);
try{
}catch(Exception ex){
}
}
public void btnAction(){
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
//new s_info();
String us1 =t.getText();
String pw1 =t1.getText();
//JOptionPane.showMessageDialog(null,us1);
try{
String sql = "select * from login where username ='" + us1+"' and password='" + pw1+"'";
JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next())
{
JOptionPane.showMessageDialog(null, rs.getString(1));
}
//String us2 =rs.getString("username");
//String ps2 =rs.getString("password");
/*if(rs.next()){
if(us1.equals(us2)){
JOptionPane.showMessageDialog(null,"no more record");
}}
else{
JOptionPane.showMessageDialog(null,"record");
}*/
//rs.getString();
//rs = st.executeQuery(sql2);
// t.setText(rs.getString("username"));
// t1.setText(rs.getString("password"));
// }
} catch (Exception ex) {
}
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//JOptionPane.showMessageDialog(null,"record");
}
});
}
}------------------------------------------------------------------------------------------------------------------
s_info.java
import javax.swing.*;
import java.awt.event.*;
public final class s_info extends Main{
JFrame f;
JLabel fname;
JLabel lname;
JLabel faname;
JLabel mname;
JLabel address;
JLabel contact;
JLabel occ;
JLabel course;
JLabel sem;
JLabel fee;
JLabel marks;
JLabel sub;
JLabel sex;
public int flag =0;
JTextField t;
JTextField t1;
JTextField t2;
JTextField t3;
JTextField t4;
JTextField t5;
JTextField t6;
JTextField t7;
JTextField t8;
JTextField t9;
JTextField t0;
JTextField tt;
JTextField sx;
JButton ok = new JButton("Save");
JButton cl = new JButton("Cancel");
JRadioButton r1 = new JRadioButton("Male");
JRadioButton r2 = new JRadioButton("Female");
public s_info(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(600,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fname = new JLabel("Student Name");
lname = new JLabel("Last Name");
address = new JLabel("Address");
contact = new JLabel("Contact No.");
faname =new JLabel("Father`s name");
mname =new JLabel("Mother`s name");
occ = new JLabel("Occupation");
fee = new JLabel("Fee Paid");
marks = new JLabel("Marks in %");
course =new JLabel("Course Title");
sem =new JLabel("Semester");
sub = new JLabel("Subject");
sex = new JLabel("Sex");
t = new JTextField(10);
t1 = new JTextField(10);
t2 = new JTextField(20);
t3 = new JTextField(10);
t4 = new JTextField(20);
t5 = new JTextField(20);
t6 = new JTextField(10);
t7 = new JTextField(10);
t8= new JTextField(10);
t9 = new JTextField(10);
t0 = new JTextField(10);
tt = new JTextField(10);
sx = new JTextField(10);
ButtonGroup BG = new ButtonGroup();
BG.add(r1);
BG.add(r2);
r1.setSelected(true);
r2.setSelected(true);
JPanel p = new JPanel();
p.add(fname);
p.add(t);
p.add(lname);
p.add(t1);
p.add(faname);
p.add(t2);
p.add(mname);
p.add(t3);
p.add(sex);
//p.add(sx);
p.add(r1);
p.add(r2);
p.add(occ);
p.add(t4);
p.add(address);
p.add(t5);
p.add(contact);
p.add(t6);
p.add(course);
p.add(t7);
p.add(sem);
p.add(t8);
p.add(marks);
p.add(t9);
p.add(sub);
p.add(t0);
p.add(fee);
p.add(tt);
p.add(ok);
p.add(cl);
f.add(p);
try{
String sql = "select * from s_info";
rs = st.executeQuery(sql);
}catch(Exception ex){
}
}
public void btnAction(){
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String fname = t.getText();
String lname = t1.getText();
String faname = t2.getText();
String moname = t3.getText();
String sex = sx.getText();
String occ = t4.getText();
String add = t5.getText();
String con = t6.getText();
String course = t7.getText();
String sem = t8.getText();
String marks = t9.getText();
String sub = t0.getText();
String fee = tt.getText();
try{
rs.moveToInsertRow();
rs.updateString(1, fname);
rs.updateString(2, lname);
rs.updateString(3, faname);
rs.updateString(4, moname);
rs.updateString(5, occ);
rs.updateString(6, add);
rs.updateString(7, con);
rs.updateString(8, course);
rs.updateString(9, sem);
rs.updateString(10, marks);
rs.updateString(11, sub);
rs.updateString(12, fee);
if(flag==1){
rs.updateString(13, "Male");}
if(flag==2){
rs.updateString(13, "Female");
}
rs.insertRow();
JOptionPane.showMessageDialog(null,"Record Saved");
}catch(Exception ex){}
}
});
cl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//new s_info();
}
});
r1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
flag=1;
//JOptionPane.showMessageDialog(null,"male");
}
});
r2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
flag =2;
//JOptionPane.showMessageDialog(null,"female");
}
});
}
}
--------------------------------------------------------------------------------------------------------------------
s_infob.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class s_infob extends Main{
JFrame f;
JLabel fname;
JLabel lname;
JLabel faname;
JLabel mname;
JLabel address;
JLabel contact;
JLabel occ;
JLabel sex;
JTextField t;
JTextField t1;
JTextField t2;
JTextField t3;
JTextField t4;
JTextField t5;
JTextField t6;
JButton sv = new JButton("Save");
JButton cl = new JButton("Cancel");
public s_infob(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(600,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fname = new JLabel("Student Name");
lname = new JLabel("Last Name");
address = new JLabel("Address");
contact = new JLabel("Contact No.");
faname =new JLabel("Father`s name");
mname =new JLabel("Mother`s name");
occ = new JLabel("Occupation");
sex = new JLabel("Sex");
t = new JTextField(10);
t1 = new JTextField(10);
t2 = new JTextField(20);
t3 = new JTextField(10);
t4 = new JTextField(20);
t5 = new JTextField(20);
t6 = new JTextField(10);
JPanel p = new JPanel();
p.add(fname);
p.add(t);
p.add(lname);
p.add(t1);
p.add(faname);
p.add(t4);
p.add(mname);
p.add(t5);
p.add(sex);
p.add(occ);
p.add(t6);
p.add(address);
p.add(t2);
p.add(contact);
p.add(t3);
p.add(sv);
p.add(cl);
f.add(p);
try{
String sql = "select * from s_info";
rs = st.executeQuery(sql);
rs.next();
// t.setText(rs.getString("Sname"));
// t1.setText(rs.getString("Lname"));
//t2.setText(rs.getString("Age"));
}catch(Exception ex){
}
}
public void btnAction(){
sv.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String sname = t.getText();
String lname = t1.getText();
String faname = t4.getText();
String moname = t5.getText();
String occ = t6.getText();
String add = t2.getText();
String con = t3.getText();
try{
rs.moveToInsertRow();
rs.updateString("sname", sname);
//rs.updateString(1 ,"fname");
rs.updateString("lname", lname);
rs.updateString("faname",faname );
rs.updateString("moname",moname );
rs.updateString("occ",occ );
rs.updateString("add",add );
rs.updateString("contact",con );
rs.insertRow();
JOptionPane.showMessageDialog(null,"record saved");
}
catch(Exception ex){}
}
});
cl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//new s_info();
}
});
}
}
-------------------------------------------------------------------------------------------------------------------
s_login.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//import java.sql.*;
public class s_login extends Main {
JFrame f;
JLabel uname;
JLabel pass;
JLabel age;
JTextField tf1;
JTextField tf2;
JButton b1 = new JButton("Login");
JButton b2 = new JButton("Cancel");
public int flag1=0;
public s_login(){
frame();
btnAction();
}
public void frame(){
f = new JFrame();
f.setVisible(true);
f.setSize(300,200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
uname = new JLabel("User Name");
pass = new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JPasswordField(10);
JPanel p = new JPanel();
p.add(uname);
p.add(tf1);
p.add(pass);
p.add(tf2);
p.add(b1);
p.add(b2);
f.add(p);
try{
}catch(Exception ex){
}
}
public void btnAction(){
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
bitu =tf1.getText();
String pw1 =tf2.getText();
try{
String sql = "select * from s_login where sname ='" + bitu+"' and password='" + pw1+"'";
//JOptionPane.showMessageDialog(null,sql);
rs = st.executeQuery(sql);
while(rs.next())
{
//JOptionPane.showMessageDialog(null, rs.getString(1));
new s_info();
}
while(!rs.next()){
JOptionPane.showMessageDialog(null,"invalid login");
break;
}
//String us2 =rs.getString("username");
//String ps2 =rs.getString("password");
/*if(rs.next()){
if(us1.equals(us2)){
JOptionPane.showMessageDialog(null,"no more record");
}}
else{
JOptionPane.showMessageDialog(null,"record");
}*/
//rs.getString();
//rs = st.executeQuery(sql2);
// t.setText(rs.getString("username"));
// t1.setText(rs.getString("password"));
// }
} catch (Exception ex) {
}
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
f.setVisible(false);
//JOptionPane.showMessageDialog(null,"record");
}
});
}
}------------------------------------------------------------------------------------------------------------------
Save all files with its own name.... n run it on netbeans...... Same as all management projects can be design... like attendance management system, library management system n etc......!!!!