123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Example of JTabbed Pane.

--------------------------------------------------------------------------------

Description : Not Specified

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.sql.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import java.io.*;

public class app2 extends JApplet
{
public void init()
{
JTabbedPane jtp=new JTabbedPane();
jtp.addTab("Flight Schedule and Seats",new flightschedule());
jtp.addTab("Arrival/Departure",new arrdep());
jtp.addTab("Fare",new fare());
jtp.addTab("PNR Status",new pnr());
getContentPane().add(jtp);
}

}
class flightschedule extends JPanel
{
JLabel jl1;JLabel jl2;JLabel jl3;JComboBox jc1;JComboBox jc2;JComboBox jc3;
JButton jb1;JButton jb2;JTextArea area1;JTextArea area2;JScrollPane jsp;JScrollPane jsp1;
String ss="";
public flightschedule()
{
setForeground(Color.black);
jl1=new JLabel("ORIGIN CITY");
jl2=new JLabel("DESTINATION CITY");
jl3=new JLabel("DATE");
jc1=new JComboBox();

jc1.addItem("AGARTALA");jc1.addItem("AHMEDABAD");jc1.addItem("BANGALORE");
jc1.addItem("BHUBANESHWAR");

jc1.addItem("CALICUT");jc1.addItem("CHANDIGARH");jc1.addItem("DELHI");jc1.
addItem("GUWAHATI");

jc1.addItem("HYDERABAD");jc1.addItem("IMPHAL");jc1.addItem("INDORE");jc1.addItem("JAIPUR");

jc1.addItem("JAMMU");jc1.addItem("KOLKATA");jc1.addItem("LUCKNOW");jc1.addItem("MADRAS");

jc1.addItem("MUMBAI");jc1.addItem("NAGPUR");jc1.addItem("PANAJI");jc1.addItem("PATNA");

jc1.addItem("SHILLONG");jc1.addItem("SHIMLA");jc1.addItem("TRIVANDRUM");jc1.addItem("VADODARA");
jb1=new JButton("GET SCHEDULE");
jb2=new JButton("SEAT STATUS");
jc2=new JComboBox();

jc2.addItem("AGARTALA");jc2.addItem("AHMEDABAD");jc2.addItem("BANGALORE");
jc2.addItem("BHUBANESHWAR");

jc2.addItem("CALICUT");jc2.addItem("CHANDIGARH");jc2.addItem("DELHI");jc2.addItem("GUWAHATI");

jc2.addItem("HYDERABAD");jc2.addItem("IMPHAL");jc2.addItem("INDORE");jc2.addItem("JAIPUR");

jc2.addItem("JAMMU");jc2.addItem("KOLKATA");jc2.addItem("LUCKNOW");jc2.addItem("MADRAS");

jc2.addItem("MUMBAI");jc2.addItem("NAGPUR");jc2.addItem("PANAJI");jc2.addItem("PATNA");

jc2.addItem("SHILLONG");jc2.addItem("SHIMLA");jc2.addItem("TRIVANDRUM");jc2.addItem("VADODARA");
jc3=new JComboBox();

jc3.addItem("1");jc3.addItem("2");jc3.addItem("3");jc3.addItem("4");jc3.addItem("5");jc3.addItem("6");

jc3.addItem("7");jc3.addItem("8");jc3.addItem("9");jc3.addItem("10");jc3.addItem("11");jc3.addItem("12");

jc3.addItem("13");jc3.addItem("14");jc3.addItem("15");jc3.addItem("16");jc3.addItem("17");jc3.addItem("18");

jc3.addItem("19");jc3.addItem("20");jc3.addItem("21");jc3.addItem("22");jc3.addItem("23");jc3.addItem("24");

jc3.addItem("25");jc3.addItem("26");jc3.addItem("27");jc3.addItem("28");jc3.addItem("29");jc3.addItem("30");
area1=new JTextArea(6,30);
area2=new JTextArea(10,30);
jsp=new JScrollPane(area1);
jsp1=new JScrollPane(area2);
setLayout(new GridLayout(5,2,5,5));
add(jl1); add(jc1);
add(jl2); add(jc2);
add(jl3); add(jc3);
add(jb1); add(jb2);
add(jsp); add(jsp1);
jb1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
flightsch(ae);
}
});
jb2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
seatstatus(ae);
}
});
}
void flightsch(ActionEvent ae)
{
try
{
obj o=new obj();
o.setorigincity((String)jc1.getSelectedItem());
o.setdestinationcity((String)jc2.getSelectedItem());
URL url=new URL("http://localhost:8080/servlet/schedule");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
ss=response.getstatus();
area1.setText(ss);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
void seatstatus(ActionEvent ae)
{
try
{
obj o=new obj();
o.setorigincity((String)jc1.getSelectedItem());
o.setdestinationcity((String)jc2.getSelectedItem());
o.setdate((String)jc3.getSelectedItem());
URL url=new URL("http://localhost:8080/servlet/seats");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
ss=response.getstatus();
area2.setText(ss);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
public void writeOb(URLConnection con,obj o)
{
try
{
con.setUseCaches(false);
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
con.setDoInput(true);
con.setDoOutput(true);
ObjectOutputStream os=new ObjectOutputStream(con.getOutputStream());
System.out.println("writing params");
os.writeObject(o);
System.out.println("data sent");
os.flush();
os.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
public obj readOb(URLConnection con)
{
obj o=null;
try
{
ObjectInputStream is=new ObjectInputStream(con.getInputStream());
System.err.println("waiting for response");
o=(obj)is.readObject();
is.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe.getMessage());
}
return o;
}

}
class fare extends JPanel
{
JLabel jl1;JLabel jl2;JComboBox jc1;JButton jb;JComboBox jc2;JTextArea
area;
public fare()
{
setForeground(Color.black);
jl1=new JLabel("ORIGIN CITY");
jl2=new JLabel("DESTINATION CITY");
jc1=new JComboBox();

jc1.addItem("AGARTALA");jc1.addItem("AHMEDABAD");jc1.addItem("BANGALORE");
jc1.addItem("BHUBANESHWAR");

jc1.addItem("CALICUT");jc1.addItem("CHANDIGARH");jc1.addItem("DELHI");jc1.addItem("GUWAHATI");

jc1.addItem("HYDERABAD");jc1.addItem("IMPHAL");jc1.addItem("INDORE");jc1.addItem("JAIPUR");

jc1.addItem("JAMMU");jc1.addItem("KOLKATA");jc1.addItem("LUCKNOW");jc1.addItem("MADRAS");

jc1.addItem("MUMBAI");jc1.addItem("NAGPUR");jc1.addItem("PANAJI");jc1.addItem("PATNA");

jc1.addItem("SHILLONG");jc1.addItem("SHIMLA");jc1.addItem("TRIVANDRUM");jc1.addItem("VADODARA");
jb=new JButton("GET FARE");
jc2=new JComboBox();

jc2.addItem("AGARTALA");jc2.addItem("AHMEDABAD");jc2.addItem("BANGALORE");
jc2.addItem("BHUBANESHWAR");

jc2.addItem("CALICUT");jc2.addItem("CHANDIGARH");jc2.addItem("DELHI");jc2.addItem("GUWAHATI");

jc2.addItem("HYDERABAD");jc2.addItem("IMPHAL");jc2.addItem("INDORE");jc2.addItem("JAIPUR");

jc2.addItem("JAMMU");jc2.addItem("KOLKATA");jc2.addItem("LUCKNOW");jc2.addItem("MADRAS");

jc2.addItem("MUMBAI");jc2.addItem("NAGPUR");jc2.addItem("PANAJI");jc2.addItem("PATNA");

jc2.addItem("SHILLONG");jc2.addItem("SHIMLA");jc2.addItem("TRIVANDRUM");jc2.addItem("VADODARA");

area=new JTextArea("",10,1000);
setLayout(new GridLayout(6,2,5,5));
add(jl1); add(jc1);
add(jl2); add(jc2);
add(jb); add(new JLabel());
add(area);
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
flightfare(ae);
}
});
}
void flightfare(ActionEvent ae)
{
try
{
obj o=new obj();
o.setorigincity((String)jc1.getSelectedItem());
o.setdestinationcity((String)jc2.getSelectedItem());
URL url=new URL("http://localhost:8080/servlet/fare");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
String ss=response.getprice();
area.setText(ss);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
public void writeOb(URLConnection con,obj o)
{
try
{
con.setUseCaches(false);
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
con.setDoInput(true);
con.setDoOutput(true);
ObjectOutputStream os=new ObjectOutputStream(con.getOutputStream());
System.out.println("writing params");
os.writeObject(o);
System.out.println("data sent");
os.flush();
os.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
public obj readOb(URLConnection con)
{
obj o=null;
try
{
ObjectInputStream is=new ObjectInputStream(con.getInputStream());
System.err.println("waiting for response");
o=(obj)is.readObject();
is.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe.getMessage());
}
return o;
}

}
class arrdep extends JPanel
{
JLabel jl1;JLabel jl2;JLabel jl3;JLabel jl4;JLabel jl5;JButton
jb1;JTextField jtf1;
JTextField jtf2;JTextArea jta1;JTextArea jta2;JButton jb2;JComboBox
jc1;JComboBox jc2;
JComboBox jc3;JComboBox jc4;
public arrdep()
{
jl1=new JLabel("Arrival");
jl2=new JLabel("Flight No");JLabel jl6=new JLabel("Flight No");
jl3=new JLabel("DESTINATION CITY");JLabel jl7=new JLabel("ORIGIN CITY");
jl4=new JLabel("Day Time");JLabel jl8=new JLabel("Day Time");
jl5=new JLabel("Departure");
jb1=new JButton("Arrival");
jtf1=new JTextField(6);
jtf2=new JTextField(6);
jta1=new JTextArea();
jta2=new JTextArea();
jb2=new JButton("Departure");
jc1=new JComboBox();

jc1.addItem("AGARTALA");jc1.addItem("AHMEDABAD");jc1.addItem("BANGALORE");
jc1.addItem("BHUBANESHWAR");

jc1.addItem("CALICUT");jc1.addItem("CHANDIGARH");jc1.addItem("DELHI");jc1.addItem("GUWAHATI");

jc1.addItem("HYDERABAD");jc1.addItem("IMPHAL");jc1.addItem("INDORE");jc1.addItem("JAIPUR");

jc1.addItem("JAMMU");jc1.addItem("KOLKATA");jc1.addItem("LUCKNOW");jc1.addItem("MADRAS");

jc1.addItem("MUMBAI");jc1.addItem("NAGPUR");jc1.addItem("PANAJI");jc1.addItem("PATNA");

jc1.addItem("SHILLONG");jc1.addItem("SHIMLA");jc1.addItem("TRIVANDRUM");jc1.addItem("VADODARA");
jc3=new JComboBox();

jc3.addItem("MORNING");jc3.addItem("AFTERNOON");jc3.addItem("EVENING");
jc2=new JComboBox();

jc2.addItem("AGARTALA");jc2.addItem("AHMEDABAD");jc2.addItem("BANGALORE");
jc2.addItem("BHUBANESHWAR");

jc2.addItem("CALICUT");jc2.addItem("CHANDIGARH");jc2.addItem("DELHI");jc2.addItem("GUWAHATI");

jc2.addItem("HYDERABAD");jc2.addItem("IMPHAL");jc2.addItem("INDORE");jc2.addItem("JAIPUR");

jc2.addItem("JAMMU");jc2.addItem("KOLKATA");jc2.addItem("LUCKNOW");jc2.addItem("MADRAS");

jc2.addItem("MUMBAI");jc2.addItem("NAGPUR");jc2.addItem("PANAJI");jc2.addItem("PATNA");

jc2.addItem("SHILLONG");jc1.addItem("SHIMLA");jc2.addItem("TRIVANDRUM");jc2.addItem("VADODARA");
jc4=new JComboBox();

jc4.addItem("MORNING");jc4.addItem("AFTERNOON");jc4.addItem("EVENING");
setLayout(new GridLayout(8,4,3,3));
add(jl1);add(new JLabel());add(new JLabel());add(new JLabel());
add(jl2);add(jtf1);add(jl3);add(jc1);
add(jl4);add(jc3);add(new JLabel());add(new JLabel());
add(jb1);add(jta1);add(new JLabel());add(new JLabel());

//-----------------------------------------------------------------------------
add(jl5);add(new JLabel());add(new JLabel());add(new JLabel());
add(jl6);add(jtf2);add(jl7);add(jc2);
add(jl8);add(jc4);add(new JLabel());add(new JLabel());
add(jb2);add(jta2);
jb1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
flightarrival(ae);
}
});
jb2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
flightdeparture(ae);
}
});
}
void flightarrival(ActionEvent ae)
{
try
{
obj o=new obj();
o.setflightno(jtf1.getText());
o.setdestinationcity((String)jc1.getSelectedItem());
o.setdaytime((String)jc3.getSelectedItem());
URL url=new URL("http://localhost:8080/servlet/arrival");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
String ss=response.getstatus();
jta1.setText(ss);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
void flightdeparture(ActionEvent ae)
{
try
{
obj o=new obj();
o.setflightno(jtf2.getText());
o.setorigincity((String)jc2.getSelectedItem());
o.setdaytime((String)jc4.getSelectedItem());
URL url=new URL("http://localhost:8080/servlet/departure");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
String ss1=response.getstatus();
jta2.setText(ss1);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
public void writeOb(URLConnection con,obj o)
{
try
{
con.setUseCaches(false);
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
con.setDoInput(true);
con.setDoOutput(true);
ObjectOutputStream os=new ObjectOutputStream(con.getOutputStream());
System.out.println("writing params");
os.writeObject(o);
System.out.println("data sent");
os.flush();
os.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
public obj readOb(URLConnection con)
{
obj o=null;
try
{
ObjectInputStream is=new ObjectInputStream(con.getInputStream());
System.err.println("waiting for response");
o=(obj)is.readObject();
is.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe.getMessage());
}
return o;
}

}
class pnr extends JPanel
{
JLabel jl1;
JLabel jl3;JTextField jtf;JButton jb;JTextArea jta;
public pnr()
{
jl1=new JLabel("Please enter your PNR number");
jl3=new JLabel("PNR Number");
jtf=new JTextField(10);
jb=new JButton("Submit Query");
jta=new JTextArea();
setLayout(new GridLayout(6,2,5,5));
add(jl1);add(new JLabel("to know the current"));
add(new JLabel("status of your query"));add(new JLabel());
add(jl3);add(jtf);add(jb);add(jta);
add(new JLabel());add(new JLabel());
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
pnrnumber(ae);
}
});
}
void pnrnumber(ActionEvent ae)
{
try
{
obj o=new obj();
o.setpnrnumber(jtf.getText());
URL url=new URL("http://localhost:8080/servlet/pnrnumber");
System.out.println("openeing connection");
URLConnection con=url.openConnection();
writeOb(con,o);
obj response=readOb(con);
if(response!=null)
{
String ss=response.getstatus();
jta.setText(ss);
}
}
catch(MalformedURLException mue)
{
System.err.println(mue.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
}
public void writeOb(URLConnection con,obj o)
{
try
{
con.setUseCaches(false);
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
con.setDoInput(true);
con.setDoOutput(true);
ObjectOutputStream os=new ObjectOutputStream(con.getOutputStream());
System.out.println("writing params");
os.writeObject(o);
System.out.println("data sent");
os.flush();
os.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
public obj readOb(URLConnection con)
{
obj o=null;
try
{
ObjectInputStream is=new ObjectInputStream(con.getInputStream());
System.err.println("waiting for response");
o=(obj)is.readObject();
is.close();
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe.getMessage());
}
return o;
}
 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG