Professional Documents
Culture Documents
of
class
XII-A
successfully
INFORMATICS
entitled
SLAM
has
completed
PRACTICES
BOOK
project
during
the
Signature of
Signature of
Internal Examiner:
External
Examiner:
DECLARATIO
N
I hereby declare that the project work
entitled
SLAM
BOOK,
submitted
to
CM.SATWIK
Class XII A
ACKNOWLEDGEME
NT
Gratitude is the fairest blossom which
constant
encouragement
and
his
enthusiasm
to
involved
in
the
assignment,
people
who
CM.SATWIK
Class: XIIA
CONTENTS
1. INTRODUCTION
2. HARDWARE AND SOFTWARE REQUIREMENTS
3. FILES IMPORTED
4.
7.
CODING
8.
CONCLUSION
9.
BIBLIOGRAPHY
Introduction
A typical Slam Book requires a management
system to ease its operations such as maintaining details
of all the people in it, attending to various needs of users
and also achieving increased efficiency in the accessing
of the data.
modules
and
ease
the
process
of
saving
Hardware &
software
required
Hardware:
On
the
hardware
part
hardware
supports
Windows
Vista/7/XP
that
any
Software:
Files imported
java.awt :
java.io:
Java IO is an API that comes with Java which is targeted at reading and
writing data (input and output). The Java IO package is primarily focused on input and
8
output to files, network streams, internal memory buffers etc. you read and write data
to and from it via Java IO's InputStream and OutputStream classes.
java.sql:
This package provides the APIs for accessing and processing data which
is stored in the database especially relational database by using the java programming
language. It includes a framework where we different drivers can be installed
dynamically to access different databases especially relational databases.
This java.sql package contains API for the following basic operations other than
Mappings and Exceptions.
1 Making a connection with a database with the help of DriverManager class
2). Sending SQL Parameters to a database:
3). Updating and retrieving the results of a query:
javax.imageio:
describing the contents of image files, including metadata and thumbnails (IOImage);
for controlling the image reading process, and image writing process, and for reporting
errors.
components than the earlier Abstract Window Toolkit (AWT). Swing provides several
advanced components such as tabbed panel, scroll panes, trees, tables, and lists.
Classes generated
Welcome:
Start:
Addbuddy:
details of the
friend in the database like name,
mobile number
whose
Viewbuddy:
the friends in
the database.
Search:
particular
10
welcome class
CODING
package myslambook;
import java.awt.Color;
/** * @author CM SATWIK*/
Public class welcome extends javax.swing.JFrame {
public welcome() {
initComponents();
this.getContentPane().setBackground(Color.blue) ;
new
javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(51, 0, 255));
setPreferredSize(new ava.awt.Dimension(1450, 1000));
setType(java.awt.Window.Type.UTILITY);
jButton1.setBackground(new java.awt.Color(153, 204, 255));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 0, 153));
11
jButton1.setText("WELCOME TO MY SLAMBOOK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt)
jButton1ActionPerformed(evt);
});
End
of
Welcome
Class___________________________________________
12
Startup class
CODING
package myslambook;
import java.awt.Color;
public class startup extends javax.swing.JFrame {
public startup() {
initComponents();
this.getContentPane().setBackground(Color.DARK_GRAY) ;
jButton1.setBackground(Color.RED);
jButton2.setBackground(Color.MAGENTA);
jButton3.setBackground(Color.GREEN);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
new viewbuddy().setVisible(true);
}
13
});
}
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
___________________________ End of Startup Class_______________________________
14
Add buddy
CODING
package myslambook;
import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
15
import java.sql.SQLException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
public class addbuddy extends javax.swing.JFrame {
public addbuddy() {
initComponents();
this.getContentPane().setBackground(Color.BLUE) ;
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JPG, GIF, and PNG Images", "jpg", "gif", "png");
jFileChooser1.setFileFilter(filter);
int o = jFileChooser1.showOpenDialog(this);
if (o == JFileChooser.APPROVE_OPTION) {
File f = jFileChooser1.getSelectedFile();
filename = f.getAbsolutePath();
System.out.println("You chose to open this file: " + f.getName());
BufferedImage image;
try
{ //display the image in jlabel
16
image = ImageIO.read(f);
jLabel16.setIcon(new ImageIcon("" + f));
catch(IOException e)
this.pack();}
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (jRadioButton1.isSelected())
jLabel12.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/images/Acquintance.png")));
relation = "acquintance";
if (jRadioButton5.isSelected())
jLabel12.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/images/Friend.png")));
relation = "classmate";
try {
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/slambook","
root","tiger");
System.out.println("Connection Established Succcesfully..."); }
catch(ClassNotFoundException | SQLException e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}
try
if(filename!=null )
{
ps=connection.prepareStatement("insert
into
friends
values(?,?,?,?,?,?,?,?,?,?,?)");
18
JOptionPane.showMessageDialog(this,
}
}
19
viewbuddy
CODING
package myslambook;
20
import java.awt.image.BufferedImage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;
public class viewbuddy extends javax.swing.JFrame {
private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
String s = jList1.getSelectedValue().toString();
try
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/sla
mbook","root","tiger");
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * FROM friends WHERE realname
= \'" + s + "\';");
while(resultSet.next()){
21
jLabel2.setText(resultSet.getString(1));
jLabel3.setText(resultSet.getString(2));
jLabel4.setText(resultSet.getString(3));
jLabel5.setText(resultSet.getString(4));
jLabel6.setText(resultSet.getString(5));
jLabel7.setText(resultSet.getString(6));
jLabel8.setText(resultSet.getString(7));
jLabel9.setText(resultSet.getString(8));
jLabel10.setText(resultSet.getString(9));
jLabel11.setText(resultSet.getString(11));
BufferedImage im = ImageIO.read(resultSet.getBinaryStream(10));
ImageIcon image1 = new ImageIcon(im);
jLabel1.setIcon(image1);
showall();
finally
{
try
resultSet.close();
statement.close();
connection.close();
}
catch (Exception ex)
{
22
ex.printStackTrace();
}
l9.setVisible(true);
l10.setVisible(true); }
public final void hideall(){
l1.setVisible(false);
l2.setVisible(false);
l3.setVisible(false);
l4.setVisible(false);
l5.setVisible(false);
l6.setVisible(false);
l7.setVisible(false);
l8.setVisible(false);
l9.setVisible(false);
l10.setVisible(false);
jList1.setVisible(false);
try
Class.forName("com.mysql.jdbc.Driver");
24
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/slambo
ok","root","*****");
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * FROM friends;" );
DefaultListModel list = new DefaultListModel();
int i = 0 ;
while(resultSet.next())
list.addElement(resultSet.getString(1));
jList1.setModel(list);
try
resultSet.close();
statement.close();
connection.close();
catch (Exception ex)
}
{
ex.printStackTrace();
}
});
}}
25
search
CODING
package myslambook;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class search extends javax.swing.JFrame {
public search() {
initComponents();
clearAll();
hideall();
this.getContentPane().setBackground(Color.BLUE) ;
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/sl
ambook","root","*****");
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * FROM friends WHERE
realname = \'" + jsearch.getText() + "\';");
while(resultSet.next()){
jLabel2.setText(resultSet.getString(1));
jLabel3.setText(resultSet.getString(2));
jLabel4.setText(resultSet.getString(3));
jLabel5.setText(resultSet.getString(4));
jLabel6.setText(resultSet.getString(5));
jLabel7.setText(resultSet.getString(6));
jLabel8.setText(resultSet.getString(7));
jLabel9.setText(resultSet.getString(8));
jLabel10.setText(resultSet.getString(9));
jLabel1.setText(resultSet.getString(11));
BufferedImage im = ImageIO.read(resultSet.getBinaryStream(10));
ImageIcon image1 = new ImageIcon(im);
jLabel1.setIcon(image1);
showall();
catch (Exception ex)
}
{
27
ex.printStackTrace();
finally
try
{
{
resultSet.close();
statement.close();
connection.close();
}
catch (Exception ex)
ex.printStackTrace();
{
}
}
public final void clearAll(){
jLabel1.setText("");
jLabel2.setText("");
jLabel3.setText("");
jLabel4.setText("");
jLabel5.setText("");
jLabel6.setText("");
jLabel7.setText("");
jLabel8.setText("");
jLabel9.setText("");
jLabel10.setText("");
jLabel11.setText("");
}
public final void showall(){
28
l1.setVisible(true);
l2.setVisible(true);
l3.setVisible(true);
l4.setVisible(true);
l5.setVisible(true);
l6.setVisible(true);
l7.setVisible(true);
l8.setVisible(true);
l9.setVisible(true);
l10.setVisible(true);
}
});
}}
Conclusion
This Software is developed initially with basic features. First
the welcome Screen appears, from where a user is allowed to traverse
through. Then various options like Addbuddy, Viewbuddy, Search and
Exit options comes.
A user can save details of a friend in Addbuddy. View the list
of friends in Viewbuddy, and further clicking on any name, one can see
the full details. He can also search any particular friend by typing name.
Right now we are developing this software for testing
purpose but after completing this project it can be used as web
application. It will reduce use of paper and it will be time saving
software. It will produce result efficiently and quickly.
The software removes the redundancy by providing the check on
mobile no., which allows only one data record, can exist in table for one
mobile no. we can modify the software according their further requirements
and additional features can be added.
30
Bibliography
1 http://www.google.com/
2 http://en.wikipedia.org
3 http://cbsecsnip.in
4 http://cbse.nic.in
5 www.bOtskOOL.com
31
32