Project Report on

Intranet MAILING SYSTEM
Submitted in partial fulfillment of the requirements for the award of

DIPLOMA IN J2EE PROGRAMMING

Submitted by VIGNESHWARAN. R.

Under the guidance of Miss. R. Kalaiyarasi Faculty/CSC Computer Education

CSC COMPUTER EDUCATION SIMMAKKAL MADURAI – 625001.

1|Page

CSC COMPUTER EDUCATION SIMMAKKAL MADURAI – 625001.

CERTIFICATE
This is to certify that this project entitled “Intranet Mailing System” using Java is the Bonafide Record of work done by VIGNESHWARAN. R. in partial fulfillment of the requirements for the award of DIPLOMA IN J2EE PROGRAMMING.

INTERNAL GUIDE

EXTERNAL GUIDE

BRANCH MANAGER

PLACE: MADURAI DATE:

2|Page

ACKNOWLEDGEMENT
“I have to Thank God Almighty For all his benevolence”. I extend my deep sense of gratitude to all people who have guided, inspired and motivated me during this project.

I express my sincere praise and thanks to Lord Almighty for his blessings showered on me throughout my life, especially for this project work.

I am very thankful to Mr.V.RAMA KRISHNAN, our center in charge for his kind help towards the Completion of Our work.

I take this opportunity and immense pleasure in expressing my deep sense of gratitude to Miss.R.KALAIYARASI, faculty of CSC COMPUTER EDUCATION SIMMAKKAL, ideas under whose innovate, hope and encourage of this project work.

I thank my parents for their constant source of encouragement and cheer all long in achieving my goal.

Finally, I thank all of them who directly and indirectly helped in bringing this project as a successful one and extend my thanks to all my CSC COMPUTER EDUCATION staffs and friends, whose timely help, while working on project.

3|Page

Declaration
I here by declare that this project entitled “Intranet Mailing System” submitted by me to the “CSC COMPUTER EDUCATION” for the course of Diploma in J2EE Programming is an original and independent work carried out by me under the guidance of Miss.R.Kalaiyarasi, Faculty of CSC.

Submitted by VIGNESHWARAN. R.

4|Page

INDEX
S.NO 1. 2. 3. 4. 5. 6. 8. 9. 10. 11. CONTENT SYNOPSIS SYSTEM CONFIGURATION JAVA SWING MS-ACCESS DATA STRUCTURES SOURCE CODE SCREEN LAYOUTS CONCLUSION BIBLIOGRAPHY

5|Page

SYNOPSIS
Present System: Presenting Intranet Mailing System is manually providing services to employees of departments of an Organization. Employees have to go departments to know some particular information. Sometimes information is passed by manually between departments. This manual system will take time to pass the information and sometimes it causes lost of information also. This causes lost of employee time also. Need for new System: Nowadays the organizations are growing fast and are increasing in size also. So the organizations are divided into departments. In the fast growing world the information is needed as fast as possible. This can be accomplished by passing the information quickly. Quick passing of mails is not possible in load manual systems because in manual systems the mails are passed through persons from one department to another. It takes mush time and risk also. This leads the inconsistency of information. So we need a system which is both quick and accurate. This can be achieved by this project. The main aim of this project is to send the mails spontaneously without requiring the parties be available at the same instant. It is much cheaper than the manual system. Advantages with the proposed system: The main advantage of the Intra mail system is its security feature allowing only registered users to access the system and preventing any hackers, unauthorized users. Another interesting feature is the notifying feature which displays a popup alert to notify the users of new messages for 5seconds before disappearing. It also has an address book and newsreader.

6|Page

Modules Involved: Registration – In this module a new user can register his / her details for accessing this product. Once they registered or if they already have an id and password, they can enter through the login portal and can access the application. New Users details stored in a database and the existing details obtained from the same for checking at the time of login. The user details are automatically added to the admin’s address book during the registration itself. Menu Window – This module welcomes the user and provides the options for accessing other modules. This module displays a popup at the lower right corner of the screen if there are any new messages for the user waiting to be read. Once the work is finished, the user can choose to either exit or just logout from the application for the other users to use, in case. Mail Editor – This is the most primary module of the application. It is used to send and receive mails. It has a separate window for inbox and composing window. In the inbox pane, the list of received messages is displayed in a list and the user can view the full message, subject and time of message by clicking the sender name in the list. The user can also reply to the sender which automatically fills in the subject and recipient address in the composing window. In the composing window, the user can view his address book to refer the recipient’s mail address. News Editor – This module is only accessible to the admin. It provides the options for the admin to add news and events common to all the End Users. News Reader – This module is available to all the users except the admin. It displays the news and upcoming events common to all other End Users sent by the admin. Address Book – For easy user reference, the other’s personal details and email addresses can be stored in a database using this application. Whenever user need, he / she can retrieve the details from the address book. The EndUser can only view the addresses he added in the address book where admin can view all.

7|Page

SYSTEM CONFIGURATION
Hardware specification:
Processor RAM CPU Speed Hard Disk Monitor Keyboard Floppy Drive Cache Memory Pointing Device : : : : : : : : : Pentium IV 256MB 2.80GHz 40GB 17” 1024x768 104keys 1.44MB, 3.4inch 64KB Mouse (2 Buttons or more)

Software specification:
Front end Back end Operating System JRE : : : : Java Swing MS-Access 2007 Cross-platform version 6 update 15 (1.6.0_15)

8|Page

JAVA
Introduction
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.

History
James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects. Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation. Sun released the first public implementation as Java 1.0 in 1995. It promised "Write Once, Run Anywhere" (WORA), providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular.

Principles
There were five primary goals in the creation of the Java language: 1. It should be "simple, object oriented and familiar". 2. It should be "robust and secure". 3. It should be "architecture neutral and portable". 4. It should execute with "high performance". 5. It should be "interpreted, threaded, and dynamic".
9|Page

Java Platform
One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any supported hardware/operating-system platform. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to platform-specific machine code. Java bytecode instructions are analogous to machine code, but are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a Web browser for Java applets.

Automatic memory management
Java uses an automatic garbage collector to manage memory in the object lifecycle. The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use. Once no references to an object remain, the unreachable memory becomes eligible to be freed automatically by the garbage collector. One of the ideas behind Java's automatic memory management model is that programmers be spared the burden of having to perform manual memory management.

Syntax
The syntax of Java is largely derived from C++. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object oriented language. All code is written inside a class and everything is an object, with the exception of the intrinsic data types (ordinal and real numbers, boolean values, and characters), which are not classes for performance reasons. Java uses the same commenting methods as C++. There are two different styles of comment: a single line style marked with two forward slashes, and a multiple line style opened with a forward slash asterisk (/*) and closed with an asterisk forward slash (*/).

10 | P a g e

SWING
Introduction
Swing is a widget toolkit for Java. It is part of Sun Microsystems' Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs. Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit. Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform.

History
The Internet Foundation Classes (IFC) were a graphics library for Java originally developed by Netscape Communications Corporation and first released on December 16, 1996. On April 2, 1997, Sun Microsystems and Netscape Communications Corporation announced their intention to incorporate IFC with other technologies to form the Java Foundation Classes. Swing introduced a mechanism that allowed the look and feel of every component in an application to be altered without making substantial changes to the application code. The introduction of support for a pluggable look and feel allows Swing components to emulate the appearance of native components while still retaining the benefits of platform independence. This feature also makes it easy to make an application written in Swing look very different from native programs if desired. Originally distributed as a separately downloadable library, Swing has been included as part of the Java Standard Edition since release 1.2. The Swing classes and components are contained in the javax.swing package hierarchy.

11 | P a g e

Architecture
Swing is a platform-independent, Model-View-Controller GUI framework for Java. It follows a single-threaded programming model, and possesses the following traits:

Foundations
Platform independence Swing is platform independent both in terms of its expression (Java) and its implementation (non-native universal rendering of widgets). Extensibility Swing is a highly partitioned architecture, which allows for the "plugging" of various custom implementations of specified framework interfaces: Users can provide their own custom implementation(s) of these components to override the default implementations. In general, Swing users can extend the framework by extending existing (framework) classes and/or providing alternative implementations of core components. Component-oriented Swing is a component-based framework. The distinction between objects and components is a fairly subtle point: concisely, a component is a well-behaved object with a known/specified characteristic pattern of behaviour. Swing objects asynchronously fire events, have "bound" properties, and respond to a wellknown set of commands (specific to the component.) Specifically, Swing components are Java Beans components, compliant with the Java Beans Component Architecture specifications. Customizable Given the programmatic rendering model of the Swing framework, fine control over the details of rendering of a component is possible in Swing. As a general pattern, the visual representation of a Swing component is a composition
12 | P a g e

of a standard set of elements, such as a "border", "inset", decorations, etc. Typically, users will programmatically customize a standard Swing component (such as a JTable) by assigning specific Borders, Colors, Backgrounds, opacities, etc., as the properties of that component. The core component will then use these property (settings) to determine the appropriate renderers to use in painting its various aspects. However, it is also completely possible to create unique GUI controls with highly customized visual representation. Configurable Swing's heavy reliance on runtime mechanisms and indirect composition patterns allows it to respond at runtime to fundamental changes in its settings. For example, a Swing-based application can change its look and feel at runtime. Further, users can provide their own look and feel implementation, which allows for uniform changes in the look and feel of existing Swing applications without any programmatic change to the application code. Lightweight UI Swing's configurability is a result of a choice not to use the native host OS's GUI controls for displaying itself. Swing "paints" its controls programmatically through the use of Java 2D APIs, rather than calling into a native user interface toolkit. Thus, a Swing component does not have a corresponding native OS GUI component, and is free to render itself in any way that is possible with the underlying graphics APIs. Look and feel Swing allows one to specialize the look and feel of widgets, by modifying the default (via runtime parameters), deriving from an existing one, by creating one from scratch, or, beginning with J2SE 5.0, by using the skinnable synth Look and Feel, which is configured with an XML property file. The look and feel can be changed at runtime, and early demonstrations of Swing frequently provided a way to do this.

13 | P a g e

MS – ACCESS
Introduction
Microsoft Office Access, previously known as Microsoft Access, is a relational database management system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software development tools. It is a member of the Microsoft Office suite of applications and is included in the Professional and higher versions for Windows and also sold separately. Access stores data in its own format based on the Access Jet Database Engine. It can also import or link directly to data stored in other Access databases, Excel, SharePoint lists, text, XML, Outlook, HTML, dBase, Paradox, Lotus 1-2-3, or any ODBC-compliant data container including Microsoft SQL Server, Oracle, MySQL and PostgreSQL. Software developers and data architects can use it to develop application software and non-programmer "power users" can use it to build simple applications.

Features
Users can create tables, queries, forms and reports, and connect them together with macros. The original concept of Access was for end users to be able to “access” data from any source. Other uses include: the import and export of data to many formats including Excel, Outlook, ASCII, dBase, Paradox, FoxPro, SQL Server, Oracle, ODBC, etc. It also has the ability to link to data in its existing location and use it for viewing, querying, editing, and reporting. This allows the existing data to change and the Access platform to always use the latest data. It can perform heterogeneous joins between data sets stored across different platforms. Access is often used by people downloading data from enterprise level databases for manipulation, analysis, and reporting locally.

14 | P a g e

There is also the Jet Database format (MDB or ACCDB in Access 2007) which can contain the application and data in one file. This makes it very convenient to distribute the entire application to another user, who can run it in disconnected environments. Microsoft Access offers parameterized queries. These queries and Access tables can be referenced from other programs like VB6 and .NET through DAO or ADO. From Microsoft Access, VBA can reference parameterized stored procedures via ADO. The desktop editions of Microsoft SQL Server can be used with Access as an alternative to the Jet Database Engine. This support started with MSDE (Microsoft SQL Server Desktop Engine), a scaled down version of Microsoft SQL Server 2000, and continues with the SQL Server Express versions of SQL Server 2005 and 2008. Microsoft Access is a file server-based database. Unlike client-server relational database management systems (RDBMS), Microsoft Access does not implement database triggers, stored procedures, or transaction logging.

Protection
Microsoft Access offers several ways to secure the application while allowing users to remain productive. The most basic is a database password. Once entered, the user has full control of all the database objects. This is a relatively weak form of protection which can be easily cracked. A higher level of protection is the use of workgroup security requiring a user name and password. Users and groups can be specified along with their rights at the object type or individual object level. Databases can also be encrypted. The ACCDB format offers significantly advanced encryption from previous versions.

15 | P a g e

DATA STRUCTURES
TABLE NAME: registration FIELD NAME userid username password hintquestion answer sex dob address city phoneno emailid TYPE TEXT TEXT TEXT TEXT TEXT TEXT DATE/TIME TEXT TEXT NUMBER TEXT

TABLE NAME: mail_details FIELD NAME from to date subject msgfile TYPE TEXT TEXT DATE/TIME TEXT TEXT

16 | P a g e

TABLE NAME: news_details FIELD NAME newsid date topic description daysvalid TYPE TEXT DATE/TIME TEXT TEXT NUMBER

TABLE NAME: addr_book FIELD NAME name address city emailid phoneno addedby TYPE TEXT TEXT TEXT TEXT NUMBER TEXT

TABLE NAME: notif FIELD NAME userid checked TYPE TEXT TEXT

17 | P a g e

SOURCE CODE

18 | P a g e

Portal.java:
/* To display the Portal Screen for User Name and Password Checking */ package Classes;

import java.awt.*; //for applet usage import java.awt.event.*; import javax.swing.*; public class Portal extends JFrame implements ActionListener { Label un,pw; Image img; Label mn; JTextField uname; JPasswordField pword; JButton log_but,can_but,reg_but; public Portal() { setTitle("Login Screen"); GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); mn = new Label("Mail Client Editor"); Font f = new Font("Times New Roman",Font.BOLD,20); mn.setFont(f); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 20; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; gbl.setConstraints(mn, gbc); add(mn); buildConstraints(gbc, 0, 1, 1, 1, 40, 12); un = new Label("UserId"); gbl.setConstraints(un, gbc); add(un); uname = new JTextField(10); buildConstraints(gbc, 1, 1, 2, 1, 60, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(uname, gbc); add(uname); pw = new Label("Password"); buildConstraints(gbc, 0, 2, 1, 1, 0, 12); gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(pw, gbc); add(pw);

19 | P a g e

pword = new JPasswordField(10); buildConstraints(gbc, 1, 2, 2, 1, 0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(pword, gbc); add(pword); log_but = new JButton("Login"); log_but.addActionListener(this); buildConstraints(gbc, 0, 3, 1, 1, 0, 15); gbc.ipadx = 20; gbc.ipady = 20; gbl.setConstraints(log_but, gbc); add(log_but); can_but = new JButton("Clear"); can_but.addActionListener(this); buildConstraints(gbc, 1, 3, 1, 1, 0, 0); gbl.setConstraints(can_but, gbc); add(can_but); reg_but = new JButton("Register"); reg_but.addActionListener(this); buildConstraints(gbc, 2, 3, 1, 1, 0, 0); gbl.setConstraints(reg_but, gbc); add(reg_but); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setVisible(false); System.exit(0); } } ); } /* Actions Handler for Portal, Cancel, Register */ public void actionPerformed(ActionEvent ae) { if (ae.getSource() == can_but) { uname.setText(""); pword.setText(""); } else if (ae.getSource() == reg_but) { Registration r = new Registration(); r.setLocation(0,0); r.setSize(800,600); r.setVisible(true); setVisible(false); } else if(ae.getSource()==log_but) { DBase d = new DBase();

20 | P a g e

String unm,pwd; unm = uname.getText(); pwd = pword.getText(); uname.setText(""); pword.setText(""); int res = d.checkUser(unm,pwd); if (res == 1) { setVisible(false); MenuWin i= new MenuWin(unm); i.setLocation(0,0); i.setSize(800,600); i.setVisible(true); } else if (res == 0) { Dialog db = new Dialog(this,"Error",true); db.setLayout(new BorderLayout()); db.setSize(100,100); db.add(new JLabel("Error in Login!"), BorderLayout.CENTER); JButton b; db.add((b = new JButton("Okay")), BorderLayout.SOUTH); b.addActionListener(new T(db)); db.setLocationRelativeTo(this); db.setVisible(true); uname.setText(""); pword.setText(""); } } } class T implements ActionListener { Dialog db; public T(Dialog db){ this.db = db; } public void actionPerformed(ActionEvent ae) { db.dispose(); } } public static void main(String ar[]) { Portal l = new Portal(); //l.setSize(640,480); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); } private void buildConstraints(GridBagConstraints gbc,int x, int y, int w, int h, int wx, int wy){ gbc.gridx = x; // start cell in a row

21 | P a g e

gbc.gridy = y; // start cell in a column gbc.gridwidth = w; // how many column does the control occupy in the row gbc.gridheight = h; // how many column does the control occupy in the column gbc.weightx = wx; // relative horizontal size gbc.weighty = wy; // relative vertical size } }

Registration.java
/** * To Register and Add new users and their details in addressbook */

package Classes; import java.awt.*; import java.sql.*; import java.awt.event.*; import javax.swing.*; public class Registration extends JFrame implements ActionListener { JLabel reg1,uid,uname,pword,rpass,hint,ans,sex,dob,addr,city,phone,mail; JTextField uid1,uname1,hint1,ans1,sex1,city1,phone1,mail1; JPasswordField pword1,rpass1; JButton reg,back; Connection con; PreparedStatement st; ButtonGroup cg; JRadioButton c1,c2; TextArea address; JComboBox dt,mn,yr; public Registration() { setTitle("RegistrationForm"); reg1= new JLabel("Register Here"); Font f=new Font("TimesNewRoman",Font.BOLD,15); reg1.setFont(f); reg1.setBounds(330,50,120,30); add(reg1); setLayout(null); setForeground(Color.black); uid = new JLabel("User Id"); uid.setBounds(250,100,100,25); add(uid); uid1 = new JTextField(10); uid1.setBounds(350,100,100,25); add(uid1); uname = new JLabel("User Name"); uname.setBounds(250,130,100,25);

22 | P a g e

add(uname); uname1 = new JTextField(10); uname1.setBounds(350,130,100,25); add(uname1); pword = new JLabel("Password"); pword.setBounds(250,160,100,25); add(pword); pword1 = new JPasswordField(10); pword1.setBounds(350,160,100,25); add(pword1); rpass=new JLabel("Retype Password"); rpass.setBounds(250,190,100,25); add(rpass); rpass1 = new JPasswordField(10); rpass1.setBounds(350,190,100,25); add(rpass1); hint = new JLabel("Hint Question"); hint.setBounds(250,220,100,25); add(hint); hint1= new JTextField(10); hint1.setBounds(350,220,100,25); add(hint1); ans= new JLabel("Answer"); ans.setBounds(250,250,100,25); add(ans); ans1= new JTextField(10); ans1.setBounds(350,250,100,25); add(ans1);

sex=new JLabel("Sex"); sex.setBounds(250,280,100,25); add(sex); cg = new ButtonGroup(); c1 = new JRadioButton("Male",true); c2 = new JRadioButton("Female",false); cg.add(c1); cg.add(c2); add(c1); c1.setBounds(350,280,100,25); add(c2); c2.setBounds(450,280,100,25); dob=new JLabel("Date of Birth"); dob.setBounds(250,310,100,25); add(dob);

23 | P a g e

dt=new JComboBox(); for (int i = 1; i < 32; i++) { dt.addItem(Integer.toString(i)); } dt.setBounds(350,310,50,20);

mn=new JComboBox(); for (int i = 1; i < 13; i++) { mn.addItem(Integer.toString(i)); } mn.setBounds(400,310,50,20);

yr=new JComboBox(); for (int i = 1975; i < 2000; i++) { yr.addItem(Integer.toString(i)); } yr.setBounds(450,310,60,20); add(dt); add(mn); add(yr); addr = new JLabel("Address"); addr.setBounds(250,340,100,25); add(addr); address= new TextArea(40,40); address.setBounds(350,340,100,50); add(address);

city = new JLabel("City"); city.setBounds(250,400,100,25); add(city); city1= new JTextField(10); city1.setBounds(350,400,100,25); add(city1); phone = new JLabel("Phone"); phone.setBounds(250,430,100,25); add(phone); phone1= new JTextField(10); phone1.setBounds(350,430,100,25); add(phone1); mail = new JLabel("e-mail"); mail.setBounds(250,460,100,25); add(mail); mail1= new JTextField(10); mail1.setBounds(350,460,100,25);

24 | P a g e

add(mail1); reg= new JButton("Register"); reg.setBounds(280,510,90,20); reg.addActionListener(this); add(reg); back= new JButton("back"); back.setBounds(400,510,90,20); back.addActionListener(this); add(back); connectDB(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setVisible(false); Portal l = new Portal(); //l.setSize(640,480); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); } } ); } public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn"); } catch(Exception e) { Registration.showErrMes("\n Connection Exception"); } } public void actionPerformed(ActionEvent ae) { final String uid,unm,pwd,rpwd,que,ans,addr,cy,em,ph; char sex='X'; int d,m,y,fs1=0,fs2=0; boolean pwf,ef,pf,ucf; pwf = ef = pf = ucf = true; final Frame tf; if (ae.getSource()==reg) { uid = uid1.getText(); unm = uname1.getText(); DBase db = new DBase(); ucf = db.checkUserID(uid); pwd = pword1.getText(); rpwd = rpass1.getText(); if (pwd.equals(rpwd) == false) pwf=false;

25 | P a g e

que = hint1.getText(); ans = ans1.getText(); if (c1.isSelected() == true) sex = 'M'; else if (c2.isSelected() == true) sex = 'F'; d = Integer.parseInt(dt.getItemAt(dt.getSelectedIndex())+""); m = Integer.parseInt(mn.getItemAt(mn.getSelectedIndex())+""); y = Integer.parseInt(yr.getItemAt(yr.getSelectedIndex())+""); addr = address.getText(); cy = city1.getText(); ph = phone1.getText(); int i; for (i=0;i<ph.length();i++) { if (ph.charAt(i) < 48 || ph.charAt(i) > 57) pf = false; } em = mail1.getText(); for (i=0;i<em.length();i++) { if (em.charAt(i) == '@') fs1++; if (em.charAt(i) == '.') fs2++; } if (fs1 != 1 || fs2 !=1) ef = false; if (pwf == true && pf == true && ef == true && ucf == true) { try { st = con.prepareStatement("insert into registration values (?,?,?,?,?,?,?,?,?,?,?)"); st.setString(1,uid); st.setString(2,unm); st.setString(3,pwd); st.setString(4,que); st.setString(5,ans); st.setString(6,String.valueOf(sex)); st.setString(7,d + "/" + m + "/" + y); st.setString(8,addr); st.setString(9,cy); st.setString(10,ph); st.setString(11,em); st.execute(); st = con.prepareStatement("insert into addr_book values (?,?,?,?,?,?)"); st.setString(1,unm); st.setString(2,addr); st.setString(3,cy); st.setString(4,em); st.setString(5,ph); st.setString(6, "admin"); st.execute(); st = con.prepareStatement("insert into notif values (?,?)"); st.setString(1,unm); st.setString(2,"yes"); st.execute();

26 | P a g e

//Registration.showErrMes("Inserted"); tf = new Frame("Ack"); tf.setBackground(Color.BLACK); tf.setSize(100,100); tf.setLocation(300,250); JLabel l = new JLabel("Record Inserted", JLabel.CENTER); l.setForeground(Color.green); tf.add(l); tf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { tf.setVisible(false); setVisible(false); Portal l = new Portal(); //l.setSize(640,480); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); l.uname.setText(uid); l.pword.setText(""); } }); tf.setVisible(true); } catch(Exception e) { Registration.showErrMes(e + ""); } } else if (pwf == false && pf == true && ef == true) { showErrMes("Incorrect Password"); } else if (ef == false && pwf == true && pf == true) { showErrMes("Invalid Email Id"); } else if (pf == false && pwf == true && ef == true) { showErrMes("Incorrect Phone Number"); } else if (ucf == false) { showErrMes("Duplicate User! Try with Other Names"); } else { showErrMes("Error in Inputs"); } } else if(ae.getSource()==back) { setVisible(false); Portal l = new Portal(); //l.setSize(640,480); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); } } public static void showErrMes(String title,String msg) { final JFrame f1 = new JFrame(title); f1.setLayout(new BorderLayout()); JLabel l = new JLabel(msg,JLabel.CENTER); JButton okay = new JButton("Okay"); okay.addActionListener(new T(f1));

27 | P a g e

f1.add(l,BorderLayout.NORTH); f1.add(okay,BorderLayout.SOUTH); f1.setSize(300,100); f1.setLocation(225,250); f1.setVisible(true); f1.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f1.setVisible(false); } } ); } public static void showErrMes(String msg) { showErrMes("Info:",msg); } static class T implements ActionListener { JFrame jf; public T(JFrame jf) { this.jf = jf; } public void actionPerformed(ActionEvent ae) { jf.dispose(); } } public static void main(String ar[]) { Registration r = new Registration(); r.setTitle("Registration Form"); r.setSize(800,600); r.setLocation(0,0); r.setVisible(true); } }

DBase.java
/** * To Verify UserId and Password */ package Classes; import java.sql.*; public class DBase { Connection con; Statement st; ResultSet rs; public DBase() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn"); } catch(Exception e) {

28 | P a g e

Registration.showErrMes("Database Connectivity Error"+e); } } public String getUserId(String emailid) { try { st = con.createStatement(); rs = st.executeQuery("select * from registration"); while (rs.next()) { if (rs.getString(11).equals(emailid)) return rs.getString(1); } } catch(Exception e) {} return null; } public int checkUser(String un, String pw) { try { st = con.createStatement(); rs = st.executeQuery("select * from registration"); while (rs.next()) { if (rs.getString(1).equals(un) && rs.getString(3).equals(pw)) return 1; } return 0; } catch(Exception e) { Registration.showErrMes("Record Set Accessing Error"+e); } return 0; } public boolean checkUserID(String un) { try { st = con.createStatement(); rs = st.executeQuery("select * from registration"); while (rs.next()) { if (rs.getString(1).equals(un)) return false; } } catch(Exception e) { Registration.showErrMes("Record Set Accessing Error"); } return true; } }

MenuWin.java
/* User Entry - Registered User's Portal */ package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*;

29 | P a g e

class MenuWin extends JFrame implements ActionListener, Runnable { Connection con; Statement st; String unm,pwd; JButton mail,abook,lout,nedt; JButton com,exit; JLabel lblTitle,welcome; Thread t; public MenuWin(String un) { unm = un; lblTitle = new JLabel("Operations List"); lblTitle.setBounds(300,40,200,50); Font f = new Font("Times New Roman",Font.BOLD | Font.ITALIC,30); lblTitle.setFont(f); add(lblTitle); welcome = new JLabel("Welcome "+unm); f = new Font("Arial", Font.BOLD | Font.ITALIC, 15); welcome.setFont(f); welcome.setBounds(100, 110, 200, 25); add(welcome); setTitle("Main Menus"); setLayout(null); mail=new JButton("Mail Editor"); mail.setBounds(330,170,120,25); mail.addActionListener(this); add(mail); if(unm.equals("admin")) nedt = new JButton("News Editor"); else nedt = new JButton("News Viewer"); nedt.setBounds(330,220,120,25); nedt.addActionListener(this); add(nedt); abook=new JButton("Address Book"); abook.setBounds(330,270,120,25); abook.addActionListener(this); add(abook); lout = new JButton("Logout"); lout.setBounds(600,420,100,25); lout.addActionListener(this); add(lout); exit=new JButton("Exit"); exit.setBounds(100,420,100,25); exit.addActionListener(this); add(exit);

30 | P a g e

addWindowListener(new W()); t = new Thread(this); t.start(); // // // try { notif(); } catch (InterruptedException ex) {}

} public void actionPerformed(ActionEvent ae) { if(ae.getSource()==mail) { setVisible(false); MailEditor e= new MailEditor(unm); e.setLocation(0,0); e.setSize(800,600); e.setVisible(true); } else if (ae.getSource() == nedt) { setVisible(false); if (unm.equals("admin")) { Editor e = new Editor(unm); e.setLocation(0,0); e.setSize(800,600); e.setVisible(true); } else { NewsUser ne = new NewsUser(unm); ne.setLocation(0,0); ne.setSize(800,600); ne.setVisible(true); } } else if(ae.getSource()==abook) { setVisible(false); AddBook a= new AddBook(unm); a.setLocation(0,0); a.setSize(800,600); a.setVisible(true); } else if(ae.getSource()==lout) { setVisible(false); Portal l = new Portal(); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); } else if(ae.getSource()==exit) { System.exit(0); }

31 | P a g e

} public void run() { if(new Notif().checkedMail(unm)==false) { Frame f = new Frame(); JLabel l = new JLabel(" New Message(s) arrived!"); f.setBackground(Color.DARK_GRAY); l.setFont(new Font("Arial Bold",Font.ITALIC,15)); l.setForeground(Color.ORANGE); f.add(l); f.setUndecorated(true); f.setAlwaysOnTop(true); f.setSize(200,100); //f.setLocationRelativeTo(this); f.setLocation(820,620); f.setVisible(true); try { Thread.sleep(5000); } catch (InterruptedException ex) {} f.setVisible(false); } } class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); Portal l = new Portal(); l.setResizable(false); l.pack(); l.setLocationByPlatform(true); l.setVisible(true); } } }

Notif.java
package Classes; import java.sql.*; public class Notif { Connection con; Statement st; ResultSet rs; public Notif() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn"); } catch(Exception e) { Registration.showErrMes("Database Connectivity Error"+e);

32 | P a g e

} } boolean checkedMail(String unm) { try { st = con.createStatement(); rs = st.executeQuery("select * from notif"); while (rs.next()) { if (rs.getString(1).equals(unm) && rs.getString(2).equals("no")) return false; } return true; } catch(Exception e) {} return true; } void setChecked(String unm) { try { String qry = "update notif set checked='yes' where userid='"+unm+"'"; st = con.createStatement(); st.executeUpdate(qry); } catch(Exception e) {}

} void setNotChecked(String unm) { try { String qry = "update notif set checked='no' where userid='"+unm+"'"; st = con.createStatement(); st.executeUpdate(qry); } catch(Exception e) {}

} }

MailEditor.java
package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MailEditor extends JFrame implements ActionListener, ItemListener { Connection con; PreparedStatement ps; Statement st; ResultSet rs; JLabel edt,lblFrom,lblTo,lblSub,lblMes,sub,date; JTextField txtTo,txtSub; TextArea txtMes, showMsg; JButton inbox,com,lout,reply;

33 | P a g e

String unm,email; String subjects[],msges[],dates[]; JButton back,cmdSend,cmdClear,showAddr; Panel panTop,panBot,panTop1,panCom,panInb; Font bold = new Font("Arial",Font.BOLD,13); List l = new List(10); int mailcount=0; public MailEditor(String un) { unm = un; setTitle("Mail Editor Screen"); setLayout(new BorderLayout()); panTop = new Panel(); panTop.setLayout(new BorderLayout()); panTop1 = new Panel(); panTop1.setLayout(new FlowLayout()); panBot = new Panel(); panBot.setLayout(new BorderLayout()); edt=new JLabel("Mail Editor", JLabel.CENTER); Font f=new Font("TimesNewRoman",Font.BOLD,15); edt.setBounds(280,80,200,25); edt.setFont(f); inbox=new JButton("Inbox"); inbox.setBounds(30,150,100,25); inbox.addActionListener(this); panTop1.add(inbox); com = new JButton("Compose"); com.setBounds(30,200,100,25); com.addActionListener(this); panTop1.add(com); back=new JButton("Back"); back.setBounds(100,500,100,25); back.addActionListener(this); panTop1.add(back); lout = new JButton("Logout"); lout.setBounds(30,250,100,25); lout.addActionListener(this); panTop1.add(lout); panTop.add("North",edt); panTop.add("South",panTop1); addWindowListener(new W()); //addInPane(); //addOutPane(); connectDB(); // Main Panels

//

//

//

//

//

34 | P a g e

add("North",panTop); add("Center",panBot); try{ st = con.createStatement(); rs = st.executeQuery("select * from registration"); while(rs.next()) if(rs.getString(1).equals(unm)) email = rs.getString(11); } catch(Exception e){ Registration.showErrMes("Error in receiving mail id"); } } // Panel Inbox void addInPane() { panInb = new Panel(); showMsg = new TextArea("Select a Message",100,100); showMsg.setEditable(false); mailcount=0; l.removeAll(); l.addItemListener(this);

panInb.setLayout(new BorderLayout()); try { st = con.createStatement(); rs = st.executeQuery("select * from mail_details"); while (rs.next()) if(rs.getString(2).equals(email)) mailcount++; subjects = new String[mailcount]; msges = new String[mailcount]; dates = new String[mailcount]; rs = st.executeQuery("select * from mail_details"); int i=0; while(rs.next()) if(rs.getString(2).equals(email)) { l.add(rs.getString(1)); dates[i] = rs.getString(3); subjects[i] = rs.getString(4); msges[i] = rs.getString(5); i++; }

Panel westpanel = new Panel(); westpanel.setLayout(new BorderLayout()); JLabel from = new JLabel("FROM"); from.setFont(bold); westpanel.add(from,BorderLayout.NORTH); westpanel.add(l,BorderLayout.CENTER); panInb.add(westpanel,BorderLayout.WEST);

35 | P a g e

Panel centerpanel = new Panel(); Panel centertopflowpanel = new Panel(); centertopflowpanel.setLayout(new BorderLayout()); centerpanel.setLayout(new BorderLayout()); sub = new JLabel(); sub.setFont(bold); centertopflowpanel.add(sub,BorderLayout.CENTER); reply = new JButton("Reply"); reply.addActionListener(this); centertopflowpanel.add(reply,BorderLayout.EAST); centerpanel.add(centertopflowpanel,BorderLayout.NORTH); centerpanel.add(showMsg,BorderLayout.CENTER); date = new JLabel(); centerpanel.add(date,BorderLayout.SOUTH); panInb.add(centerpanel,BorderLayout.CENTER); } catch(Exception e) { //Registration.showErrMes("Inbox Error"+e); System.out.print("Inbox Error"+e); } } // Panel Compose void addOutPane() { panCom = new Panel(); panCom.setLayout(null);

lblTo = new JLabel("To"); lblTo.setBounds(100,100,100,25); panCom.add("Center",lblTo); txtTo = new JTextField(150); txtTo.setBounds(200,100,500,25); panCom.add("Center",txtTo); lblSub = new JLabel("Subject"); lblSub.setBounds(100,150,100,25); panCom.add("Center",lblSub); txtSub = new JTextField(150); txtSub.setBounds(200,150,500,25); panCom.add("Center",txtSub); lblMes = new JLabel("Message"); lblMes.setBounds(100,200,100,25); panCom.add("Center",lblMes); txtMes = new TextArea(25,100); txtMes.setBounds(200,200,500,200); panCom.add("Center",txtMes); cmdSend = new JButton("Send Message"); cmdSend.setBounds(175,450,200,25); cmdSend.addActionListener(this); panCom.add("Center",cmdSend);

36 | P a g e

cmdClear = new JButton("Clear"); cmdClear.setBounds(400,450,100,25); cmdClear.addActionListener(this); panCom.add("Center",cmdClear); showAddr = new JButton("Show Address Book"); showAddr.setBounds(525,450,200,25); showAddr.addActionListener(this); panCom.add("Center",showAddr); } public void actionPerformed(ActionEvent ae) { if (ae.getSource()==inbox) { panBot.setVisible(false); panBot.removeAll(); addInPane(); panBot.add(panInb); panBot.setVisible(true); setVisible(true); new Notif().setChecked(unm); } else if (ae.getSource() == com) {panBot.setVisible(false); panBot.removeAll(); addOutPane(); panBot.add(panCom); panBot.setVisible(true); setVisible(true); } else if(ae.getSource()==back) { panBot.setVisible(false); panBot.removeAll(); setVisible(false); MenuWin i = new MenuWin(unm); i.setLocation(0,0); i.setSize(800,600); i.setVisible(true); } else if (ae.getSource()==lout) { panBot.setVisible(false); panBot.removeAll(); setVisible(false); Portal p = new Portal(); //p.setSize(640,480); p.setResizable(false); p.pack(); p.setLocationByPlatform(true); p.setVisible(true); }

37 | P a g e

else if (ae.getSource()==cmdSend) { panBot.setVisible(false); panBot.removeAll(); try { String mt,su,me; java.util.Date dt = new java.util.Date(); mt = txtTo.getText(); su = txtSub.getText(); me = txtMes.getText(); ps = con.prepareStatement("insert into mail_details values(?,?,?,?,?)"); ps.setString(1,email); ps.setString(2,mt); ps.setString(3,String.valueOf(dt)); ps.setString(4,su); ps.setString(5,me); ps.execute(); String recipient = new DBase().getUserId(mt); new Notif().setNotChecked(recipient); Registration.showErrMes("Acknowledge:","Mail Sent"); } catch(Exception e) { Registration.showErrMes(e+""); } } else if (ae.getSource()==cmdClear) { //txtFrom.setText(""); txtTo.setText(""); txtSub.setText(""); txtMes.setText(""); } else if(ae.getSource()==reply) { if(l.getSelectedIndex() == -1) { Registration.showErrMes("Select a Message to reply"); } else{ String to = l.getSelectedItem(); String resub = "Re: " + sub.getText().substring(9); panBot.setVisible(false); panBot.removeAll(); addOutPane(); panBot.add(panCom); panBot.setVisible(true); setVisible(true); txtTo.setText(to); txtSub.setText(resub); }

} else if (ae.getSource()== showAddr) {

38 | P a g e

ShowAddr s = new ShowAddr(unm); s.setLocation(0,0); s.setSize(800,600); s.setVisible(true); } } public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn","",""); } catch(Exception e) { Registration.showErrMes("\n Connection Exception"); } } public void itemStateChanged(ItemEvent ie) { int i = l.getSelectedIndex(); date.setText("Date: " + dates[i]); sub.setText("Subject: " + subjects[i]); showMsg.setText(msges[i]); showMsg.setBackground(Color.white); } class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); MenuWin i = new MenuWin(unm); i.setLocation(0,0); i.setSize(800,600); i.setVisible(true); } } }

Editor.java
/** * To Add NEW eventS */ package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*;

public class Editor extends JFrame implements ActionListener { JLabel nedt,nid,date,topic,desc,valid; JTextField nid1,date1,valid1; JButton back,ad;

39 | P a g e

List topic1; TextArea desc1; String unm; Connection con; PreparedStatement st; public Editor(String un) { unm = un; setTitle("News Editor"); nedt= new JLabel("News Editor"); Font f=new Font("TimesNewRoman",Font.BOLD,15); nedt.setFont(f); nedt.setBounds(350,50,100,25); add(nedt); setLayout(null); nid = new JLabel("News Id"); nid.setBounds(250,100,100,25); add(nid); nid1 = new JTextField(10); nid1.setBounds(350,100,100,25); add(nid1); date = new JLabel("Date"); date.setBounds(250,130,100,25); add(date); date1 = new JTextField(10); date1.setBounds(350,130,100,25); add(date1); topic = new JLabel("Topic"); topic.setBounds(250,160,100,25); add(topic); topic1=new List(1); topic1.add("Politics"); topic1.add("Business"); topic1.add("Sports"); topic1.add("Education"); topic1.setBounds(350,160,100,20); add(topic1);

desc= new JLabel("Description"); desc.setBounds(250,190,100,25); add(desc); desc1 = new TextArea(100,200); desc1.setBounds(250,220,500,150); add(desc1);

valid = new JLabel("Days Valid"); valid.setBounds(250,400,100,25); add(valid);

40 | P a g e

valid1= new JTextField(10); valid1.setBounds(350,400,100,25); add(valid1); back= new JButton("Back to Menu"); back.setBounds(280,510,120,25); back.addActionListener(this); add(back);

ad= new JButton("Add"); ad.setBounds(400,510,100,25); ad.addActionListener(this); add(ad); connectDB(); addWindowListener(new W()); } public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn","",""); //Registration.showErrMes("\n Connected"); } catch(Exception e) { Registration.showErrMes("\n Connection Exception"); //connectDB(); } } public void actionPerformed(ActionEvent ae) { String id,dt,tp,des,vdt; if (ae.getSource() == back) { setVisible(false); MenuWin m = new MenuWin(unm); m.setSize(800,600); m.setLocation(0,0); m.setVisible(true); } else if(ae.getSource()==ad) { id=nid1.getText(); dt=date1.getText(); tp=topic1.getSelectedItem(); des=desc1.getText(); vdt=valid1.getText(); try { st = con.prepareStatement("insert into news_details values (?,?,?,?,?)"); st.setString(1,id); st.setString(2,dt); st.setString(3,tp);

41 | P a g e

st.setString(4,des); st.setInt(5,Integer.parseInt(vdt)); st.execute(); Registration.showErrMes("Acknowledge","News Inserted"); nid1.setText(""); date1.setText(""); desc1.setText(""); valid1.setText(""); } catch(Exception e) { Registration.showErrMes(e+""); } } } class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); MenuWin m = new MenuWin(unm); m.setSize(800,600); m.setLocation(0,0); m.setVisible(true); } } }

NewsUser.java
/* To display the News for End Users */ package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class NewsUser extends JFrame implements ActionListener , ItemListener { JLabel nedt,ndt,ndesc,valid,valid1; JButton back; Choice lstdt; TextArea desc1; Connection con; PreparedStatement pst; Statement st; ResultSet rs,rs1; int yr,mn,dt; String unm; public NewsUser(String un) { unm = un; setTitle("News Editor Display"); nedt= new JLabel("News Editor Display"); Font f=new Font("TimesNewRoman",Font.BOLD,15);

42 | P a g e

nedt.setFont(f); nedt.setBounds(350,50,150,25); add(nedt); setLayout(null); ndt = new JLabel("Date"); ndt.setBounds(200,75,100,25); add(ndt); lstdt=new Choice(); lstdt.setBounds(300,75,80,20); add(lstdt); lstdt.addItemListener(this); ndesc = new JLabel("Description"); ndesc.setBounds(200,125,100,25); add(ndesc); desc1 = new TextArea(10,30); desc1.setBounds(300,125,400,300); add(desc1); valid = new JLabel("Days Valid"); valid.setBounds(200,475,100,25); add(valid); valid1= new JLabel(); valid1.setBounds(300,475,100,25); add(valid1); back= new JButton("Back to Menu"); back.setBounds(300,525,120,25); back.addActionListener(this); add(back); connectDB(); addWindowListener(new W()); } public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn","",""); //Registration.showErrMes("\n Connected"); st = con.createStatement(); String qry = "Select * from news_details"; rs = st.executeQuery(qry); while (rs.next()) { String str = rs.getString(2); int cnt=0; for (int i=0;i<lstdt.getItemCount();i++) { if (str.equals(lstdt.getItem(i))) { cnt++; }

43 | P a g e

} if (cnt == 0) lstdt.addItem(str); } } catch(Exception e) { Registration.showErrMes("\n Connection Exception"+e); //connectDB(); } } public void itemStateChanged(ItemEvent ie) { try { String qry = "Select * from news_details"; rs1 = st.executeQuery(qry); String d1 = (String) ie.getItem(); //Registration.showErrMes(d1); desc1.setText(""); valid1.setText(""); while (rs1.next()) { String d2 = rs1.getString(2); String str1,str2; int vd; str1 = rs1.getString(3); str2 = rs1.getString(4); vd = rs1.getInt(5); if (d1.equals(d2)) { desc1.append("\n"); desc1.append(str1); desc1.append("\n"); desc1.append(str2); desc1.append("\n"); valid1.setText(String.valueOf(vd)); } } } catch(Exception e) { Registration.showErrMes(e+""); } } public void actionPerformed(ActionEvent ae) { if (ae.getSource() ==back) { setVisible(false); MenuWin i = new MenuWin(unm); i.setLocation(0,0); i.setSize(800,600); i.setVisible(true); setVisible(false); }

44 | P a g e

} class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); MenuWin i = new MenuWin(unm); i.setLocation(0,0); i.setSize(800,600); i.setVisible(true); setVisible(false); } } }

AddBook.java
/** * To Add new Addressess in the Address Book */ package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class AddBook extends JFrame implements ActionListener { JLabel addb,name,city,mail,phone,addr; JTextField name1,city1,mail1,phone1; JButton back,ad,clr,view; TextArea address; Connection con; String unm; PreparedStatement st; public AddBook(String un) { unm = un; setTitle("Address Book - New Entry"); addb= new JLabel("Address Book"); Font f=new Font("TimesNewRoman",Font.BOLD,15); addb.setBounds(330,50,100,25); addb.setFont(f); add(addb); setLayout(null); name = new JLabel("Name"); name.setBounds(270,100,100,25); add(name); name1 = new JTextField(10); name1.setBounds(370,100,100,25); add(name1);

45 | P a g e

addr = new JLabel("Address"); addr.setBounds(270,160,100,25); add(addr); address = new TextArea(20,20); address.setBounds(370,160,100,50); add(address);

city= new JLabel("City"); city.setBounds(270,220,100,25); add(city); city1 = new JTextField(10); city1.setBounds(370,220,100,25); add(city1); mail=new JLabel("E-mail"); mail.setBounds(270,280,100,25); add(mail); mail1=new JTextField(10); mail1.setBounds(370,280,100,25); add(mail1); phone= new JLabel("Phone"); phone.setBounds(270,340,100,25); add(phone); phone1=new JTextField(10); phone1.setBounds(370,340,100,25); add(phone1); ad=new JButton("Add"); ad.setBounds(250,400,100,25); ad.addActionListener(this); add(ad); clr=new JButton("Clear"); clr.setBounds(350,400,100,25); clr.addActionListener(this); add(clr); back= new JButton("Back"); back.setBounds(450,400,100,25); back.addActionListener(this); add(back); view=new JButton("View all the Addresses"); view.setBounds(300,500,200,25); view.addActionListener(this); add(view); connectDB(); addWindowListener(new W());

46 | P a g e

} public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn"); } catch(Exception e) { Registration.showErrMes("\n Connection Exception"); } } public void actionPerformed(ActionEvent ae) { final Frame tf = new Frame("Acknowledge"); int j,fs=0,i; boolean ef,pf; ef=pf=true; String na,ad1,cy,em,ph; if (ae.getSource() ==back) { setVisible(false); MenuWin m = new MenuWin(unm); m.setLocation(0,0); m.setSize(800,600); m.setVisible(true); } else if (ae.getSource() == clr) { name1.setText(""); address.setText(""); city1.setText(""); phone1.setText(""); mail1.setText(""); } else if(ae.getSource()==ad) { na=name1.getText(); ad1=address.getText(); cy=city1.getText(); em=mail1.getText(); ph=phone1.getText(); for (j=0;j<ph.length();j++) { if (ph.charAt(j) <48 || ph.charAt(j)> 57) pf =false; } for (i=0;i<em.length();i++) { if (em.charAt(i) == '@') fs++; if (em.charAt(i) == '.') fs++; }

47 | P a g e

if (fs != 2) ef = false; if (pf == true && ef == false) { Registration.showErrMes("Error in Input","Incorrect email id"); } else if (pf==false && ef==true) { Registration.showErrMes("Error in Input","Incorrect Phone Number"); } else if(pf==true && ef==true) { try { st = con.prepareStatement("insert into addr_book values (?,?,?,?,?,?)"); st.setString(1,na); st.setString(2,ad1); st.setString(3,cy); st.setString(4,em); st.setString(5,ph); st.setString(6, unm); st.execute(); tf.setSize(100,100); tf.setLocation(300,250); JLabel l = new JLabel("Address Added", JLabel.CENTER); tf.add(l); tf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { tf.setVisible(false); } }); tf.setVisible(true); name1.setText(""); address.setText(""); city1.setText(""); mail1.setText(""); phone1.setText(""); } catch(Exception e) { Registration.showErrMes("Alert!",e+""); } } } else if (ae.getSource()==view) { ShowAddr s = new ShowAddr(unm); s.setLocation(0,0); s.setSize(800,600); s.setVisible(true); } }

48 | P a g e

class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); MenuWin m = new MenuWin(unm); m.setLocation(0,0); m.setSize(800,600); m.setVisible(true); } } }

ShowAddr.java
/* To display the News */ package Classes; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ShowAddr extends JFrame implements ActionListener { String unm; Connection con; Statement st; ResultSet rs; Panel pTop,pMid,pBot; JButton back; JLabel addb,l[][]; public ShowAddr(String un) { unm = un; setLayout(new BorderLayout()); pTop = new Panel(); pMid = new Panel(); pBot = new Panel(); l = new JLabel[20][5]; setTitle("Address Book - View"); addb= new JLabel("Address Book - View Details",JLabel.CENTER); Font f=new Font("TimesNewRoman",Font.BOLD,15); addb.setBounds(320,50,100,25); addb.setFont(f); pTop.add(addb); pMid.setLayout(new GridLayout(20,5)); for (int i=0;i<20;i++) { for (int j=0;j<5;j++) { l[i][j] = new JLabel("",JLabel.CENTER); pMid.add(l[i][j]); }

49 | P a g e

} l[0][0].setText("Name"); l[0][1].setText("Address"); l[0][2].setText("City"); l[0][3].setText("Email"); l[0][4].setText("Phone"); f=new Font("TimesNewRoman",Font.BOLD,14); for(int i=0;i<5;i++) l[0][i].setFont(f); back = new JButton("Back"); back.setBounds(300,350,100,25); back.addActionListener(this); pBot.add(back); connectDB(); add("North",pTop); add("Center",pMid); add("South",pBot); connectDB(); addWindowListener(new W()); } public void connectDB() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn","",""); //Registration.showErrMes("\n Connected"); st = con.createStatement(); rs = st.executeQuery("select * from addr_book"); int i=1; String s1,s2,s3,s4,s5; while (rs.next()) { if(rs.getString(6).equals(unm)) { s1 = rs.getString(1); s2 = rs.getString(2); s3 = rs.getString(3); s4 = rs.getString(4); s5 = rs.getString(5); l[i][0].setText(s1); l[i][1].setText(s2); l[i][2].setText(s3); l[i][3].setText(s4); l[i][4].setText(s5); i++; } } } catch(Exception e) { Registration.showErrMes("\n Connection Exception"); //connectDB(); } }

50 | P a g e

public void actionPerformed(ActionEvent ae) { final Frame tf = new Frame("Acknowledge"); int j,fs=0,i; boolean ef,pf; ef=pf=true; String na,ad1,cy,em,ph; if (ae.getSource() == back) { setVisible(false); } } public void showErrMes(String msg) { final Frame f1 = new Frame("Error in Input"); JLabel l = new JLabel(msg,JLabel.CENTER); f1.add(l); f1.setSize(200,100); f1.setLocation(300,300); f1.setVisible(true); f1.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f1.setVisible(false); } } ); } class W extends WindowAdapter { public void windowClosing(WindowEvent we) { setVisible(false); } } }

51 | P a g e

SCREEN LAYOUTS

52 | P a g e

LOGIN PORTAL

REGISTRATION FORM

53 | P a g e

ADMIN’S MAIN MENU

54 | P a g e

ENDUSER’S MAIN MENU

55 | P a g e

MAIL INBOX

Mail Compose

56 | P a g e

Admin’s News Editor

EndUser’s News Reader

57 | P a g e

AddressBook

AddressBook – View

58 | P a g e

CONCLUSION
The “INTRANET MAILING SYSTEM” project was designed in a user-friendly manner specifically to meet the needs of Up and Down communication in an Organization. The user need not remember the mail address of others as they can refer using the address book. The new mail popup also helps to notify the user whether to check inbox or not. Since Java is an Object Oriented Platform, we can change (or) modify any activities in the future. This project is flexible to add new aspects. The application has been developed in the multi-user platformindependent approach. So the single application can be linked and used by many users simultaneously in any operating system as long as it is JRE6 compliant. Now we use MS-Access database to maintain the details. In future, we may use “MYSQL” or “DB2” to maintain the information. Any change in database in future will be probably supported as long as that DBMS supports ODBC and SQL.

59 | P a g e

BIBLIOGRAPHY
JAVA THE COMPLETE REFERENCE J2SE 5 Edition  TATA MCGRAW-HILL EDITION  HERBERT SCHILDT

THINKING IN JAVA 4TH EDITION  PRENTICE HALL  BRUCE ECKEL

MICROSOFT ACCESS 2007  BIBLE  WILEY

SOFTWARE ENGINEERING  RICHARD FAIRLEY

60 | P a g e

Sign up to vote on this title
UsefulNot useful