Hi....
I have made this code for my college project but don't understand why i am getting some errors like
2 Error : java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state (This error occured while checking availability of seats...)
Also the Report section of project is not showing anything
can anybody help me i have to submit this project on 6th of December.....
I am Copying the code of all the files.....one by one...
1) Project.java
import java.awt.*;
import java.awt.event.*;
public class Project extends Frame
{
public static void main(String args[])
{
Login L = new Login();
L.setLocation(200,100);
L.setSize(300,300);
L.setVisible(true);
L.setTitle("Login Screen");
}
}
2) Cancellation.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Cancellation extends Frame implements ActionListener
{
Label l1,l2,l3;
TextField t1;
Button b1,b2;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Cancellation()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("PNR No");
l1.setFont(f);
t1 = new TextField(20);
l2 = new Label("");
l3 = new Label("");
b1 = new Button("Submit");
b2 = new Button("Reset");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(b2,gbc);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
addWindowListener(new TU());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
t1.setText("");
}
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("select FlightNo,TravelDate,Class from Passengers where PNRNo=?");
String pnrno = t1.getText();
ps.setInt(1,Integer.parseInt(pnrno));
rs=ps.executeQuery();
rs.next();
System.out.println(rs.getString(1)+""+rs.getString(2)+" "+rs.getString(3));
/* if(rs.getString(3).equals(String.valueOf('F')))
{
ps=con.prepareStatement("update Reservation set FSeats=FSeats+1 where FlightNo=? and TravelDate=?");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
if(rs.getString(3).equals(String.valueOf('B')))
{
ps=con.prepareStatement("update Reservation set BSeats=BSeats+1 where FlightNo= ? and TravelDate= ? ");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
if(rs.getString(3).equals(String.valueOf('E')))
{
ps=con.prepareStatement("update Reservation set ESeats=ESeats+1 where FlightNo=? and TravelDate=?");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
*/
ps=con.prepareStatement("delete from Passengers where PNRNo=?");
ps.setInt(1,Integer.parseInt(pnrno));
count = ps.executeUpdate();
con.close();
t1.setText("");
}
catch(Exception e)
{
System.out.println("Error : "+e);
}
}
}
class TU extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
3) Change.java
import java.awt.*;
import java.awt.event.*;
public class Change extends Frame
{
Label l1,l2;
TextField t1,t2;
GridLayout g;
Button b1,b2;
Change()
{
g = new GridLayout(3,2,20,40);
setLayout(g);
l1 = new Label("Username",Label.CENTER);
l2 = new Label("Password",Label.CENTER);
t1 = new TextField(20);
t2 = new TextField(20);
t2.setEchoChar('*');
b1 = new Button("Submit");
b2 = new Button("Close");
b2.addActionListener(new W());
addWindowListener(new L());
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
}
class W implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
dispose();
}
}
}
class L extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
public Insets getInsets()
{
return new Insets(40,40,40,40);
}
public static void main(String args[])
{
Change m = new Change();
m.setTitle("Change Login Details");
m.setSize(400,300);
m.setVisible(true);
}
}
4) Check.java
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Check extends Frame implements ActionListener
{
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12;
TextField t1,t2,t3,t4,t5;
Choice c;
Button b1,b2;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Check()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("");
l4 = new Label("");
l5 = new Label("");
l6 = new Label("");
l7 = new Label("");
l2 = new Label("Travel Date");
l2.setFont(f);
l3 = new Label("Flight No");
l3.setFont(f);
l8 = new Label("First Class Seats");
l8.setFont(f);
l9 = new Label("Business Class Seats");
l9.setFont(f);
l10 = new Label("Economy Class Seats");
l10.setFont(f);
l11 = new Label("");
l12 = new Label("");
t1 = new TextField(20);
t2 = new TextField(20);
t3 = new TextField(20);
t4 = new TextField(20);
t5 = new TextField(20);
c = new Choice();
b1 = new Button("Submit");
b2 = new Button("Reset");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
c.add("DL - BGR : HA101");
c.add("BGR - DL : HA102");
c.add("DL - BY : HA201");
c.add("BY - DL : HA202");
c.add("DL - KLA : HA301");
c.add("KLA - DL : HA302");
c.add("DL - CHN : HA401");
c.add("CHN - DL : HA402");
c.add("DL - HYD : HA501");
c.add("HYD - DL : HA502");
c.add("DL - PUN : HA601");
c.add("PUN - DL : HA602");
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(c,gbc);
add(c);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l6,gbc);
add(l6);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(l7,gbc);
add(l7);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=10;
gbl.setConstraints(b2,gbc);
add(b2);
gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l11,gbc);
add(l11);
gbc.gridx=2;
gbc.gridy=12;
gbl.setConstraints(l12,gbc);
add(l12);
gbc.gridx=0;
gbc.gridy=14;
gbl.setConstraints(l8,gbc);
add(l8);
gbc.gridx=2;
gbc.gridy=14;
gbl.setConstraints(t3,gbc);
add(t3);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(l9,gbc);
add(l9);
gbc.gridx=2;
gbc.gridy=16;
gbl.setConstraints(t4,gbc);
add(t4);
gbc.gridx=0;
gbc.gridy=18;
gbl.setConstraints(l10,gbc);
add(l10);
gbc.gridx=2;
gbc.gridy=18;
gbl.setConstraints(t5,gbc);
add(t5);
b1.addActionListener(this);
b2.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("Select * from Reservation where TravelDate=? and FlightNo=?");
ps.setString(1,t1.getText());
ps.setString(2,t2.getText());
rs=ps.executeQuery();
rs.next();
t3.setText(Integer.toString(rs.getInt(3)));
t4.setText(Integer.toString(rs.getInt(4)));
t5.setText(Integer.toString(rs.getInt(5)));
con.close();
}
catch(Exception e)
{
System.out.println("2 Error : "+e);
}
}
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
}
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
5) Collection.java
import java.awt.*;
import java.awt.event.*;
public class Collection extends Frame
{
Collection()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
6) Confirmed.java
import java.awt.*;
import java.awt.event.*;
public class Confirmed extends Frame
{
Confirmed()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
}
7) Create.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Create extends Frame implements ActionListener
{
TextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17;
Choice c;
Button b1,b2,b3;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Create()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l15 = new Label("Flight No");
l15.setFont(f);
l1 = new Label("Travel Date");
l1.setFont(f);
l2 = new Label("FName");
l2.setFont(f);
l3 = new Label("LName");
l3.setFont(f);
l4 = new Label("Age");
l4.setFont(f);
l5 = new Label("Gender");
l5.setFont(f);
l6 = new Label("Address");
l6.setFont(f);
l7 = new Label("Phone");
l7.setFont(f);
l8= new Label("Class");
l8.setFont(f);
l9= new Label("Status");
l9.setFont(f);
t10 = new TextField(20);
t1 = new TextField(20);
t2 = new TextField(20);
t3 = new TextField(20);
t4 = new TextField(20);
t5 = new TextField(20);
t6 = new TextField(20);
t7 = new TextField(20);
t8 = new TextField(20);
t9 = new TextField(20);
c = new Choice();
b1 = new Button("Submit");
b2 = new Button("Reset");
b3 = new Button("Generate Ticket");
l10 = new Label("");
l11 = new Label("");
l12 = new Label("");
l13 = new Label("");
l14 = new Label("");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l10,gbc);
add(l10);
c.add("DL - BGR : HA101");
c.add("BGR - DL : HA102");
c.add("DL - BY : HA201");
c.add("BY - DL : HA202");
c.add("DL - KLA : HA301");
c.add("KLA - DL : HA302");
c.add("DL - CHN : HA401");
c.add("CHN - DL : HA402");
c.add("DL - HYD : HA501");
c.add("HYD - DL : HA502");
c.add("DL - PUN : HA601");
c.add("PUN - DL : HA602");
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(c,gbc);
add(c);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l13,gbc);
add(l13);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l14,gbc);
add(l14);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l15,gbc);
add(l15);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(t10,gbc);
add(t10);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=10;
gbl.setConstraints(t3,gbc);
add(t3);
gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=12;
gbl.setConstraints(t4,gbc);
add(t4);
gbc.gridx=0;
gbc.gridy=14;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=2;
gbc.gridy=14;
gbl.setConstraints(t5,gbc);
add(t5);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(l6,gbc);
add(l6);
gbc.gridx=2;
gbc.gridy=16;
gbl.setConstraints(t6,gbc);
add(t6);
gbc.gridx=0;
gbc.gridy=18;
gbl.setConstraints(l7,gbc);
add(l7);
gbc.gridx=2;
gbc.gridy=18;
gbl.setConstraints(t7,gbc);
add(t7);
gbc.gridx=0;
gbc.gridy=20;
gbl.setConstraints(l8,gbc);
add(l8);
gbc.gridx=2;
gbc.gridy=20;
gbl.setConstraints(t8,gbc);
add(t8);
gbc.gridx=0;
gbc.gridy=22;
gbl.setConstraints(l9,gbc);
add(l9);
gbc.gridx=2;
gbc.gridy=22;
gbl.setConstraints(t9,gbc);
add(t9);
gbc.gridx=0;
gbc.gridy=24;
gbl.setConstraints(l11,gbc);
add(l11);
gbc.gridx=2;
gbc.gridy=24;
gbl.setConstraints(l12,gbc);
add(l12);
gbc.gridx=0;
gbc.gridy=26;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=26;
gbl.setConstraints(b2,gbc);
add(b2);
/* gbc.gridx=0;
gbc.gridy=28;
gbl.setConstraints(l16,gbc);
add(l16);
gbc.gridx=2;
gbc.gridy=28;
gbl.setConstraints(l17,gbc);
add(l17);
gbc.gridx=0;
gbc.gridy=30;
gbl.setConstraints(b3,gbc);
add(b3);
*/
b1.addActionListener(this);
b2.addActionListener(this);
// b3.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("insert into Passengers(FlightNo,TravelDate,FName,LName,Age,Gender,Address,Phone,Class,Status)values(?,?,?,?,?,?,?,?,?,?)");
String age = t4.getText();
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
ps.setString(3,t2.getText());
ps.setString(4,t3.getText());
ps.setInt(5,Integer.parseInt(age));
ps.setString(6,t5.getText());
ps.setString(7,t6.getText());
ps.setString(8,t7.getText());
ps.setString(9,t8.getText());
ps.setString(10,t9.getText());
ps.executeUpdate();
if(t8.getText().equals(String.valueOf('F')))
{
String str = "update Reservation set FSeats=FSeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
if(t8.getText().equals(String.valueOf('B')))
{
String str = "update Reservation set BSeats=BSeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
if(t8.getText().equals(String.valueOf('E')))
{
String str = "update Reservation set ESeats=ESeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
con.close();
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
t9.setText("");
t10.setText("");
Ticket t = new Ticket();
//setVisible(false);
t.setSize(400,500);
t.setVisible(true);
t.setTitle("Ticket Screen");
}
catch(SQLException e)
{
System.out.println("2 Error : "+e);
}
catch(Exception ex)
{
System.out.println("Error 1:"+ex);
}
}
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
t9.setText("");
t10.setText("");
}
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
public static void main(Strin[CODE][/CODE]g args[])
{
Create v = new Create();
v.setSize(400,500);
v.setVisible(true);
v.setTitle("Create Passenger Screen");
}
}
8) Login.java
import java.awt.*;
import java.awt.event.*;
public class Login extends Frame implements ActionListener
{
String username = "admin";
String password = "admin";
TextField t1,t2;
Label l1,l2,l3,l4,l5,l6;
Button b2,b3,b4;
GridBagLayout gbl;
GridBagConstraints gbc;
Font f1,f2;
public Login()
{
//setTitle("Login Screen");
//g = new GridLayout(4,2,0,60);
//setLayout(g);
setBackground(Color.cyan);
f1 = new Font("TimesRoman",Font.BOLD,20);
f2 = new Font("TimesRoman",Font.BOLD,15);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("Username",Label.CENTER);
l1.setFont(f1);
l2 = new Label("Password",Label.CENTER);
l2.setFont(f1);
l3 = new Label("");
l4 = new Label("");
l5 = new Label("");
l6 = new Label("");
t1 = new TextField(15);
t2 = new TextField(15);
t2.setEchoChar('*');
//b1 = new Button("Change Login Details");
b2 = new Button("Reset");
b2.setFont(f2);
b3 = new Button("Submit");
b3.setFont(f2);
b4 = new Button("Close");
b4.setFont(f2);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(b2,gbc);
add(b2);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(b3,gbc);
add(b3);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(b4,gbc);
add(b4);
//add(l1);
//add(t1);
//add(l2);
//add(t2);
//add(b1);
//add(b2);
//add(b3);
//add(b4);
//b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
}
/*public Insets getInsets()
{
return new Insets(40,40,40,40);
}*/
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
}
if(ae.getSource()==b4)
{
System.exit(0);
}
if(ae.getSource()==b3)
{
if((t1.getText().equals(username))&&(t2.getText().equals(password)))
{
MainMenu m = new MainMenu();
setVisible(false);
m.setSize(400,400);
m.setVisible(true);
m.setTitle("Main Menu");
}
else
{
//Warning w = new Warning();
//w.setSize(300,200);
//w.setVisible(true);
//w.setTitle("Message Box");
MessageBox mb = new MessageBox(this);
mb.setLocation(200,200);
mb.setVisible(true);
}
}
/*if(ae.getSource() == b1)
{
Change c = new Change();
c.setSize(400,400);
c.setVisible(true);
c.setTitle("Screen for Changing Login Details");
}*/
}
}
9) Mainmenu.java
import java.awt.*;
import java.awt.event.*;
public class MainMenu extends Frame implements ActionListener
{
MenuBar mbar;
Menu m1,m2,m3;
MenuItem m1_1,m1_2,m2_1,m2_2,m2_3,m3_1;
public MainMenu()
{
mbar = new MenuBar();
setMenuBar(mbar);
m1=new Menu("Bookings");
mbar.add(m1);
m1_1 = new MenuItem("Reservation");
m1.add(m1_1);
m1_2 = new MenuItem("Cancellation");
m1.add(m1_2);
m2=new Menu("Reports");
mbar.add(m2);
m2_1 = new MenuItem("Confirmed Passengers");
m2.add(m2_1);
m2_2 = new MenuItem("Waiting");
m2.add(m2_2);
m2_3 = new MenuItem("Daily Collection Report");
m2.add(m2_3);
m3=new Menu("Close");
mbar.add(m3);
m3_1 = new MenuItem("Close");
m3.add(m3_1);
m1_1.addActionListener(this);
m1_2.addActionListener(this);
m2_1.addActionListener(this);
m2_2.addActionListener(this);
m2_3.addActionListener(this);
m3_1.addActionListener(this);
addWindowListener(new M());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==m1_1)
{
Reservation r = new Reservation();
r.setSize(400,400);
r.setVisible(true);
r.setTitle("Reservation Screen");
}
if(ae.getSource()==m1_2)
{
Cancellation c = new Cancellation();
c.setSize(400,400);
c.setVisible(true);
c.setTitle("Cancellation Screen");
}
if(ae.getSource()==m2_1)
{
Confirmed cr = new Confirmed();
cr.setSize(400,400);
cr.setVisible(true);
cr.setTitle("Confirmed Passengers List");
}
if(ae.getSource()==m2_2)
{
Waiting wr = new Waiting();
wr.setSize(400,400);
wr.setVisible(true);
wr.setTitle("Waiting List");
}
if(ae.getSource()==m2_3)
{
Collection dcr = new Collection();
dcr.setSize(400,400);
dcr.setVisible(true);
dcr.setTitle("Daily Collection Report");
}
if(ae.getSource()==m3_1)
{
System.exit(0);
}
}
/*public static void main(String args[])
{
MainMenu m = new MainMenu();
m.setTitle("Main Menu");
m.setSize(400,400);
m.setVisible(true);
}*/
class M extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
10) MessageBox.java
import java.awt.*;
import java.awt.event.*;
public class MessageBox extends Dialog implements ActionListener
{
GridBagLayout gbl;
GridBagConstraints gbc;
FlowLayout F;
Button b1;
Label l;
Font f1,f2;
MessageBox(Frame fm)
{
super(fm,true);
setBackground(Color.cyan);
f1 = new Font("Times Roman",Font.BOLD,20);
f2 = new Font("Times Roman",Font.BOLD,15);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l=new Label("Incorrect username or password",Label.CENTER);
l.setFont(f1);
b1 = new Button(" OK ");
b1.setFont(f2);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l,gbc);
add(l);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(b1,gbc);
add(b1);
setSize(350,200);
setTitle("Message Box");
b1.addActionListener(this);
addWindowListener(new X());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
setVisible(false);
dispose();
}
}
class X extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
11) Reservation.java
import java.awt.*;
import java.awt.event.*;
public class Reservation extends Frame implements ActionListener
{
Button b1,b2,b3;
Label l1,l2;
GridBagLayout gbl;
GridBagConstraints gbc;
Font f;
Reservation()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
b1=new Button("Check Availability");
b1.setFont(f);
b2=new Button(" Create Passenger ");
b2.setFont(f);
// b3=new Button(" Fare Teller ");
// b3.setFont(f);
l1= new Label("");
l2= new Label("");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(b2,gbc);
add(b2);
/* gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(b3,gbc);
add(b3);
*/
b1.addActionListener(this);
b2.addActionListener(this);
// b3.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
Check m = new Check();
//setVisible(false);
m.setSize(400,400);
m.setVisible(true);
m.setTitle("Check Availability Screen");
}
if(ae.getSource()==b2)
{
Create v = new Create();
//setVisible(false);
v.setSize(400,500);
v.setVisible(true);
v.setTitle("Create Passenger Screen");
}
/* if(ae.getSource()==b3)
{
Fare f = new Fare();
//setVisible(false);
f.setSize(400,500);
f.setVisible(true);
f.setTitle("Fare Teller Screen");
}
*/
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
12) Ticket.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Ticket extends Frame implements ActionListener
{
TextField t1;
Label l1;
Button b1;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Ticket()
{
setBackground(Color.cyan);
t1 = new TextField(20);
l1 = new Label("PNR NO ");
l1.setFont(f);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(t1,gbc);
add(t1);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
/* public static void main(String args[])
{
Ticket t = new Ticket();
t.setSize(400,500);
t.setVisible(true);
t.setTitle("Ticket Screen");
}*/
}
13) Waiting.java
import java.awt.*;
import java.awt.event.*;
public class Waiting extends Frame
{
Waiting()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
}
14) Warning.java
import java.awt.*;
import java.awt.event.*;
public class Warning extends Frame
{
GridLayout g;
Button b1;
Label l;
Warning()
{
g = new GridLayout(2,1,10,40);
setLayout(g);
l = new Label("Incorrect username or password",Label.CENTER);
b1 = new Button("Ok");
add(l);
add(b1);
b1.addActionListener(new Y());
addWindowListener(new X());
}
class Y implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
//dispose();
System.exit(0);
}
}
}
class X extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
public Insets getInsets()
{
return new Insets(40,40,40,40);
}
/*public static void main(String args[])
{
Warning m = new Warning();
m.setTitle("Message Box");
m.setSize(300,200);
m.setVisible(true);
}*/
}
These are all Java files of my project also I have a Database named MyDataSource1.....
Guys Help me its very Urgent....
Thanks in advance....