#native_company# #native_desc#
#native_cta#

Power of PHP, Java Swing ,JDBC for Application Develoment

By James Smith
on September 13, 2002

Version: 1

Type: Full Script

Category: Other

License: GNU General Public License

Description: Hi Friends, Thanks for the response u gave me for my previous codes,
I am a hardcore PHP Programmer; found PHP the best for Development of
Dynamic Websites, But as a programmer getting lots of project of Different Types
I found Java very good for Application Development,
I saw many sites, nowhere could I find a clear description of how to use
Java swing with JDBC,
So I wrote this code, which will be very helpful for Application Development
Programmers, in fact as u know u can call java applets and java programs from PHP
So this could be a great advantage source code

/*
//--------------------Read First Installation Instructions ---------------------
Code By : James Smith
My Email : [email protected]
================== Directory ============================
make directory james in c: , that is c:james
place the following files in this directory 
download these files from
http://www.geocities.com/james_smith73/james.zip
1. frametest2.java
2. james.mdb
3. sidebar33.jpg
================== Autoexec.bat =========================
step 1 : SET classpath=
step 2 : SET PATH=c:windows;c:windowscommand;c:jdk1.2.1bin;c:
step 3 : SET JAVA_HOME=c:jdk1.2.1
================== ODBC Settings ========================
step 4 : click control panel
step 5 : ODBC Data Sources
step 6 : click UserDSN Tab
step 7 : click ADD Button , Select Microsoft Access Driver , Finish 
step 8 : Give Datasource Name as  "james" , no double quotes
step 9 : use Select and select james.mdb from c:jamesjames.mdb
click ok , ok finish
================== Compile ================================
cd c:james
javac frametest2.java
================= Run ====================================
java frametest2
login 'a' and password 'a' for Accoutant (use this)
login 'p' and password 'p' for Principal
//------------------- 
*/


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.table.*;

public class frametest2 extends JFrame 
{		
 		//============================================================ Start Variables ==========
		boolean inAnApplet = true;   
		final boolean shouldFill = true;
    	final boolean shouldWeightX = true;
		final static String MYPANEL1 = " LOGIN ";
		final static String MYPANEL2 = " ADD STUDENT DETAILS ";
		final static String MYPANEL3 = " MODIFY / DELETE STUDENT DETAILS ";
		final static String MYPANEL4 = " STUDENT REPORTS ";
		final static String MYPANEL5 = " SEARCH STUDENT DETAILS ";
		final static String MYPANEL6 = " VIEW STUDENT DETAILS ";
		final static String MYPANEL7 = " GENERATE REPORTS ";
		ImageIcon ii = new ImageIcon("sidebar33.jpg");
		Font dataFont = new Font("courier new",Font.PLAIN,12);
		Font titleFont = new Font("courier new",Font.BOLD,14);
		JLabel jLabel, jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6;
		JLabel jLabel7, jLabel8, jLabel9 ;
		JRadioButton jRadiobutton, Male, Female, mMale, mFemale;
		ActionListener rlistener = new RadioListener();		
		JCheckBox jCheckbox, SSLC, PHOTO, CHARCERT, NCCCERT, mSSLC, mPHOTO, mCHARCERT, mNCCCERT;
		CheckBoxListener myListener = new CheckBoxListener();
		JComboBox jCombobox, jCombobox1, jCombobox2 ,mjCombobox1, mjCombobox2, jCombobox3;
		ComboBoxListener cbListener = new ComboBoxListener();
		Container contentPane = getContentPane();
		JDialog dialog = new JDialog((Frame) null, "! DELETE CONFIRMATION !", true);
		Container dialogContentPane = dialog.getContentPane();
  	    GridBagLayout gridbag = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();	
		GridBagConstraints c2 = new GridBagConstraints();	
		ButtonGroup bg = new ButtonGroup();
		String sql, sql1, dialogmessage, sr, Namesel, reg_no;
		String driver="sun.jdbc.odbc.JdbcOdbcDriver";
		String url="jdbc:odbc:james";		
		String dialogtitle = "Student Record Added";
		String dialogf = "LOGIN FAILED";
		String dialogm = "DATABASE RECORD UPDATED";
		String dialogd = "DATABASE RECORD DELETED";
		String Sexsel = "Male";
		String Yearsel = "1st PUC";
		String Sectionsel = "Section A";
		String currname = "";
		String tempname = "";
		int SSLCsel, PHOTOsel, CHARCERTsel, NCCCERTsel, mSSLCsel, mPHOTOsel, mCHARCERTsel, mNCCCERTsel;
		int dialogtype = JOptionPane.PLAIN_MESSAGE;
		int tempcnt;
		JPanel jPanel, p1, p2, p3;
		JTabbedPane tabbedPane = new JTabbedPane();
		JTextField jTextfield;
		JTextField loginname = new JTextField(40);	
		JTextField loginpass = new JTextField(40);	
		JTextField adds_name = new JTextField(20);	
		JTextField adds_addr = new JTextField(20);					
		JTextField adds_fname = new JTextField(20);		
		JTextField mods_fname = new JTextField(20);		
		JTextField mods_name = new JTextField(20);	
		JTextField mods_addr = new JTextField(20);				
		JButton login = new JButton("LOGIN");
		JButton DELETEIT = new JButton("YES DELETE");
		JButton DONTDELETE = new JButton("NO DELETE");
		JButton button, ADDREC, MODIFY, SHOW_STUDENT_LIST, DELETE;
		JLabel jLabeldlg = new JLabel("Do You Really want to Delete ?");
		Object[] data = new Object[5];
	   	DefaultTableModel defaulttablemodel = new DefaultTableModel();
   		JTable jtable = new JTable(defaulttablemodel);						
		//------------------------------------------------------------ End Variables ------------
		//============================================================ Start main ===============
		public static void main(String args[])
 		{
  			frametest2 app = new frametest2();
 		}
		//------------------------------------------------------------ End main -----------------
		//============================================================ Start frametest2 =========
 		public frametest2() 
 		{
  			super("A TEST APPLICATION");
  			setup();
  			pack();
  			addWindowListener(new WindowEventHandler());
  			show();
 		}
		//------------------------------------------------------------ End frametest2 ------------
		//============================================================ Start setup ===============
 		void setup() 
 		{
  			setupMenuBar();
			showpane1();
			contentPane.add(tabbedPane, BorderLayout.CENTER);
  		}
		//------------------------------------------------------------ End setup -----------------
		//============================================================ Start setupMenuBar ========
 		void setupMenuBar() 
		{
  			  MenuBar menuBar = new MenuBar();
			  Menu fileMenu = new Menu("File");			  		
			  		MenuItem fileExit = new MenuItem("Exit");			  			  
			  			fileExit.addActionListener(new MenuItemHandler()); 
			  			fileMenu.add(fileExit);					
			  		menuBar.add(fileMenu);
			  setMenuBar(menuBar);
 		}	
		//------------------------------------------------------------ End setupMenuBar-----------
		//============================================================ Start showpane1 ============		
		void showpane1()
		{
			p1 = new JPanel()
			{
	                public Dimension getPreferredSize() 
					{
	                	Dimension size = super.getPreferredSize();
	                	size.width = 785;	
						size.height = 495;	
	                	return size;
	            	}
	        };	
			p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Login Panel"));
			p1.setFont(titleFont);
			p1.setLayout(gridbag);  		
			   	jLabel1 = new JLabel("Enter Username : ");
				jLabel1.setFont(dataFont);
			        c.ipady = 2;       						
					c.ipadx = 2;       						
			        c.weighty = 0.0;   						
			        c.anchor = GridBagConstraints.WEST; 	
			      	c.gridwidth = 1;   						
			        c.gridx = 0;       						   
			        c.gridy = 0;       						
			        gridbag.setConstraints(jLabel1, c);
		        p1.add(jLabel1);				
				loginname = new JTextField("                                           ");
			    	c.ipady = 2;       						
					c.ipadx = 2;       						
		        	c.weighty = 0.0;   						
		        	c.anchor = GridBagConstraints.WEST; 	
		       		c.gridwidth = 2;   						
		        	c.gridx = 1;       						    
		        	c.gridy = 0;       						
		        	gridbag.setConstraints(loginname, c);
		        p1.add(loginname);				
				jLabel2 = new JLabel("Enter Password : ");
				jLabel2.setFont(dataFont);
			        c.ipady = 2;       						
					c.ipadx = 2;       						
			        c.weighty = 0.0;   						
			        c.anchor = GridBagConstraints.WEST; 	
			        c.gridwidth = 1;   						
			        c.gridx = 0;       						     
			        c.gridy = 1;       						
			        gridbag.setConstraints(jLabel2, c);
			     p1.add(jLabel2);				
				loginpass = new JTextField("                                           ");
			    	c.ipady = 2;       						
					c.ipadx = 2;       						
		        	c.weighty = 0.0;   						
		        	c.anchor = GridBagConstraints.WEST; 	
		       		c.gridwidth = 2;   						
		        	c.gridx = 1;       						     
		        	c.gridy = 1;       						
		        	gridbag.setConstraints(loginpass, c);
		        p1.add(loginpass);				
				button = new JButton("LOGIN");
		        	c.ipady = 2;       						
					c.ipadx = 2;       						
		        	c.weighty = 0.0;   						
		        	c.anchor = GridBagConstraints.CENTER; 	        
					c.gridwidth = 1;   						
		        	c.gridx = 1;       						      
		        	c.gridy = 2;       						
		        	gridbag.setConstraints(button, c);
		        p1.add(button);										
				button.addActionListener(new ButtonHandler());  				
			tabbedPane.addTab(MYPANEL1, p1);
		}
		//------------------------------------------------------------ End__ showpane1 -----------
		//============================================================ Start showpane2 ===========
		void showpane2() //ADD STUDENT DETAILS
		{			
				   p2 = new JPanel();
				   p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Add Student Details"));
				   p2.setLayout(gridbag);					  		   
				   jLabel3 = new JLabel(" Student Name : ");	
						jLabel3.setFont(dataFont);		
						c.fill = GridBagConstraints.BOTH;		
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 0;       						     
			        	c.gridy = 1;       						
			        	gridbag.setConstraints(jLabel3, c);				
					p2.add(jLabel3);															
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 1;       						     
			        	c.gridy = 1;       						
			        	gridbag.setConstraints(adds_name, c);				
					p2.add(adds_name);									
					jLabel4 = new JLabel(" Student Address : ");	
						jLabel4.setFont(dataFont);				
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 0;       						     
			        	c.gridy = 2;       						
			        	gridbag.setConstraints(jLabel4, c);		
					p2.add(jLabel4);																		  
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 1;       						     
			        	c.gridy = 2;   
					p2.add(adds_addr);											
					gridbag.setConstraints(adds_addr, c);	
					jLabel5 = new JLabel(" Father's Name : ");	
						jLabel5.setFont(dataFont);				
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 0;       						     
			        	c.gridy = 3;       						
			        	gridbag.setConstraints(jLabel5, c);				
					p2.add(jLabel5);											
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 1;       						     
			        	c.gridy = 3;       						
			        	gridbag.setConstraints(adds_fname, c);				
					p2.add(adds_fname);												
					Male = new JRadioButton("Male",true);
						Male.setFont(dataFont);		
						c.fill = GridBagConstraints.BOTH;
						c.ipady = 2;       						
		       			c.ipadx = 2;  
		       			c.gridx = 1;
		        		c.gridy = 4;
		        		gridbag.setConstraints(Male, c);
						Male.addActionListener(rlistener);
						bg.add(Male);
					p2.add(Male);										
	   				Female = new JRadioButton("Female",false);
						Female.setFont(dataFont);		
						c.fill = GridBagConstraints.BOTH;
						c.ipady = 2;       						
		       			c.ipadx = 2;  
		       			c.gridx = 2;
		        		c.gridy = 4;
		        		gridbag.setConstraints(Female, c);
						bg.add(Female);		
						Female.addActionListener(rlistener);	
					p2.add(Female);								
					jLabel6 = new JLabel(" Class : ");	
						jLabel6.setFont(dataFont);				
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 0;       						     
			        	c.gridy = 5;       						
			        	gridbag.setConstraints(jLabel6, c);				
					p2.add(jLabel6);													
					jCombobox1 = new JComboBox();
						jCombobox1.setFont(dataFont);	
				 		jCombobox1.addItem("1st PUC");
		    			jCombobox1.addItem("2nd PUC");
		    			c.fill = GridBagConstraints.BOTH;
						c.insets = new Insets(10,0,0,30);  		
						c.ipady = 2;     						
						c.ipadx = 2;							
		       	        c.gridx = 1;							
		        		c.gridy = 5;							
						jCombobox1.addItemListener(cbListener);	
		        		gridbag.setConstraints(jCombobox1, c);
		        	p2.add(jCombobox1);							
					jCombobox2 = new JComboBox();
						jCombobox2.setFont(dataFont);	
				 		jCombobox2.addItem("Section A");
		    			jCombobox2.addItem("Section B");
						jCombobox2.addItem("Section C");
						c.fill = GridBagConstraints.BOTH;
						c.insets = new Insets(10,0,0,30);  		
		    			c.ipady = 2;     
						c.ipadx = 2;		
		       	        c.gridx = 2;	
		        		c.gridy = 5;			
						jCombobox2.addItemListener(cbListener);			
		        		gridbag.setConstraints(jCombobox2, c);
		        	p2.add(jCombobox2);										
						SSLC = new JCheckBox("SSLC Marks Card  ");
						c.fill = GridBagConstraints.BOTH;
						c.ipady = 0;       						
						c.ipadx = 0;  
						c.gridx = 1;       						     
			        	c.gridy = 6; 						
						gridbag.setConstraints(SSLC, c);
						SSLC.setFont(dataFont);
						SSLC.addItemListener(myListener);
    					p2.add(SSLC);										
						PHOTO = new JCheckBox("PHOTO (Passport Size)  ");
						c.ipady = 0;       						
						c.ipadx = 0;  
						c.gridx = 2;       						     
			        	c.gridy = 6; 
						gridbag.setConstraints(PHOTO, c);
						PHOTO.setFont(dataFont);
						PHOTO.addItemListener(myListener);
    					p2.add(PHOTO);							
						CHARCERT = new JCheckBox("Charecter Certificater");
						c.ipady = 0;       						
						c.ipadx = 0;  
						c.gridx = 1;       						     
			        	c.gridy = 7; 
						gridbag.setConstraints(CHARCERT, c);
						CHARCERT.setFont(dataFont);
						CHARCERT.addItemListener(myListener);
    					p2.add(CHARCERT);												
						NCCCERT = new JCheckBox("NCC Certificate Given");
						c.ipady = 0;       						
						c.ipadx = 0;  
						c.gridx = 2;       						     
			        	c.gridy = 7;
						gridbag.setConstraints(NCCCERT, c);
						NCCCERT.setFont(dataFont);
						NCCCERT.addItemListener(myListener);
    					p2.add(NCCCERT);											
					ADDREC = new JButton("SAVE RECORD");										
						c.ipady = 2;       						
						c.ipadx = 2;  
						c.gridx = 2;       						     
			        	c.gridy = 8;  
						gridbag.setConstraints(ADDREC, c);
						p2.add(ADDREC);
						ADDREC.addActionListener(new ButtonHandler());
					jLabel7 = new JLabel(" ", ii, JLabel.CENTER);	
						c.fill = GridBagConstraints.BOTH;
						c.gridwidth = 5; 
						c.gridx = 0;       						     
			        	c.gridy = 9;       						
			        	gridbag.setConstraints(jLabel7, c);				
					p2.add(jLabel7);				   
				tabbedPane.addTab(MYPANEL2, p2);
		}
		//-------------------------------------------------------------- End showpane2 ---------
		void showpane3()
		{			  	   
				   p3 = new JPanel();
				   p3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Modify Student Details"));
				   p3.setLayout(gridbag);	
				   jCombobox3 = new JComboBox();
				   		jCombobox3.addItem("Select Student : ");
						jCombobox3.setFont(dataFont);	
						c2.fill = GridBagConstraints.BOTH;		
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 2;       						     
			        	c2.gridy = 1;       						
			        	gridbag.setConstraints(jCombobox3, c2);			
						jCombobox3.addItemListener(cbListener);		
					p3.add(jCombobox3);		
				   JLabel jl8 = new JLabel(" Student Name : ");
						jl8.setFont(dataFont);		
						c2.fill = GridBagConstraints.BOTH;		
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 0;       						     
			        	c2.gridy = 1;       						
			        	gridbag.setConstraints(jl8, c2);				
					p3.add(jl8);				
					mods_name = new JTextField(20);	
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 1;       						     
			        	c2.gridy = 1;       						
			        	gridbag.setConstraints(mods_name, c2);				
					p3.add(mods_name);	
					JLabel jl9 = new JLabel(" Student Address : ");
						jl9.setFont(dataFont);		
						c2.fill = GridBagConstraints.BOTH;		
						c2.ipady = 2;       						
						c2.ipadx = 2;    
						c2.gridx = 0;       						     
			        	c2.gridy = 2;       						
			        	gridbag.setConstraints(jl9, c2);				
					p3.add(jl9);		
					mods_addr = new JTextField(20);	
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 1;       						     
			        	c2.gridy = 2;       						
			        	gridbag.setConstraints(mods_addr, c2);				
					p3.add(mods_addr);				
					jLabel5 = new JLabel(" Father's Name : ");	
						jLabel5.setFont(dataFont);				
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 0;       						     
			        	c2.gridy = 3;       						
			        	gridbag.setConstraints(jLabel5, c2);				
					p3.add(jLabel5);											
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 1;       						     
			        	c2.gridy = 3;       						
			        	gridbag.setConstraints(mods_fname, c2);				
					p3.add(mods_fname);												
					mMale = new JRadioButton("Male",true);
						mMale.setFont(dataFont);		
						c2.fill = GridBagConstraints.BOTH;
						c2.ipady = 2;       						
		       			c2.ipadx = 2;  
		       			c2.gridx = 1;
		        		c2.gridy = 4;
		        		gridbag.setConstraints(mMale, c2);
						mMale.addActionListener(rlistener);
						bg.add(mMale);
					p3.add(mMale);										
	   				mFemale = new JRadioButton("Female",false);
						mFemale.setFont(dataFont);		
						c2.fill = GridBagConstraints.BOTH;
						c2.ipady = 2;       						
		       			c2.ipadx = 2;  
		       			c2.gridx = 2;
		        		c2.gridy = 4;
		        		gridbag.setConstraints(mFemale, c2);
						bg.add(mFemale);		
						mFemale.addActionListener(rlistener);	
					p3.add(mFemale);								
					jLabel6 = new JLabel(" Class : ");	
						jLabel6.setFont(dataFont);				
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 0;       						     
			        	c2.gridy = 5;       						
			        	gridbag.setConstraints(jLabel6, c2);				
					p3.add(jLabel6);													
					mjCombobox1 = new JComboBox();
						mjCombobox1.setFont(dataFont);	
				 		mjCombobox1.addItem("1st PUC");
		    			mjCombobox1.addItem("2nd PUC");
		    			c2.fill = GridBagConstraints.BOTH;
						c2.insets = new Insets(10,0,0,30);  		
						c2.ipady = 2;     						
						c2.ipadx = 2;							
		       	        c2.gridx = 1;							
		        		c2.gridy = 5;							
						mjCombobox1.addItemListener(cbListener);	
		        		gridbag.setConstraints(mjCombobox1, c2);
		        	p3.add(mjCombobox1);							
					mjCombobox2 = new JComboBox();
						mjCombobox2.setFont(dataFont);	
				 		mjCombobox2.addItem("Section A");
		    			mjCombobox2.addItem("Section B");
						mjCombobox2.addItem("Section C");
						c2.fill = GridBagConstraints.BOTH;
						c2.insets = new Insets(10,0,0,30);  		
		    			c2.ipady = 2;     
						c2.ipadx = 2;		
		       	        c2.gridx = 2;	
		        		c2.gridy = 5;			
						mjCombobox2.addItemListener(cbListener);			
		        		gridbag.setConstraints(mjCombobox2, c2);
		        	p3.add(mjCombobox2);										
						mSSLC = new JCheckBox("SSLC Marks Card  ");
						c2.fill = GridBagConstraints.BOTH;
						c2.ipady = 0;       						
						c2.ipadx = 0;  
						c2.gridx = 1;       						     
			        	c2.gridy = 6; 						
						gridbag.setConstraints(mSSLC, c2);
						mSSLC.setFont(dataFont);
						mSSLC.addItemListener(myListener);
    					p3.add(mSSLC);										
						mPHOTO = new JCheckBox("PHOTO (Passport Size)  ");
						c2.ipady = 0;       						
						c2.ipadx = 0;  
						c2.gridx = 2;       						     
			        	c2.gridy = 6; 
						gridbag.setConstraints(mPHOTO, c2);
						mPHOTO.setFont(dataFont);
						mPHOTO.addItemListener(myListener);
    					p3.add(mPHOTO);							
						mCHARCERT = new JCheckBox("Charecter Certificater");
						c2.ipady = 0;       						
						c2.ipadx = 0;  
						c2.gridx = 1;       						     
			        	c2.gridy = 7; 
						gridbag.setConstraints(mCHARCERT, c2);
						mCHARCERT.setFont(dataFont);
						mCHARCERT.addItemListener(myListener);
    					p3.add(mCHARCERT);												
						mNCCCERT = new JCheckBox("NCC Certificate Given");
						c2.ipady = 0;       						
						c2.ipadx = 0;  
						c2.gridx = 2;       						     
			        	c2.gridy = 7; 
						gridbag.setConstraints(mNCCCERT, c2);
						mNCCCERT.setFont(dataFont);
						mNCCCERT.addItemListener(myListener);
    					p3.add(mNCCCERT);	
					DELETE = new JButton("DELETE RECORD");										
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 1;       						     
			        	c2.gridy = 8;  
						gridbag.setConstraints(DELETE, c2);
						p3.add(DELETE);
						DELETE.addActionListener(new ButtonHandler());											
					MODIFY = new JButton("MODIFY RECORD");										
						c2.ipady = 2;       						
						c2.ipadx = 2;  
						c2.gridx = 2;       						     
			        	c2.gridy = 8;  
						gridbag.setConstraints(MODIFY, c2);
						p3.add(MODIFY);
						MODIFY.addActionListener(new ButtonHandler());					
					jLabel7 = new JLabel(" ", ii, JLabel.CENTER);	
						c2.fill = GridBagConstraints.BOTH;
						c2.gridwidth = 5; 
						c2.gridx = 0;       						     
			        	c2.gridy = 10;       						
			        	gridbag.setConstraints(jLabel7, c2);				
					p3.add(jLabel7);					
			tabbedPane.addTab(MYPANEL3, p3);	
			accessDBMOD();
		}
		void showpane4()
		{
			  JPanel p4 = new JPanel();			
			  try
			  {			  
					Class.forName(driver);					
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();	
					String query = "SELECT StudentID, Name, Address, FName FROM student_det";
					ResultSet rs = statement.executeQuery(query);	
					ResultSetMetaData rmeta = rs.getMetaData();
					int numColumns=rmeta.getColumnCount();					
					for(int i=1;i<=numColumns;++i) 
					{
   						if(i<=numColumns)
						{
							defaulttablemodel.addColumn(rmeta.getColumnName(i));
						}   					
  					}					
					while(rs.next())
					{   						
						for(int i=1;i<=numColumns;++i)   
						{		
							if(i<=numColumns)
							{				 	
								tempname = rs.getString(i);
								tempcnt=i-1;
								data[tempcnt] = tempname;		
							}			
	   					}   
						defaulttablemodel.addRow(data);						
   					}
			  }
			  catch(Exception ex)
			  {
			  		//
			  }
	        p4.add(new JScrollPane(jtable));
			tabbedPane.addTab(MYPANEL4, p4);
		}		
		void showpane5()
		{
			JPanel p5 = new JPanel();				
				jLabel = new JLabel(" Inside Panel 5 ");	
					jLabel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"ONE TEST"));
					p5.add(jLabel);
				jLabel2 = new JLabel(" Inside Panel 55 ");	
					jLabel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"ONE TEST 22"));
					p5.add(jLabel2);
			tabbedPane.addTab(MYPANEL5, p5);
		}
		void showpane6()
		{			
			JPanel p6 = new JPanel();
				jLabel = new JLabel(" Inside Panel 6 ");	
				p6.add(jLabel);
			tabbedPane.addTab(MYPANEL6, p6);
		}
		void showpane7()
		{
			JPanel p7 = new JPanel();
				jLabel = new JLabel(" Inside Panel 7 ");	
				p7.add(jLabel);
			tabbedPane.addTab(MYPANEL7, p7);
		}
		void showpane2345()
		{	
			showpane2();
			showpane3();
			showpane4();
			showpane5();
		}
		void showpane67()
		{	
			showpane6();
			showpane7();
		}		
		void accessDB() 
		{		 	
			  try
			  {			   		
					String var1 =  loginname.getText();
						   var1 =  var1.trim();
					String var2 =  loginpass.getText();
						   var2 =  var2.trim();					
					sql = "SELECT * FROM login WHERE username='"+var1+"' AND password='"+var2+"'";
					Class.forName(driver);
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();
					boolean hasResults = statement.execute(sql);
			   		if(hasResults)
					{
			    		ResultSet result = statement.getResultSet();
			    		if(result!=null)
						{ 		
							displayResults(result);
			   			}
						connection.close();
			  		}				
			  }
			  catch(Exception ex)
			  {

			  }
		}		
		void accessDBMod(String nsel) 
		{		 	
			  try
			  {			   	
					sql = "SELECT * FROM student_det WHERE Name='"+nsel+"'";
					Class.forName(driver);
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();
					boolean hasResults = statement.execute(sql);
			   		if(hasResults)
					{
			    		ResultSet result = statement.getResultSet();
			    		if(result!=null)
						{ 		
							displayResultsMod(result);
			   			}
						connection.close();
			  		}						
			  }
			  catch(Exception ex)
			  {

			  }
		}	
		void accessDBDel(String nsel) 
		{		 	
			  try
			  {					  					
					Class.forName(driver);					
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();	
					sql = "DELETE FROM student_det WHERE Name='"+nsel+"'";
					statement.executeUpdate(sql);					
					connection.close();			
					mjCombobox1.setSelectedIndex(0);		 
					mjCombobox2.setSelectedIndex(0);			 
					mods_name.setText(" ");					
					mods_addr.setText(" ");			
					mods_fname.setText(" ");			
					mSSLC.setSelected(false);			
					mPHOTO.setSelected(false);			
					mNCCCERT.setSelected(false);		
					mCHARCERT.setSelected(false);		
					mMale.doClick();						
			  }
			  catch(Exception ex)
			  {

			  }
		}	
		void displayResults(ResultSet r) throws SQLException 
		{
  				ResultSetMetaData rmeta = r.getMetaData();
				int foundrec = 0;
  				int numColumns=rmeta.getColumnCount();  
				while(r.next())
				{								
						String param3 = r.getString(3).trim();
						if (param3.equals("Accounts")) 
						{
							foundrec = 1;
							tabbedPane.removeTabAt(0);
							showpane2345();	
						}
						else if(param3.equals("Principal"))
						{
							foundrec = 1;
							tabbedPane.removeTabAt(0);
							showpane67();	
						}		
  				}		
				if(foundrec==0)
				{
					dialogmessage = "Please Re-Login";
					dialogtype = JOptionPane.INFORMATION_MESSAGE;
					JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogf, dialogtype);
					loginname.setText(" ");
					loginpass.setText(" ");
				}	
		}	
		void displayResultsMod(ResultSet r) throws SQLException 
		{
  				ResultSetMetaData rmeta = r.getMetaData();
				int foundrec = 0;
  				int numColumns=rmeta.getColumnCount();
				String text2="";	
				String text3="";	
				String text4="";	
				String text5="";	
				String text6="";	
				String text7="";	
				String text8="";	
				int int9=0;
				int int10=0;
				int int11=0;
				int int12=0;
				while(r.next())
				{
					reg_no=r.getString(2);
  					text3+=r.getString(3);
					text4+=r.getString(4);
					text5+=r.getString(5);
					text6+=r.getString(6);
					text7+=r.getString(7);
					text8+=r.getString(8);
					int9=r.getInt(9);
					int10=r.getInt(10);
					int11=r.getInt(11);
					int12=r.getInt(12);					
  				}
				currname = text3;
				mods_name.setText(text3);
				mods_addr.setText(text4);
				mods_fname.setText(text5);				
				text6 = text6.trim();
				if (text6.equals("Male")) 
				{
					mMale.doClick();						
				}
				else
				{
					mFemale.doClick();
				}	
				text7 = text7.trim();
				if (text7.equals("2nd PUC")) 
				{
					mjCombobox1.setSelectedIndex(1); 			
				}
				else
				{
					mjCombobox1.setSelectedIndex(0); 
				}				
				text8 = text8.trim();
				if (text8.equals("Section A")) 
				{
					mjCombobox2.setSelectedIndex(0); 			
				}
				else if(text8.equals("Section B"))
				{
					mjCombobox2.setSelectedIndex(1); 
				}				
				else
				{
					mjCombobox2.setSelectedIndex(2); 
				}		
				if(int9==1)
				{
					mSSLC.setSelected(true);
				}
				else
				{
					mSSLC.setSelected(false);
				}
				if(int10==1)
				{
					mPHOTO.setSelected(true);
				}
				else
				{
					mPHOTO.setSelected(false);
				}
				if(int11==1)
				{
					mCHARCERT.setSelected(true);
				}
				else
				{
					mCHARCERT.setSelected(false);
				}
				if(int12==1)
				{
					mNCCCERT.setSelected(true);
				}
				else
				{
					mNCCCERT.setSelected(false);
				}
		}
		void accessDBADD() 
		{
		 	  try
			  {			  
					Class.forName(driver);					
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();	
					String query = "SELECT * FROM student_det";
					ResultSet rs = statement.executeQuery(query);
					int cnt = 0;
					while (rs.next()) 
					{
    					cnt++;      					
					}
					cnt = cnt+1;
					char ys = Yearsel.charAt(0);
					char ss =  Sectionsel.charAt(8);
					reg_no = "02-PCM-"+ys+""+ss+"-"+cnt; 
					sql = "INSERT INTO student_det (StudentID, Name, Address, FName, Sex, Yearsel, Sectionsel, SSLC, PHOTO,  CHARCERT, NCCCERT) VALUES ('"+reg_no+"','"+adds_name.getText()+"','"+adds_addr.getText()+"','"+adds_fname.getText()+"','"+Sexsel+"','"+Yearsel+"','"+Sectionsel+"',"+SSLCsel+","+PHOTOsel+","+CHARCERTsel+","+NCCCERTsel+")"; 
					statement.executeUpdate(sql);	
					connection.close();										
					dialogmessage = " "+adds_name.getText().toUpperCase()+" has Registration Number : "+reg_no;
					dialogtype = JOptionPane.INFORMATION_MESSAGE;
					JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogtitle, dialogtype);
					jCombobox1.setSelectedIndex(0); 
					jCombobox2.setSelectedIndex(0); 
					String snametemp = adds_name.getText();
					jCombobox3.addItem(adds_name.getText());
					adds_name.setText(" ");
					adds_addr.setText(" ");
					adds_fname.setText(" ");
					SSLC.setSelected(false);
					PHOTO.setSelected(false);
					NCCCERT.setSelected(false);
					CHARCERT.setSelected(false);
					Male.doClick();		
			  }
			  catch(Exception ex)
			  {

			  }
		}
		void accessDBMOD() 
		{
		 	  try
			  {			  		
					sql = "SELECT Name FROM student_det ORDER BY Name"; 
					Class.forName(driver);
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();
					boolean hasResults = statement.execute(sql);
					if(hasResults)
					{
			    		ResultSet result = statement.getResultSet();
			    		if(result!=null)
						{ 							
							displayResultsMOD(result);
						}						
			   			connection.close();
			  		}
				
			  }
			  catch(Exception ex)
			  {
			   		
			  }
		}		
		void updateDB() 
		{
		 	  try
			  {
			  		sql = "UPDATE student_det SET Name='"+mods_name.getText()+"', Address='"+mods_addr.getText()+"', FName='"+mods_fname.getText()+"', Sex='"+Sexsel+"', Yearsel='"+Yearsel+"', Sectionsel='"+Sectionsel+"', SSLC="+mSSLCsel+", PHOTO="+mPHOTOsel+", CHARCERT="+mCHARCERTsel+", NCCCERT="+mNCCCERTsel+"  WHERE StudentID='"+reg_no+"'"; 
					Class.forName(driver);
			   		Connection connection=DriverManager.getConnection(url);
			   		Statement statement = connection.createStatement();
					statement.executeUpdate(sql);	
		   			connection.close();
					dialogmessage = " "+mods_name.getText().toUpperCase()+" Record is Updated ";
					dialogtype = JOptionPane.INFORMATION_MESSAGE;
					JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogm, dialogtype);
			  }
			  catch(Exception ex)
			  {
			  		
			  }			  
		}		
		void displayResultsMOD(ResultSet r) throws SQLException 
		{
  				ResultSetMetaData rmeta = r.getMetaData();
  				int numColumns=rmeta.getColumnCount(); 
				while(r.next())
				{	
					for(int i=1;i<=numColumns;++i) 
					{
    					if(i<=numColumns)
						{
							jCombobox3.addItem(r.getString(i));
						}
   					}   					 
  				}	
		}
		//=========================================================== START ButtonHandler ========
 		class ButtonHandler implements ActionListener 
		{
  			public void actionPerformed(ActionEvent ev)
			{
   				String s=ev.getActionCommand(); 
				if(s=="LOGIN") 
				{
					accessDB();					
				}  
				else if(s=="SAVE RECORD")
				{
					accessDBADD();
					String snametemp = adds_name.getText();
				}	
				else if(s=="MODIFY RECORD")
				{					
					String temp_mname = mods_name.getText().trim();
					String temp_currname = currname.trim();
					if(temp_mname.equals(temp_currname))
					{
						
					}
					else
					{
						jCombobox3.addItem(mods_name.getText());	
					}					
					updateDB();					
				}
				else if(s=="DELETE RECORD")
				{
					dialogContentPane.setLayout(new FlowLayout());					
					dialogContentPane.add(jLabeldlg);
					jLabeldlg.setFont(titleFont);
					dialogContentPane.add(DELETEIT);
					DELETEIT.addActionListener(new ButtonHandler());		
					dialogContentPane.add(DONTDELETE);
					DONTDELETE.addActionListener(new ButtonHandler());
					dialog.setBounds(300, 200, 250, 120);
					dialog.show();
				}
				else if(s=="YES DELETE")
				{
					dialog.dispose();
					Namesel = jCombobox3.getSelectedItem().toString();
  					accessDBDel(Namesel);
				}
				else if(s=="NO DELETE")
				{
					dialog.dispose();
				}
			}
 		}
		//=========================================================== END__ ButtonHandler ========
		//=========================================================== START MenuItemHandler ======
 		class MenuItemHandler implements ActionListener 
		{
  			public void actionPerformed(ActionEvent ev)
			{
   				String s=ev.getActionCommand();
   				if(s=="Exit")
				{
    				System.exit(0);
   				}								
  			}					
 		}
		//=========================================================== END__ MenuItemHandler ======
		//=========================================================== START WindowEventHandler ===
 		class WindowEventHandler extends WindowAdapter 
		{
  			public void windowClosing(WindowEvent e)
			{
   				System.exit(0);
  			}
 		}
		//=========================================================== END__ WindowEventHandler ===
		//=========================================================== START RadioListener ========
		class RadioListener implements ActionListener 
		{
      		public void actionPerformed(ActionEvent e) 
			{
				  Sexsel = e.getActionCommand();
		    }
		}
		//=========================================================== END__ RadioListener ========
		//=========================================================== START RadioListener ========
		class ComboBoxListener implements ItemListener  
		{
      		public void itemStateChanged(ItemEvent e) 
			{				
		    	sr = (String)e.getItem();
				if (e.getSource().equals(jCombobox1))
    			{
    				Yearsel = jCombobox1.getSelectedItem().toString();
    			}
				if (e.getSource().equals(mjCombobox1))
    			{
    				Yearsel = mjCombobox1.getSelectedItem().toString();
    			}
    			if (e.getSource().equals(jCombobox2))
    			{
    				Sectionsel = jCombobox2.getSelectedItem().toString();
    			}
				if (e.getSource().equals(mjCombobox2))
    			{
    				Sectionsel = mjCombobox2.getSelectedItem().toString();
    			}
				if (e.getSource().equals(jCombobox3))
    			{
					Namesel = jCombobox3.getSelectedItem().toString();
  					accessDBMod(Namesel);
    			}
		    }
		}
		//=========================================================== END__ RadioListener ========
		//=========================================================== START CheckBoxListener =====		
		class CheckBoxListener implements ItemListener 
		{
    		
			public void itemStateChanged(ItemEvent e) 
    		{
        		Object source = e.getItemSelectable();
				if ((e.getStateChange() == ItemEvent.SELECTED) && (source==SSLC))
       			{
					SSLCsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==SSLC))
       			{
					SSLCsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED)  && (source==PHOTO))
       			{
					PHOTOsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==PHOTO))
       			{
					PHOTOsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED) && (source==NCCCERT))
       			{
					NCCCERTsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==NCCCERT))
       			{
					NCCCERTsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED)  && (source==CHARCERT))
       			{
					CHARCERTsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==CHARCERT))
       			{
					CHARCERTsel = 0;
      			}						
				if ((e.getStateChange() == ItemEvent.SELECTED) && (source==mSSLC))
       			{
					mSSLCsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==mSSLC))
       			{
					mSSLCsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED)  && (source==mPHOTO))
       			{
					mPHOTOsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==mPHOTO))
       			{
					mPHOTOsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED) && (source==mNCCCERT))
       			{
					mNCCCERTsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==mNCCCERT))
       			{
					mNCCCERTsel = 0;
      			}					
				if ((e.getStateChange() == ItemEvent.SELECTED)  && (source==mCHARCERT))
       			{
					mCHARCERTsel = 1;
      			}
				if ((e.getStateChange() == ItemEvent.DESELECTED)  && (source==mCHARCERT))
       			{
					mCHARCERTsel = 0;
      			}								
    		}			
		}
		//=========================================================== END   CheckBoxListener =====
}