Vous êtes sur la page 1sur 97

Chapter 1 About Project

1.1 Introduction to project The system aims at the maintenance and management of the user. Firstly user can create his account. Than the user Login in this site. This system provides all the data related to the user. In this system we also modify or edit his related data. In this system user also view his profile. So this system maintain the all the data of the user. 1.2 Project initiation note Project name: My Facebook Clone Duration: May-July Quality reviewer: Mr. Lalit Panwar Team member: Birendra kumar, Raju Kumar 1.3 Problem statement This reports documentation goes through the whole process of both application program and database development. It also comprises the development tools have been utilized for these purposes. 1.4 Problem discussion This system should consist of an application program, on one hand, and a database on the other. The program should perform the basic operations upon the database as create a account, view profile, edit profile, change the account setting. Any additional functionality is a goal of a further module development. The logical database model (tables, their content and the relationships between them) should respond to the given task and cover the basic requirements. The interface of the program should be user friendly, and the program should be as easy for use as it is possible.

Both controls and forms should logically and functionally be related within the program and fully respond to the structure of the database. 1.5 Problems solution method This involves some subsections that concern the basic scheme of resolving the given task and comprise both the methods and tools of its development as well. At the very commencement, I proceeded to carry out the development of my task into the following steps: 1. Exploring the available development environment and techniques. 2. Database analyzing. 3. Database design and implementation. 4. Programs structure analyzing. 5. GUI constructing. 6. Bringing all the stuff together 7. Tests. 1.6 Program modules 1. Login window 2. Signup window 3. Menu window 4. Profile window 5. Account setting window 6. View profile window 7. View profile1 window

1.7 DFD for the project

SIGNUP

SIGNUP DATABASE

PROFILE LOGIN

FACEBOOK CLONE

EDIT PROFILE

VIEW PROFILE

PROFILE DATABASE
Figure 1.1

1.8 Processing Environment 1.8.1 Hardware requirements 1. Processor: Pentium- IV (minimum) 2. Ram: 256 MB (minimum) 3. Hard disk: 2 GB or higher 1.8.2 Software requirements 1. Operating system: Windows XP, windows 7 2. Front end: Java (core) 3. Back end: MS-Access 2007 1.8.3 Table used 1. Signup table 2. Profile table 1.9 Skills & Knowledge Needed Java (core) JDBC

Chapter 2 Introduction to Java


2.1 History of java Java is a programming language originally developed by James gosling at Sun Microsystems (which is now a subsidiary of oracle corporation) & released in 1995 as a core component of Sun Microsystems java platform. The language derives much of its syntax from C & C++ but has a simpler object model & fewer low level facilities .java applications are typically compiled to byte code (class file) that can run on Java Virtual Machine (JVM) regardless of computer architecture. Java is general purpose, concurrent, class-based, objectoriented language that is specifically design to have as few implementation dependencies as possible .it is intended to let application developers write once ,run anywhere. Java is a currently one of the most popular programming languages in use and is widely used from application software to web application. Java is a general computer programming language developed by Sun Microsystems. Originally called "Oak", by its inventor James Gosling, Java was designed with several innovative features. These include a language that is entirely object oriented, and the ability to write an application once and move it to virtually any platform. James Gosling and his team members were consuming a lot of coffee while developing this language. Good quality of coffee was supplied from a place called Java Island. Hence they fixed the name of the language as Java. The symbol for Java language is cup and saucer. Sun formally announced Java at Sun World conference in 1995. On January 23rd 1996, JDK1.0 version was released. The original and reference implementation java compiler, virtual machines, and class libraries were developed by Sun from 1995. As of may 2007, in compliance with the specification of java community process, sun relicensed most of its java technologies under the GNU general public licence. Others have also developed alternatives implementation of these Sun Technologies, such as the GNU compiler for java and GNU classpath.

2.2 Developer versions (JDK & JRE) 1. JDK 1.0 2. JDK 1.1 3. JDK 1.2 4. JDK 1.3 5. JDK 1.4 6. JDK 1.5 7. JDK 1.6 8. JDK 1.7

2.3 Editor or IDE 1. Notepad 2. Kawa 3. Net bean 4. Eclipse 5. Intellij 6. Ibm visual age 7. Oracle developer 2.4 Objectives 1. Simple 2. Secure 3. Object oriented 4. Portable 5. Platform independent 6. Platform independent 7. Robust 8. In-built 9. Big set of libraries 10. Garbage collection 11. Exception handling facility 12. Multithreaded

2.5 Types of java program 1. 2. Java application Java applets

2.6 Abstract Window Toolkit (AWT) The Java programming language provides a class library called the Abstract Window Toolkit (AWT) that contains a number of common graphical widgets.The AWT defines windows according to a class hierarchy that adds functionality and specificity with each level. 2.6.1 Panel The Panel class is a concrete subclass of Container. It doesnt add any new methods; it simply implements Container. A Panel may be thought of as a recursively nestable, concrete screen component. Panel is the superclass for Applet. When screen output is directed to an applet, it is drawn on the surface of a Panel object. 2.6.2 Window The Window class creates a top-level window. A top-level window is not contained within any other object; it sits directly on the desktop. Generally, you wont create Window objects directly. Instead, you will use a subclass of Window called Frame. Frame encapsulates what is commonly thought of as a window. It is a subclass of Window and has a title bar, menu bar, borders, and resizing corners. If you create a Frame object from within an applet, it will contain a warning message, such as Java Applet Window, to the user that an applet window has been created. 2.6.3 Control fundamentals The AWT supports the following types of controls: Labels Push buttons Check boxes Text editing

2.6.3.1 Label Labels are passive controls that do not support any interaction with the user. The following example creates three labels and adds them to an applet:

Figure 2.1 // Demonstrate Labels import java.awt.*; import java.applet.*; /* <applet code="LabelDemo" width=300 height=200> </applet> */ public class LabelDemo extends Applet { public void init() { Label one = new Label("One"); Label two = new Label("Two"); Label three = new Label("Three"); // add labels to applet window add(one); add(two); add(three);}}

2.6.3.2 Button A Button has a single line label and may be "pushed" with a mouse click.

Figure 2.2 import java.awt.*; import java.applet.Applet; public class ButtonTest extends Applet { public void init() { Button button = new Button("OK"); add(button); } }

2.6.3.3 Checkbox A Checkbox is a label with a small pushbutton. The state of a Checkbox is either true (button is checked) or false (button not checked). The default initial state is false. Clicking a Checkbox toggles its state. For example:

Figure 2.3

import java.awt.*; import java.applet.Applet; public class CheckboxSimpleTest extends Applet { public void init() { Checkbox m = new Checkbox("Allow Mixed Case"); add(m); } } 2.6.3.4 TextField The TextField class implements a single-line text-entry area, usually called an edit control.Text fields allow the user to enter strings and to edit the text using the arrow keys, cut and paste keys, and mouse.

Figure2.4 import java.awt.*; import java.applet.Applet; public class TextFieldSimpleTest extends Applet { public void init() { TextField f1 = new TextField("type something"); add(f1); } }

10

2.6.3.5 TextArea It is a multi-row text field that displays a single string of characters. where newline ('\n' or '\n\r' or '\r', depending on platform) ends each row.

Figure 2.5 import java.awt.*; import java.applet.Applet; public class TextAreaSimpleTest extends Applet { TextArea disp; public void init() { disp = new TextArea("Code goes here", 10, 30); add(disp); } }

2.7 Event handling in java


A user interaction creates an event. Common events are clicking a button, typing in a text field,selecting an item from a menu, closing and window and moving the mouse. The event causes a call to a method called an event handler. Several coding steps are required for an application to respond to events: First create a class for the event handler. Then Implement an appropriate event-listener interface. Register the event handler.

11

Chapter 3 JDBC (Java Database Connectivity)


3.1 Introduction Java provides connectivity to all kinds of databases through its Java Database Connectivity (JDBC)API. The JDBC (Java Database Connectivity) API defines interfaces and classes for writing database applications in Java by making database connections. Using JDBC you can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for executing SQL statements and supports basic SQL functionality. It provides RDBMS access by allowing us to embed SQL inside Java code. In order to write programs that talk to a database in Java, the following requirements are essentials: A relational database Java interface(through JBDC API) Simple knowledge of SQL statements

When we talk about database access, there are two important operations that a Java program must execute. They are: Read data from the database. Write data to the database.

For execution of a program a connection between the Java program and the database system must exist. Since there are different types of databases, the connection between the two would depend on the type of database driver provided by the vendor of the database system. Thus, a set of steps has to be followed to access data from a database. These steps are as follows: Load a driver that connects a Java program and the database system into the memory. Establish a connection to the database through this driver. Execute SQL statements using the established connection.

12

3.2 JDBC architecture

Figure 3.1

Figure 3.2

13

3.3 Java database connectivity steps Before you can create a java jdbc connection to the database, you must first import the java.sql package. 3.3.1 Loading a database driver In this step of the jdbc connection process, we load the driver class by calling Class.forName() with the Driver class name as an argument. Once loaded, the Driver class creates an instance of itself. A client can connect to Database Server through JDBC Driver. try { Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); //Or any other driver } catch(Exception x){ System.out.println( Unable to load the driver class! ); }

3.3.2 Creating a mySQL JDBC connection The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager is considered the backbone of JDBC architecture. Its getConnection() method is used to establish a connection to a database. It uses a username, password, and a jdbc url to establish a connection to the database and returns a connection object. A jdbc Connection represents a session/connection with a specific database. Within the context of a Connection, SQL, PL/SQL statements are executed and results are returned. An application can have one or more connections with a single database, or it can have many connections with different databases.

14

try{ Connection dbConnection=DriverManager.getConnection(url,loginName,Password) } catch( SQLException x ){ System.out.println( Couldnt get connection! ); } The url in our case is jdbc:mysql://localhost:3306/employee loginName by default in MySQL is root and password is tiger. 3.3.3 Creating a JDBC statement object Once a connection is obtained we can interact with the database. Connection interface defines methods for interacting with the database via the established connection. To execute SQL statements, you need to instantiate a Statement object from your connection object by using the createStatement() method. Statement statement = dbConnection.createStatement(); A statement object is used to send and execute SQL statements to a database. Three kinds of statements 1. Create Statement: Execute simple sql queries without parameters. Statement createStatement() Creates an SQL Statement object. 2. Prepared Statement: Execute precompiled sql queries with or without parameters. PreparedStatement prepareStatement(String sql) returns a new PreparedStatement object. PreparedStatement objects are precompiled SQL statements. 3. Callable Statement: Execute a call to a database stored procedure. CallableStatement prepareCall(String sql)returns a new CallableStatement object. CallableStatement objects are SQL stored procedure call statements.

15

3.4 Executing a sql statement with the statement object and returning a JDBC ResultSet Statement interface defines methods that are used to interact with database via the execution of SQL statements. The Statement class has three methods for executing statements:executeQuery(), executeUpdate(), and execute(). For a SELECT statement, the method to use is executeQuery . For statements that create or modify tables, the method to use is executeUpdate.DDL statements are executed with the method executeUpdate. Execute() executes an SQL statement that is written as String object. ResultSet: provides access to a table of data generated by executing a Statement. The table rows are retrieved in sequence. A ResultSet maintains a cursor pointing to its current row of data. The next() method is used to successively step through the rows of the tabular results. ResultSetMetaData: Interface holds information on the types and properties of the columns in a ResultSet. It is constructed from the Connection object.

16

Chapter 4 4.Source code Login page


import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.*; import java.sql.*; public class login extends JApplet implements ActionListener { JFrame frame = new JFrame("Login"); private JButton login,cancel,signup; private JLabel uname, upass, label; private JTextField name; private JPasswordField pass; int k=0; public String str; public login() { frame.setLayout(null); label = new JLabel("Welcome to Facebook"); uname = new JLabel("Username"); upass = new JLabel("Password"); name = new JTextField();

17

pass = new JPasswordField(); login = new JButton("Login"); cancel = new JButton("Cancel"); signup = new JButton("Signup"); label.setBounds(105, 10, 200, 25); uname.setBounds(50, 40, 140, 25); name.setBounds(150, 40, 160, 25); upass.setBounds(50, 80, 140, 25); pass.setBounds(150, 80, 160, 25); login.setBounds(50, 120, 100, 25); cancel.setBounds(180, 120, 100, 25); signup.setBounds(50, 160, 100, 25); login.addActionListener(this); cancel.addActionListener(this); signup.addActionListener(this); frame.getContentPane().add(label); frame.getContentPane().add(uname); frame.getContentPane().add(upass); frame.getContentPane().add(name); frame.getContentPane().add(pass); frame.getContentPane().add(login); frame.getContentPane().add(cancel); frame.getContentPane().add(signup);

18

frame.setSize(350, 240); frame.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == login) try { // Load the driver class Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // This defines the data source for the driver String sourceURL = new String("Jdbc:Odbc:signup"); // Create connection through the DriverManager Connection databaseConnection = DriverManager.getConnection(sourceURL); Statement statement = databaseConnection.createStatement(); firstname,username, {

ResultSet names = statement.executeQuery("SELECT password FROM upasswd"); // Output the resultset data while(names.next()) {

if(names.getString("username").equals(name.getText()) && names.getString("password").equals(pass.getText())) JOptionPane.showMessageDialog(null,"login sucessfull","SUCCESS",JOptionPane.INFORMATION_MESSAGE); k=1; str=names.getString("firstname"); frame.setVisible(false); {

19

new menu(str); } } if(k==0) { JOptionPane.showMessageDialog(null,"Incorrect Username Or Password","ERROR",JOptionPane.ERROR_MESSAGE); name.setText(""); pass.setText(""); } } catch(ClassNotFoundException cnfe) { System.err.println(cnfe); } catch(SQLException sqle) { System.err.println(sqle); } } if(e.getSource() == cancel) { System.exit(0); } if(e.getSource() == signup) { frame.setVisible(false); new signup(); }

20

} public static void main(String args[]) new login().setVisible(true); } } {

21

Signup page
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class signup extends JApplet implements ActionListener{ JFrame frame = new JFrame("Signup"); JLabel welcome,firstname,lastname,username,password,repassword,emailid; JTextField fname,lname,name,email,zero; JPasswordField pass,repass; JButton check,submit,back; int flag=0,flag1=0,checkcount=0,checkcount1=0,k=0,submitcount=0,submitcount1=0; int std; public signup() { frame.setLocation(450,250); frame.setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); std=0; welcome = new JLabel("Welcome to FaceMash"); firstname = new JLabel("Firstname"); lastname = new JLabel("Lastname"); username = new JLabel("Username");

22

password = new JLabel("Password"); repassword = new JLabel("Re-password"); emailid = new JLabel("Email id"); fname = new JTextField(); lname = new JTextField(); name = new JTextField(); email = new JTextField(); zero = new JTextField(); pass = new JPasswordField(); repass = new JPasswordField(); zero.setText(""+std); submit = new JButton("Submit"); check = new JButton("Check Availability"); back = new JButton("Back"); welcome.setBounds(170,20,200,25); firstname.setBounds(50,60,200,25); lastname.setBounds(50,100,200,25); username.setBounds(50,140,200,25); password.setBounds(50,180,200,25); repassword.setBounds(50,220,200,25); emailid.setBounds(50,260,200,25); fname.setBounds(150,60,200,25); lname.setBounds(150,100,200,25);

23

name.setBounds(150,140,200,25); pass.setBounds(150,180,200,25); repass.setBounds(150,220,200,25); email.setBounds(150,260,250,25); submit.setBounds(150,360,100,25); back.setBounds(300,360,100,25); check.setBounds(360,140,200,25); submit.addActionListener(this); back.addActionListener(this); check.addActionListener(this); frame.getContentPane().add(welcome); frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(username); frame.getContentPane().add(password); frame.getContentPane().add(repassword); frame.getContentPane().add(emailid); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(name); frame.getContentPane().add(pass); frame.getContentPane().add(repass); frame.getContentPane().add(email);

24

frame.getContentPane().add(submit); frame.getContentPane().add(back); frame.getContentPane().add(check); frame.setSize(600,500); frame.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == submit) { submitcount++; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:signup"); Statement statement = con.createStatement(); ResultSet names = statement.executeQuery("select username from upasswd while(names.next()){ if(names.getString("username").equals(name.getText())){ where username='"+name.getText()+"'");

JOptionPane.showMessageDialog(null,"Username already exist !!!! "); fname.setText(""); lname.setText(""); name.setText(""); pass.setText("");

25

repass.setText(""); email.setText(""); flag=1; submitcount1++; } } if(submitcount>submitcount1){ flag=0; } if(fname.getText().equals("") && lname.getText().equals("") && name.getText().equals("") && pass.getText().equals("") && repass.getText().equals("") && email.getText().equals("") && submitcount!=submitcount1){ JOptionPane.showMessageDialog(null,"Fill all the fields "); } else if(flag==0){ if(pass.getText().equals(repass.getText())) { PreparedStatement st = con.prepareStatement("insert into upasswd(firstname,lastname,username,password,repassword,emailid)values(?,?,?,?,?, ?);"); st.setString(1,fname.getText()); st.setString(2,lname.getText()); st.setString(3,name.getText());

26

st.setString(4,pass.getText()); st.setString(5,repass.getText()); st.setString(6,email.getText()); int i = st.executeUpdate(); JOptionPane.showMessageDialog(null,"Data inserted"); fname.setText(""); lname.setText(""); name.setText(""); pass.setText(""); repass.setText(""); email.setText(""); statement.close(); st.close(); con.close(); } else{ JOptionPane.showMessageDialog(null,"Password and Re-password are not same"); pass.setText(""); repass.setText(""); } } }

27

catch(Exception e1){ System.out.println("e1="+e1); } } if(e.getSource() == check){ checkcount++; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con1 = DriverManager.getConnection("Jdbc:Odbc:signup"); Statement statement = con1.createStatement(); ResultSet names = statement.executeQuery("select username from upasswd where username='"+name.getText()+"'"); while(names.next()){

if(names.getString("username").equals(name.getText())){ JOptionPane.showMessageDialog(null,"Unavailable"); flag1=1; checkcount1++; } } if(checkcount>checkcount1){ flag1=0; } if(name.getText().equals("") && checkcount==1){

28

JOptionPane.showMessageDialog(null,"Fill the field first"); new login(); } else if(flag1==0){ JOptionPane.showMessageDialog(null,"Available"); } statement.close(); con1.close(); } catch(Exception e2){ System.out.println("e2="+e2); } } if(e.getSource()==back){ frame.setVisible(false); new login(); } } public static void main(String args[]) { new signup().setVisible(true); } }

29

Menu page
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; public class menu extends JApplet implements ActionListener { JFrame frame = new JFrame("FaceMash"); JTextArea postarea,recieve; JScrollPane scroller; JPanel leftpanel; Font bigfont,shortfont; JLabel label,share,pic,label1; JTextField search,post; JButton name,newsfeed,messages,searchbutton,postbutton,status,accept,cancel; ImageIcon icon; JMenuBar menubar; JMenu homemenu,profilemenu,friendsmenu,accountmenu; JMenuItem accountsettings,logout,editprofile,viewprofile,gohome; int k1=0; public String str1,str2,str3,str4,str8,str20,str30,str35; public menu(String str){ str1=str; str2=str;

30

str4=str; str8=str; str20=str; str30=str; str35=str; frame.setLayout(null); frame.setLocation(0,0); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); leftpanel = new JPanel(); search = new JTextField(); post = new JTextField(); label = new JLabel("News Feed"); label1 = new JLabel("Messages"); share = new JLabel("Share:"); leftpanel.setLayout(null); bigfont = new Font("sanserif",Font.BOLD,30); shortfont = new Font("sanserif",Font.BOLD,20); postarea = new JTextArea(); postarea.setLineWrap(true); postarea.setEditable(false); recieve = new JTextArea("You have a friend request"); recieve.setLineWrap(true); recieve.setEditable(false);

31

scroller = new JScrollPane(postarea); scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR _ALWAYS); scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROL LBAR_NEVER); name = new JButton(str); newsfeed = new JButton("News Feed"); messages = new JButton("Messages"); searchbutton = new JButton("search"); postbutton = new JButton("Post"); status = new JButton("status"); accept = new JButton("Accept"); cancel = new JButton("Cancel"); icon = new ImageIcon("image.gif"); pic = new JLabel(icon); leftpanel.setBackground(Color.red); name.setBackground(Color.red); newsfeed.setBackground(Color.red); messages.setBackground(Color.red); label.setForeground(Color.red); share.setForeground(Color.blue); label1.setForeground(Color.red); recieve.setForeground(Color.blue); leftpanel.setBounds(0,0,200,975);

32

pic.setBounds(20,10,160,190); name.setBounds(40,200,110,25); newsfeed.setBounds(40,230,110,25); messages.setBounds(40,260,110,25); label.setBounds(300,100,800,25); label1.setBounds(300,100,800,35); share.setBounds(220,200,100,35); searchbutton.setBounds(705,5,100,25); postbutton.setBounds(805,230,100,25); status.setBounds(300,200,100,25); search.setBounds(300,5,400,25); post.setBounds(300,230,500,25); scroller.setBounds(300,260,500,200); recieve.setBounds(300,180,400,75); accept.setBounds(450,260,100,25); cancel.setBounds(600,260,100,25); leftpanel.add(pic); leftpanel.add(name); leftpanel.add(newsfeed); leftpanel.add(messages); menubar = new JMenuBar(); homemenu = new JMenu("Home"); homemenu.add(new JSeparator());

33

profilemenu = new JMenu("Profile"); profilemenu.add(new JSeparator()); accountmenu = new JMenu("Account"); accountmenu.add(new JSeparator()); editprofile = new JMenuItem("Edit Profile"); viewprofile = new JMenuItem("View Profile"); gohome = new JMenuItem("Home"); accountsettings = new JMenuItem("Account settings"); logout = new JMenuItem("Logout"); profilemenu.add(editprofile); profilemenu.add(viewprofile); accountmenu.add(accountsettings); accountmenu.add(logout); homemenu.add(gohome); menubar.add(homemenu); menubar.add(profilemenu); menubar.add(accountmenu); label.setFont(bigfont); label1.setFont(bigfont); share.setFont(shortfont); recieve.setFont(shortfont); newsfeed.addActionListener(this); messages.addActionListener(this);

34

postbutton.addActionListener(this); searchbutton.addActionListener(this); status.addActionListener(this); editprofile.addActionListener(this); viewprofile.addActionListener(this); logout.addActionListener(this); accept.addActionListener(this); cancel.addActionListener(this); name.addActionListener(this); accountsettings.addActionListener(this); frame.setJMenuBar(menubar); frame.getContentPane().add(leftpanel); frame.getContentPane().add(label); frame.getContentPane().add(share); frame.getContentPane().add(status); frame.getContentPane().add(search); frame.getContentPane().add(searchbutton); frame.getContentPane().add(post); frame.getContentPane().add(scroller); frame.getContentPane().add(postbutton); frame.setSize(1366,768); frame.setVisible(true); }

35

public void actionPerformed(ActionEvent e) { if(e.getSource() == postbutton) { postarea.append(name.getText()+" says:"+post.getText()); postarea.append("\n"); post.setText(null); } if(e.getSource() == editprofile) { frame.setVisible(false); new profile(str1); } if(e.getSource() == viewprofile) { frame.setVisible(false); new viewprofile(str2); } if(e.getSource()==accept){ frame.setVisible(false); new menu(str30); } if(e.getSource()==cancel){ frame.setVisible(false); new menu(str35); } if(e.getSource()==name){

36

frame.setVisible(false); new viewprofile(str2); } if(e.getSource() == messages) { frame.getContentPane().remove(label); frame.getContentPane().remove(share); frame.getContentPane().remove(status); frame.getContentPane().remove(search); frame.getContentPane().remove(searchbutton); frame.getContentPane().remove(post); frame.getContentPane().remove(postbutton); frame.getContentPane().remove(scroller); frame.getContentPane().add(recieve); frame.getContentPane().add(accept); frame.getContentPane().add(cancel); frame.getContentPane().add(label1); frame.setVisible(false); frame.setVisible(true); } if(e.getSource() == searchbutton) { str3=search.getText(); frame.setVisible(false); new viewprofile1(str3,str4);

37

} if(e.getSource() == accountsettings) { frame.setVisible(false); new setting(str20); } if(e.getSource() == logout) { System.exit(0); } } public static void main(String[] args) { login name1 = new login(); String str = name1.str; new menu(str).setVisible(true); } }

38

Account setting page


import java.awt.*; import javax.swing.*; import java.sql.*; import java.awt.event.*; public class setting extends JApplet implements ActionListener { JFrame frame = new JFrame("Account Setting"); JLabel uname,pass,email,uname1,pass1,email1; JButton b1,b2,b3,save,cancel; JTextField uname2,email2,kd; JPasswordField pass2; public String str22; public setting(String gdk){ str22=gdk; frame.setLayout(null); frame.setLocation(0,0); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); uname= new JLabel("Username"); pass= new JLabel("Password"); email= new JLabel("Email id"); uname1= new JLabel(); pass1= new JLabel(); email1= new JLabel();

39

uname2= new JTextField(); pass2= new JPasswordField(); email2= new JTextField(); kd= new JTextField(); kd.setText(gdk); b1=new JButton("Change"); b2=new JButton("Change"); b3=new JButton("Change"); save=new JButton("Save"); cancel=new JButton("Cancel"); uname.setBounds(100,100,100,25); pass.setBounds(100,200,100,25); email.setBounds(100,300,100,25); uname1.setBounds(300,100,100,25); pass1.setBounds(300,200,100,25); email1.setBounds(300,300,100,25); b1.setBounds(500,100,100,25); b2.setBounds(500,200,100,25); b3.setBounds(500,300,100,25); uname2.setBounds(700,100,200,25); pass2.setBounds(700,200,200,25); email2.setBounds(700,300,200,25); save.setBounds(150,500,100,25);

40

cancel.setBounds(350,500,100,25); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); save.addActionListener(this); cancel.addActionListener(this); frame.getContentPane().add(uname); frame.getContentPane().add(pass); frame.getContentPane().add(email); frame.getContentPane().add(uname1); frame.getContentPane().add(pass1); frame.getContentPane().add(email1); frame.getContentPane().add(b1); frame.getContentPane().add(b2); frame.getContentPane().add(b3); frame.getContentPane().add(save); frame.getContentPane().add(cancel); frame.setSize(1366,768); frame.setVisible(true); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:signup"); Statement st = con.createStatement();

41

ResultSet rs = st.executeQuery("select username,password,emailid from upasswd where firstname='"+kd.getText()+"'"); rs.next(); uname1.setText(rs.getString("username")); pass1.setText(rs.getString("password")); email1.setText(rs.getString("emailid")); rs.close(); st.close(); con.close(); } catch(Exception ex){ System.out.println("ex="+ex); } } public void actionPerformed(ActionEvent e){ if(e.getSource()==b1){ frame.getContentPane().add(uname2); frame.setVisible(false); frame.setVisible(true); } if(e.getSource()==b2){ frame.getContentPane().add(pass2); frame.setVisible(false);

42

frame.setVisible(true); } if(e.getSource()==b3){ frame.getContentPane().add(email2); frame.setVisible(false); frame.setVisible(true); } if(e.getSource()==cancel){ frame.setVisible(false); new menu(str22); } if(e.getSource()==save){ uname1.setText(uname2.getText()); pass1.setText(pass2.getText()); email1.setText(email2.getText()); } } public static void main(String[] args) { login l20 = new login(); String sdk= l20.str; new setting(sdk).setVisible(true); } }

43

Profile page
import java.awt.*; import javax.swing.*; import java.applet.*; import java.awt.event.*; import java.sql.*; public class profile extends JApplet implements ActionListener,ItemListener { JFrame frame = new JFrame("profile"); JPanel leftpanel; JLabel firstname,lastname,emailid,dob,language,religion,sex,pic,label1; JLabel what,passion,book,movie,pview,interest,fashon,drink,smoke; JTextField fname,lname,email,date,lang,reli,jt,in,in1,d,s; JButton name,newsfeed,messages,general,personal,save,cancel,cancel1,back,accept,cancel2; JTextArea recieve; JButton next; Font bigfont,shortfont; JComboBox gender,drinking,smoking; JCheckBox dating,chating,friendship,fashion,fashion1,fashion2,fashion3; ImageIcon icon; JEditorPane whatim,passions,books,movies,political; JScrollPane whatim1,passions1,books1,movies1,political1; JMenuBar menubar;

44

JMenu homemenu,profilemenu,accountmenu; JMenuItem accountsettings,logout,editprofile,viewprofile,gohome; public String str2,str5; public profile(String gd){ frame.setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); leftpanel = new JPanel(); leftpanel.setLayout(null); firstname = new JLabel("Firstname"); lastname = new JLabel("Lastname"); emailid = new JLabel("Email id"); dob = new JLabel("Date of Birth"); language = new JLabel("Language"); religion = new JLabel("Religion"); sex = new JLabel("Gender"); what = new JLabel("what"); passion = new JLabel("passion"); book = new JLabel("book"); movie = new JLabel("movie"); pview = new JLabel("pview"); interest = new JLabel("interest"); fashon = new JLabel("fashon"); drink = new JLabel("drink");

45

smoke = new JLabel("smoke"); label1 = new JLabel("Messages"); fname = new JTextField(); lname = new JTextField(); email = new JTextField(); date = new JTextField(); lang = new JTextField(); reli = new JTextField(); jt = new JTextField(); in = new JTextField(); in1 = new JTextField(); d = new JTextField(); s = new JTextField(); bigfont = new Font("sanserif",Font.BOLD,30); shortfont = new Font("sanserif",Font.BOLD,20); recieve = new JTextArea("You have a friend request"); recieve.setLineWrap(true); recieve.setEditable(false); String b[]= {"no answer","no","socially","ocassionally","regularly","trying to quit"}; drinking = new JComboBox(b); smoking = new JComboBox(b); dating = new JCheckBox("Dating");

46

chating = new JCheckBox("Chating"); friendship = new JCheckBox("Friendship"); fashion = new JCheckBox("Urban(Free Style)"); fashion1 = new JCheckBox("Classic"); fashion2 = new JCheckBox("Alternative"); fashion3 = new JCheckBox("Contemporary"); whatim = new JEditorPane(); whatim1 = new JScrollPane(); passions = new JEditorPane(); passions1 = new JScrollPane(); books = new JEditorPane(); books1 = new JScrollPane(); movies = new JEditorPane(); movies1 = new JScrollPane(); political = new JEditorPane(); political1 = new JScrollPane(); whatim1.setViewportView(whatim); passions1.setViewportView(passions); books1.setViewportView(books); movies1.setViewportView(movies); political1.setViewportView(political); name = new JButton(gd); newsfeed = new JButton("News Feed");

47

messages = new JButton("Messages"); general = new JButton("General"); personal = new JButton("Personal"); next = new JButton("Next"); save = new JButton("Save"); cancel = new JButton("Cancel"); cancel1 = new JButton("Cancel"); accept = new JButton("Accept"); cancel2 = new JButton("Cancel"); back = new JButton("Back"); icon = new ImageIcon("image.gif"); pic = new JLabel(icon); String a[]={"Select","Male","Female"}; gender = new JComboBox(a); leftpanel.setBackground(Color.red); name.setBackground(Color.red); newsfeed.setBackground(Color.red); messages.setBackground(Color.red); recieve.setForeground(Color.blue); label1.setForeground(Color.red); leftpanel.setBounds(0,0,200,995); pic.setBounds(20,10,160,190); name.setBounds(40,200,110,25);

48

newsfeed.setBounds(40,230,110,25); messages.setBounds(40,260,110,25); firstname.setBounds(250,150,300,25); lastname.setBounds(250,180,300,25); emailid.setBounds(250,210,300,25); sex.setBounds(250,240,300,25); what.setBounds(250,50,300,25); passion.setBounds(250,100,300,25); book.setBounds(250,150,300,25); movie.setBounds(250,200,300,25); pview.setBounds(250,250,300,25); interest.setBounds(250,300,300,25); fashon.setBounds(250,350,300,25); drink.setBounds(250,400,300,25); smoke.setBounds(250,450,300,25); whatim1.setBounds(370,50,300,35); passions1.setBounds(370,100,300,35); books1.setBounds(370,150,300,35); movies1.setBounds(370,200,300,35); political1.setBounds(370,250,300,35); dating.setBounds(370,300,100,25); chating.setBounds(470,300,100,25); friendship.setBounds(570,300,100,25);

49

fashion.setBounds(370,350,170,25); fashion1.setBounds(550,350,100,25); fashion2.setBounds(670,350,100,25); fashion3.setBounds(770,350,130,25); drinking.setBounds(370,400,300,25); smoking.setBounds(370,450,300,25); in.setBounds(1000,675,200,25); in1.setBounds(1000,705,200,25); d.setBounds(1000,735,100,25); s.setBounds(1000,765,100,25); dob.setBounds(250,270,300,25); language.setBounds(250,300,300,25); religion.setBounds(250,330,300,25); fname.setBounds(370,150,200,25); lname.setBounds(370,180,200,25); email.setBounds(370,210,300,25); gender.setBounds(370,240,100,25); date.setBounds(370,270,200,25); lang.setBounds(370,300,200,25); reli.setBounds(370,330,200,25); jt.setBounds(1000,240,100,25); general.setBounds(250,100,100,25); personal.setBounds(300,10,100,25);

50

next.setBounds(250,400,100,25); save.setBounds(250,530,100,25); cancel.setBounds(370,400,100,25); cancel1.setBounds(400,530,100,25); back.setBounds(550,530,100,25); recieve.setBounds(300,180,400,75); accept.setBounds(450,260,100,25); cancel2.setBounds(600,260,100,25); label1.setBounds(300,100,800,35); jt.setVisible(false); in.setVisible(false); in1.setVisible(false); d.setVisible(false); s.setVisible(false); leftpanel.add(pic); leftpanel.add(name); leftpanel.add(newsfeed); leftpanel.add(messages); menubar = new JMenuBar(); homemenu = new JMenu("Home"); homemenu.add(new JSeparator()); profilemenu = new JMenu("Profile"); profilemenu.add(new JSeparator());

51

accountmenu = new JMenu("Account"); accountmenu.add(new JSeparator()); editprofile = new JMenuItem("Edit Profile"); viewprofile = new JMenuItem("View Profile"); gohome = new JMenuItem("Home"); accountsettings = new JMenuItem("Account settings"); logout = new JMenuItem("Logout"); profilemenu.add(editprofile); profilemenu.add(viewprofile); accountmenu.add(accountsettings); accountmenu.add(logout); homemenu.add(gohome); menubar.add(homemenu); menubar.add(profilemenu); menubar.add(accountmenu); label1.setFont(bigfont); recieve.setFont(shortfont); next.addActionListener(this); cancel.addActionListener(this); cancel2.addActionListener(this); gender.addItemListener(this); dating.addItemListener(this); chating.addItemListener(this);

52

friendship.addItemListener(this); fashion.addItemListener(this); fashion1.addItemListener(this); editprofile.addActionListener(this); fashion2.addItemListener(this); fashion3.addItemListener(this); drinking.addItemListener(this); smoking.addItemListener(this); personal.addActionListener(this); save.addActionListener(this); back.addActionListener(this); viewprofile.addActionListener(this); newsfeed.addActionListener(this); gohome.addActionListener(this); messages.addActionListener(this); logout.addActionListener(this); frame.setJMenuBar(menubar); frame.getContentPane().add(leftpanel); frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(emailid);

53

frame.getContentPane().add(dob); frame.getContentPane().add(email); frame.getContentPane().add(date); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(sex); frame.getContentPane().add(gender); frame.getContentPane().add(jt); frame.getContentPane().add(general); frame.getContentPane().add(next); frame.getContentPane().add(cancel); frame.setSize(1366,768); frame.setVisible(true); } public void itemStateChanged(ItemEvent ie){ if(ie.getSource() == gender) { if(gender.getSelectedItem().equals("Select")) { jt.setText(""); } else if(gender.getSelectedItem().equals("Male"))

54

{ jt.setText("Male"); } else if(gender.getSelectedItem().equals("Female")) { jt.setText("Female"); } } if(ie.getSource() == dating) { JCheckBox dating = (JCheckBox)ie.getItem(); in.setText(dating.getText()); } if(ie.getSource() == chating) { JCheckBox chating = (JCheckBox)ie.getItem(); in.setText(chating.getText()); } if(ie.getSource() == friendship) { JCheckBox friendship = (JCheckBox)ie.getItem(); in.setText(friendship.getText()); } if(ie.getSource() == fashion) { JCheckBox fashion = (JCheckBox)ie.getItem(); in1.setText(fashion.getText());

55

} if(ie.getSource() == fashion1) { JCheckBox fashion1 = (JCheckBox)ie.getItem(); in1.setText(fashion1.getText()); } if(ie.getSource() == fashion2) { JCheckBox fashion2 = (JCheckBox)ie.getItem(); in1.setText(fashion2.getText()); } if(ie.getSource() == fashion3) { JCheckBox fashion3 = (JCheckBox)ie.getItem(); in1.setText(fashion3.getText()); } if(ie.getSource() == drinking) { if(drinking.getSelectedItem().equals("no answer")) { d.setText(""); } else if(drinking.getSelectedItem().equals("no")) { d.setText("no"); } else if(drinking.getSelectedItem().equals("socially"))

56

{ d.setText("socially"); } else if(drinking.getSelectedItem().equals("occasionally")) { d.setText("ocassionally"); } else if(drinking.getSelectedItem().equals("regularly")) { d.setText("regularly"); } else if(drinking.getSelectedItem().equals("trying to quit")) { d.setText("trying to quit"); } } if(ie.getSource() == smoking) { if(smoking.getSelectedItem().equals("no answer")) { s.setText(""); } else if(smoking.getSelectedItem().equals("no")) {

57

s.setText("no"); } else if(smoking.getSelectedItem().equals("socially")) { s.setText("socially"); } else if(smoking.getSelectedItem().equals("occasionally")) { s.setText("ocassionally"); } else if(smoking.getSelectedItem().equals("regularly")) { s.setText("regularly"); } else if(smoking.getSelectedItem().equals("trying to quit")) { s.setText("trying to quit"); } } } public void actionPerformed(ActionEvent e){ if(e.getSource() == save){ try{

58

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:profile"); PreparedStatement st = con.prepareStatement("insert into user(firstname,lastname,emailid,gender,dob,language,religion,whatim,passions,books, movies,politicalview,interested,fashion,drinking,smoking) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"); st.setString(1,fname.getText()); st.setString(2,lname.getText()); st.setString(3,email.getText()); st.setString(4,jt.getText()); st.setString(5,date.getText()); st.setString(6,lang.getText()); st.setString(7,reli.getText()); st.setString(8,whatim.getText()); st.setString(9,passions.getText()); st.setString(10,books.getText()); st.setString(11,movies.getText()); st.setString(12,political.getText()); st.setString(13,in.getText()); st.setString(14,in1.getText()); st.setString(15,d.getText()); st.setString(16,s.getText()); name.setText(fname.getText());

59

int i = st.executeUpdate(); JOptionPane.showMessageDialog(null,"Data inserted successfully"); st.close(); con.close(); } catch(Exception e1){ System.out.println(e1); } } if(e.getSource() == messages) { frame.getContentPane().remove(firstname); frame.getContentPane().remove(lastname); frame.getContentPane().remove(emailid); frame.getContentPane().remove(dob); frame.getContentPane().remove(language); frame.getContentPane().remove(religion); frame.getContentPane().remove(sex); frame.getContentPane().remove(fname); frame.getContentPane().remove(lname); frame.getContentPane().remove(email); frame.getContentPane().remove(date);

60

frame.getContentPane().remove(lang); frame.getContentPane().remove(reli); frame.getContentPane().remove(jt); frame.getContentPane().remove(gender); frame.getContentPane().remove(next); frame.getContentPane().remove(cancel); frame.getContentPane().remove(general); frame.getContentPane().add(recieve); frame.getContentPane().add(accept); frame.getContentPane().add(cancel2); frame.getContentPane().add(label1); frame.setVisible(false); frame.setVisible(true); } if(e.getSource() == cancel2) { frame.getContentPane().remove(recieve); frame.getContentPane().remove(accept); frame.getContentPane().remove(cancel2); frame.getContentPane().remove(label1);

frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid);

61

frame.getContentPane().add(dob); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(sex); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(date); frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(jt); frame.getContentPane().add(gender); frame.getContentPane().add(next); frame.getContentPane().add(cancel); frame.getContentPane().add(general); frame.setVisible(false); frame.setVisible(true); } if(e.getSource()==next){ frame.getContentPane().remove(firstname); frame.getContentPane().remove(lastname); frame.getContentPane().remove(emailid); frame.getContentPane().remove(dob);

62

frame.getContentPane().remove(language); frame.getContentPane().remove(religion); frame.getContentPane().remove(sex); frame.getContentPane().remove(fname); frame.getContentPane().remove(lname); frame.getContentPane().remove(email); frame.getContentPane().remove(date); frame.getContentPane().remove(lang); frame.getContentPane().remove(reli); frame.getContentPane().remove(jt); frame.getContentPane().remove(gender); frame.getContentPane().remove(next); frame.getContentPane().remove(cancel); frame.getContentPane().remove(general); frame.getContentPane().add(what); frame.getContentPane().add(passion); frame.getContentPane().add(book); frame.getContentPane().add(movie); frame.getContentPane().add(pview); frame.getContentPane().add(interest); frame.getContentPane().add(fashon); frame.getContentPane().add(drink); frame.getContentPane().add(smoke);

63

frame.getContentPane().add(whatim1); frame.getContentPane().add(passions1); frame.getContentPane().add(books1); frame.getContentPane().add(movies1); frame.getContentPane().add(political1); frame.getContentPane().add(dating); frame.getContentPane().add(chating); frame.getContentPane().add(friendship); frame.getContentPane().add(fashion); frame.getContentPane().add(fashion1); frame.getContentPane().add(fashion2); frame.getContentPane().add(fashion3); frame.getContentPane().add(drinking); frame.getContentPane().add(smoking); frame.getContentPane().add(in); frame.getContentPane().add(in1); frame.getContentPane().add(d); frame.getContentPane().add(s); frame.getContentPane().add(save); frame.getContentPane().add(cancel1); frame.getContentPane().add(back); frame.getContentPane().add(personal); frame.setVisible(false);

64

frame.setVisible(true); } if(e.getSource()==back){ frame.getContentPane().remove(what); frame.getContentPane().remove(passion); frame.getContentPane().remove(book); frame.getContentPane().remove(movie); frame.getContentPane().remove(pview); frame.getContentPane().remove(interest); frame.getContentPane().remove(fashon); frame.getContentPane().remove(drink); frame.getContentPane().remove(smoke); frame.getContentPane().remove(whatim1); frame.getContentPane().remove(passions1); frame.getContentPane().remove(books1); frame.getContentPane().remove(movies1); frame.getContentPane().remove(political1); frame.getContentPane().remove(dating); frame.getContentPane().remove(chating); frame.getContentPane().remove(friendship); frame.getContentPane().remove(fashion); frame.getContentPane().remove(fashion1); frame.getContentPane().remove(fashion2);

65

frame.getContentPane().remove(fashion3); frame.getContentPane().remove(drinking); frame.getContentPane().remove(smoking); frame.getContentPane().remove(in); frame.getContentPane().remove(in1); frame.getContentPane().remove(d); frame.getContentPane().remove(s); frame.getContentPane().remove(save); frame.getContentPane().remove(cancel1); frame.getContentPane().remove(back); frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid); frame.getContentPane().add(dob); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(sex); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(date); frame.getContentPane().add(lang); frame.getContentPane().add(reli);

66

frame.getContentPane().add(jt); frame.getContentPane().add(gender); frame.getContentPane().add(next); frame.getContentPane().add(cancel); frame.setVisible(false); frame.setVisible(true); } if(e.getSource() == viewprofile){ frame.setVisible(false); new viewprofile(str2); } if(e.getSource() == newsfeed){ str5= fname.getText(); frame.setVisible(false); new menu(str5); } if(e.getSource() == gohome){ str5= fname.getText(); frame.setVisible(false); new menu(str5); } if(e.getSource() == logout) { System.exit(0);

67

} if(e.getSource() == cancel){ new menu(str5); } } public static void main(String[] args) { login l = new login(); String s1= l.str; new profile(s1).setVisible(true); } }

68

View profile page


import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; import java.sql.*; public class viewprofile extends JApplet implements ActionListener { JFrame frame = new JFrame("View profile"); JPanel leftpanel; ImageIcon icon; Font bigfont,shortfont; JTextArea sendrequest,recieve; JLabel firstname,lastname,emailid,dob,language,religion,sex,pic,label,label1; JLabel what,passion,book,movie,pview,interest,fashon,drink,smoke; JTextField fname,lname,email,date,lang,reli,gender,interest1,fashon1,drink1,smoke1; JButton name,newsfeed,messages,next,back,yes,no,accept,cancel; JEditorPane whatim,passions,books,movies,political; JScrollPane whatim1,passions1,books1,movies1,political1; JMenuBar menubar; JMenu homemenu,profilemenu,accountmenu; JMenuItem accountsettings,logout,editprofile,viewprofile,gohome; public String str,str1,str4;

69

public viewprofile(String gd1) { frame.setLayout(null); frame.setLocation(0,0); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); leftpanel = new JPanel(); leftpanel.setLayout(null); firstname = new JLabel("Firstname"); lastname = new JLabel("Lastname"); emailid = new JLabel("Email id"); dob = new JLabel("Date of Birth"); language = new JLabel("Language"); religion = new JLabel("Religion"); sex = new JLabel("Gender"); what = new JLabel("About me"); passion = new JLabel("Passions"); book = new JLabel("Books"); movie = new JLabel("Movies"); pview = new JLabel("Political view"); interest = new JLabel("Interested in"); fashon = new JLabel("Fashion"); drink = new JLabel("Drinking"); smoke = new JLabel("Smoking"); label = new JLabel("Add as Friend");

70

label1 = new JLabel("Messages"); bigfont = new Font("sanserif",Font.BOLD,30); shortfont = new Font("sanserif",Font.BOLD,20); sendrequest = new JTextArea("Do you want to send a friend request?"); sendrequest.setLineWrap(true); sendrequest.setEditable(false); recieve = new JTextArea("You have a friend request"); recieve.setLineWrap(true); recieve.setEditable(false); fname = new JTextField(); lname = new JTextField(); email = new JTextField(); date = new JTextField(); gender = new JTextField(); lang = new JTextField(); reli = new JTextField(); interest1 = new JTextField(); fashon1 = new JTextField(); drink1 = new JTextField(); smoke1 = new JTextField(); name = new JButton(gd1); newsfeed = new JButton("News Feed"); messages = new JButton("Messages");

71

next = new JButton("Next"); accept = new JButton("Accept"); cancel = new JButton("Cancel"); back=new JButton("Back"); yes=new JButton("Yes"); no=new JButton("No"); icon = new ImageIcon("image.gif"); pic = new JLabel(icon); whatim = new JEditorPane(); whatim1 = new JScrollPane(); passions = new JEditorPane(); passions1 = new JScrollPane(); books = new JEditorPane(); books1 = new JScrollPane(); movies = new JEditorPane(); movies1 = new JScrollPane(); political = new JEditorPane(); political1 = new JScrollPane(); whatim1.setViewportView(whatim); passions1.setViewportView(passions); books1.setViewportView(books); movies1.setViewportView(movies); political1.setViewportView(political);

72

leftpanel.setBounds(0,0,200,995); pic.setBounds(20,10,160,190); name.setBounds(40,200,110,25); newsfeed.setBounds(40,230,110,25); messages.setBounds(40,260,110,25); firstname.setBounds(250,150,300,25); lastname.setBounds(250,180,300,25); emailid.setBounds(250,210,300,25); sex.setBounds(250,240,300,25); dob.setBounds(250,270,300,25); language.setBounds(250,300,300,25); religion.setBounds(250,330,300,25); what.setBounds(250,30,300,25); passion.setBounds(250,80,300,25); book.setBounds(250,130,300,25); movie.setBounds(250,180,300,25); pview.setBounds(250,230,300,25); interest.setBounds(250,280,300,25); fashon.setBounds(250,330,300,25); drink.setBounds(250,380,300,25); smoke.setBounds(250,430,300,25); fname.setBounds(370,150,200,25); lname.setBounds(370,180,200,25);

73

email.setBounds(370,210,300,25); gender.setBounds(370,240,200,25); date.setBounds(370,270,200,25); lang.setBounds(370,300,200,25); reli.setBounds(370,330,200,25); whatim1.setBounds(370,30,300,25); passions1.setBounds(370,80,300,25); books1.setBounds(370,130,300,25); movies1.setBounds(370,180,300,25); political1.setBounds(370,230,300,25); interest1.setBounds(370,280,300,25); fashon1.setBounds(370,330,300,25); drink1.setBounds(370,380,300,25); smoke1.setBounds(370,430,300,25); next.setBounds(250,400,100,25); back.setBounds(300,530,100,25); label.setBounds(300,100,800,25); sendrequest.setBounds(300,150,400,75); yes.setBounds(450,230,100,25); no.setBounds(600,230,100,25); accept.setBounds(450,260,100,25); cancel.setBounds(600,260,100,25); recieve.setBounds(300,180,400,75);

74

label1.setBounds(300,100,800,35); leftpanel.setBackground(Color.red); name.setBackground(Color.red); newsfeed.setBackground(Color.red); messages.setBackground(Color.red); label.setForeground(Color.red); sendrequest.setForeground(Color.blue); label1.setForeground(Color.red); whatim.setEditable(false); passions.setEditable(false); books.setEditable(false); movies.setEditable(false); political.setEditable(false); interest1.setEditable(false); fashon1.setEditable(false); drink1.setEditable(false); smoke1.setEditable(false); fname.setEditable(false); lname.setEditable(false); email.setEditable(false); date.setEditable(false); gender.setEditable(false); lang.setEditable(false);

75

reli.setEditable(false); leftpanel.add(pic); leftpanel.add(name); leftpanel.add(newsfeed); leftpanel.add(messages); menubar = new JMenuBar(); homemenu = new JMenu("Home"); homemenu.add(new JSeparator()); profilemenu = new JMenu("Profile"); profilemenu.add(new JSeparator()); accountmenu = new JMenu("Account"); accountmenu.add(new JSeparator()); editprofile = new JMenuItem("Edit Profile"); viewprofile = new JMenuItem("View Profile"); gohome = new JMenuItem("Home"); accountsettings = new JMenuItem("Account settings"); logout = new JMenuItem("Logout"); profilemenu.add(editprofile); profilemenu.add(viewprofile); accountmenu.add(accountsettings); accountmenu.add(logout); homemenu.add(gohome); label.setFont(bigfont);

76

sendrequest.setFont(shortfont); label1.setFont(bigfont); recieve.setFont(shortfont); menubar.add(homemenu); menubar.add(profilemenu); menubar.add(accountmenu); next.addActionListener(this); back.addActionListener(this); editprofile.addActionListener(this); accountsettings.addActionListener(this); logout.addActionListener(this); no.addActionListener(this); newsfeed.addActionListener(this); gohome.addActionListener(this); messages.addActionListener(this); cancel.addActionListener(this); logout.addActionListener(this); frame.setJMenuBar(menubar); frame.getContentPane().add(leftpanel); frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid); frame.getContentPane().add(dob);

77

frame.getContentPane().add(sex); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(date); frame.getContentPane().add(gender); frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(next); frame.setSize(1366,768); frame.setVisible(true); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:profile"); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("select firstname,lastname,emailid,gender,dob,language,religion from user where firstname='"+name.getText()+"'"); rs.next(); fname.setText(rs.getString("firstname")); lname.setText(rs.getString("lastname"));

78

email.setText(rs.getString("emailid")); gender.setText(rs.getString("gender")); date.setText(rs.getString("dob")); lang.setText(rs.getString("language")); reli.setText(rs.getString("religion")); name.setText(fname.getText()); rs.close(); st.close(); con.close(); } catch(Exception ex){ System.out.println("ex="+ex); } } public void actionPerformed(ActionEvent e){ if(e.getSource() == next){ frame.getContentPane().remove(firstname); frame.getContentPane().remove(lastname); frame.getContentPane().remove(emailid); frame.getContentPane().remove(dob); frame.getContentPane().remove(language); frame.getContentPane().remove(religion); frame.getContentPane().remove(sex);

79

frame.getContentPane().remove(fname); frame.getContentPane().remove(lname); frame.getContentPane().remove(email); frame.getContentPane().remove(date); frame.getContentPane().remove(lang); frame.getContentPane().remove(reli); frame.getContentPane().remove(gender); frame.getContentPane().remove(next); frame.getContentPane().add(what); frame.getContentPane().add(passion); frame.getContentPane().add(book); frame.getContentPane().add(movie); frame.getContentPane().add(pview); frame.getContentPane().add(interest); frame.getContentPane().add(fashon); frame.getContentPane().add(drink); frame.getContentPane().add(smoke); frame.getContentPane().add(whatim1); frame.getContentPane().add(passions1); frame.getContentPane().add(books1); frame.getContentPane().add(movies1); frame.getContentPane().add(political1); frame.getContentPane().add(interest1);

80

frame.getContentPane().add(fashon1); frame.getContentPane().add(drink1); frame.getContentPane().add(smoke1); frame.getContentPane().add(back); frame.setVisible(false); frame.setVisible(true); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:profile"); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("select whatim,passions,books,movies,politicalview,interested,fashion,drinking,smoking from user where firstname='"+name.getText()+"'"); rs.next(); whatim.setText(rs.getString("whatim")); passions.setText(rs.getString("passions")); books.setText(rs.getString("books")); movies.setText(rs.getString("movies")); political.setText(rs.getString("politicalview")); interest1.setText(rs.getString("interested")); fashon1.setText(rs.getString("fashion")); drink1.setText(rs.getString("drinking")); smoke1.setText(rs.getString("smoking"));

81

rs.close(); st.close(); con.close(); } catch(Exception ex1){ System.out.println("ex="+ex1); } } if(e.getSource() == messages) { frame.getContentPane().remove(firstname); frame.getContentPane().remove(lastname); frame.getContentPane().remove(emailid); frame.getContentPane().remove(dob); frame.getContentPane().remove(language); frame.getContentPane().remove(religion); frame.getContentPane().remove(sex); frame.getContentPane().remove(fname); frame.getContentPane().remove(lname); frame.getContentPane().remove(email); frame.getContentPane().remove(date); frame.getContentPane().remove(lang); frame.getContentPane().remove(reli); frame.getContentPane().remove(gender);

82

frame.getContentPane().remove(next); frame.getContentPane().remove(cancel);

frame.getContentPane().remove(what); frame.getContentPane().remove(passion); frame.getContentPane().remove(book); frame.getContentPane().remove(movie); frame.getContentPane().remove(pview); frame.getContentPane().remove(interest); frame.getContentPane().remove(fashon); frame.getContentPane().remove(drink); frame.getContentPane().remove(smoke); frame.getContentPane().remove(whatim1); frame.getContentPane().remove(passions1); frame.getContentPane().remove(books1); frame.getContentPane().remove(movies1); frame.getContentPane().remove(political1); frame.getContentPane().remove(interest1); frame.getContentPane().remove(fashon1); frame.getContentPane().remove(drink1); frame.getContentPane().remove(smoke1); frame.getContentPane().remove(back); frame.getContentPane().add(recieve);

83

frame.getContentPane().add(accept); frame.getContentPane().add(cancel); frame.getContentPane().add(label1); frame.setVisible(false); frame.setVisible(true); } if(e.getSource() == cancel) { frame.getContentPane().remove(recieve); frame.getContentPane().remove(accept); frame.getContentPane().remove(cancel); frame.getContentPane().remove(label1);

frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid); frame.getContentPane().add(dob); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(sex); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(date);

84

frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(gender); frame.getContentPane().add(next); frame.setVisible(false); frame.setVisible(true); } if(e.getSource()==back){ frame.getContentPane().remove(what); frame.getContentPane().remove(passion); frame.getContentPane().remove(book); frame.getContentPane().remove(movie); frame.getContentPane().remove(pview); frame.getContentPane().remove(interest); frame.getContentPane().remove(fashon); frame.getContentPane().remove(drink); frame.getContentPane().remove(smoke); frame.getContentPane().remove(whatim1); frame.getContentPane().remove(passions1); frame.getContentPane().remove(books1); frame.getContentPane().remove(movies1); frame.getContentPane().remove(political1); frame.getContentPane().remove(interest1);

85

frame.getContentPane().remove(fashon1); frame.getContentPane().remove(drink1); frame.getContentPane().remove(smoke1); frame.getContentPane().remove(back);

frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid); frame.getContentPane().add(dob); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(sex); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(date); frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(gender); frame.getContentPane().add(next); frame.setVisible(false); frame.setVisible(true); try{

86

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:profile"); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("select firstname,lastname,emailid,gender,dob,language,religion from user where firstname='"+name.getText()+"'"); rs.next(); fname.setText(rs.getString("firstname")); lname.setText(rs.getString("lastname")); email.setText(rs.getString("emailid")); gender.setText(rs.getString("gender")); date.setText(rs.getString("dob")); lang.setText(rs.getString("language")); reli.setText(rs.getString("religion")); rs.close(); st.close(); con.close(); } catch(Exception ex2){ System.out.println("ex="+ex2); } } if(e.getSource()==editprofile){

87

frame.setVisible(false); new profile(str1); } if(e.getSource()==no){ frame.getContentPane().remove(sendrequest); frame.getContentPane().remove(label); frame.getContentPane().remove(yes); frame.getContentPane().remove(no); frame.getContentPane().add(firstname); frame.getContentPane().add(lastname); frame.getContentPane().add(emailid); frame.getContentPane().add(gender); frame.getContentPane().add(dob); frame.getContentPane().add(language); frame.getContentPane().add(religion); frame.getContentPane().add(fname); frame.getContentPane().add(lname); frame.getContentPane().add(email); frame.getContentPane().add(sex); frame.getContentPane().add(date); frame.getContentPane().add(lang); frame.getContentPane().add(reli); frame.getContentPane().add(next);

88

frame.setVisible(false); frame.setVisible(true); } if(e.getSource()== newsfeed){ str4=fname.getText(); frame.setVisible(false); new menu(str4); } if(e.getSource()== gohome){ str4=fname.getText(); frame.setVisible(false); new menu(str4); } if(e.getSource() == logout) { System.exit(0); } } public static void main(String[] args) { login l1 = new login(); String s2=l1.str; new viewprofile(s2).setVisible(true); } }

89

Chapter 5 Output
Login window

Figure 5.1 Menu window

Figure 5.2

90

View profile window

Figure 5.3 Account setting window

Figure 5.4

91

Edit profile window

Figure 5.5

Database
Profile Table

Figure 5.6

92

Chapter 6 Security measures


All information and data of the user are stored within the system, and access to this sensitive information is controlled through an effective authentication system: one has to know the username and the password of the user. So, the system is password protected system. So, the system is secure for unauthorized user. The user can create new account and give the password for the account. This system will provide the facility to set the password by user itself. When user create a data than system provide the facility to user to check the username is available or not.

93

Chapter 7 Advantages & Limitations


7.1 Advantages 1. Any field can be added & updated to & from the database. 2. Storing large amount of data for future point of view. 3. Reducing manual efforts for maintaining the system.Reducing the lead time. 4. It gives correct information about the user. 7.2 Limitation There are some limitations of this software which must be deal in regard of documentation. However, I have tried my best till last moment to overcome these limitations to a great extent. I wish the other may be solved in future during post implementation and correction. It has following drawbacks: 1. It requires high system configuration. 2. There is no built in interface in this software for internet. That is no option for internet achievement. 3.The project My facebook clone is dedicated for a good management. However I have tried of my best to full-fill the requirement of users of this project but my project too has some limitations: A) This is used not for Client-server network. It cannot be used on Internet (web application). B) All facilities in this system depend on key-attribute, missing of key attribute may cause lose of data.

94

Chapter 8 Scope and future enhancement


This project is made in such a way that it can be easily modified in a more advanced form if there will be such need. The database of this software maintains the records of the details of the each user. Thus, this record will have a lot of use in future related to any enquiry. The updation are also revealed in this project. In future we add the chatting option in this site. Than the each user interact with each other through the LAN or the Internet. In the future we add the option of image upload system. Then the user can also the upload the image in his accont. So, in the future we can create a social networking site through which the user can interact to each other.

95

Chapter 9 Conclusion
The project My facebook clone is very easy to develop and its implementation and working is very simple. The software itself is very user friendly and light weight. It can be used to keep record of the user very easily and helps reduce the time and effort of the system administrator and at the same time without committing any error.

96

Chapter 10 Bibliography & References


10.1 Books & Study material: Study material supplied by CMC Book of core java by E. Balaguruswami Book of java by Khalid Mughal Complete reference of java

10.2 Site visited: wikkipedia google roseindia

97