Add to Favorites    Make Home Page 134341 Online  
 Language Categories  
 Our Services  

Home » Java Home » Beginners / Lab Assignments Home » Example of JTabbed Pane.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Example of JTabbed Pane.
Author sayantan lahiri
Author Email sayantan_32 [at] yahoo.com
Description
Category Java » Beginners / Lab Assignments
Hits 371620
Code Select and Copy the Code
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; } }

Related Source Codes

Script Name Author
Sending mail Using JavaMail to Yahoo and Gmail accounts sai prasad
Simple Program in Java to Implement Multithreading Satish.K
Simple Calculator in Java Using Remote Method Invocation Satish.K
Guest Book Application Using Servlets Satish.K
String Manipulation Using Stringification Satish.K
String Manipulation Using Stringification Satish.K
Moving Ball Application Using Java Beans Satish.K
Rapid Roll game subrahmanyeswararao
student mgm arpan
Sourav Datta
Download Manager Sagar
Address Book in Java Rahul Chouhan
address book using java database connectivity(jdbc-msaccess) shekhar bansal
sun Steganography B.Rajavel
Connecting Java with MS-Access - Inserting data in Aseem

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=702


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review