Professional Documents
Culture Documents
Date : Date :
ID – SHEET
Roll No : ………………………….
Phone No : 9504772727
Prashant Piyush
TABLE OF CONTENTS
Introduction
Java Details
Priliminary Design
Form Layouts
Database Design
Implementation
Bibliography
Teacher Remarks
INTRODUCTION
project.
What is java?
Java is a general purpose object oriented programming language . It is the first programming
language that is not tied to any particular hardware or operating system .The language is
based on the concept of an object. Java is highly derived from C++ . Most striking feature of
the language is that it is platform neutral language.
There were five primary goals in the creation of the Java language:
Java tools
In order to write java application or applets ,one need more than a language . The tools that
lets one to write , test , debug programs.
Java features
● Compiler and Interpreted
● Platform independent
● Simple
● Secure
● Familiar
● Portable
● Object-Oriented
● Robust
● Multithreaded
● High performance
● Distributed
● Dynamic
Compiler and Interpreted -There is a java compiler , named javac . The java compiler
takes input source code files (these files typically have the ext.java) and converts them into
compiled bytecode files.The java Interpreter known as javac can be used to execute java
application .The interpreter translates bytecode directly into program actions.
Platform independent- Java programs can be easily moved from one computer to
another, anywhere and anytime.Changes and upgradesmade in operatingsystems,
processors and system resources will not force any changes in java programs.
Simple - Java is designed to be easy for programmer to learn and use efficiently.
Secure- When we use a java compatible web browser, we can safely download java applets
without fear of virus infection. Java achieves this protection by confining a java program to
java execution environment and not allowing it access to other parts of the computer.
Object-Oriented - Java is a true object-oriented language. All program code and data
reside within objects and classes.
Robust -It provides many safeguards to ensure reliable code. It has strict compile time and
run time checking for data types. Designed as a garbage-collected language relieving the
programmers and also incorpates the concept of exception handling which captures series
errors.
Distributed- It has ability to share both data and programs. Java applications can open and
access remote objects on internet which enables multiple programmers at multiple remote
locations to collaborate and work together on single project.
Dynamic - Java is capable of dynamically in new class libraries , methods and objects .It
supports functions written in other languages like C,C++ called as native methods.
Automatic garbage collection -One idea behind Java's automatic memory management
model is that programmers should be spared the burden of having to perform manual
memory management. In some languages the programmer allocates memory to create any
object stored on the heap and is responsible for later manually deallocating that memory to
delete any such objects. If a programmer forgets to de-allocate memory or writes code that
fails to do so in a timely fashion, a memory leak can occur: the program will consume a
potentially arbitrarily large amount of memory. In addition, if a region of memory is de-
allocated twice, the program can become unstable and may crash.
In Java, this potential problem is avoided by automatic garbage collection. The programmer
determines when objects are created and the Java runtime is responsible for managing the
objects' lifecycle. The program or other objects can reference an object by holding a
reference to it (which, from a low-level point of view, is its address on the heap). When no
references to an object remain, the Java garbage collector automatically deletes the
unreachable object, freeing memory and preventing a memory leak. Memory leaks may still
occur if a programmer's code holds a reference to an object that is no longer needed—in
other words, they can still occur but at higher conceptual levels.
Comparing Java and C++, it is possible in C++ to implement similar functionality (for
example, a memory management model for specific classes can be designed in C++ to
improve speed and lower memory fragmentation considerably), with the possibly cost of
extra development time and some application complexity. In Java, garbage collection is built
in and virtually invisible to the developer. That is, developers may have no notion of when
garbage collection will take place as it may not necessarily correlate with any actions being
explicitly performed by the code they write. Depending on intended application, this can be
beneficial or disadvantageous: the programmer is freed from performing low-level tasks but
at the same time lose the option of writing lower level code.
Objects and Classes -An object is a software bundle of variables and related methods.
Objects are key to understanding object-oriented technology. Real-world objects share two
characteristics: They all have state and behavior.
Software objects are modeled after real-world objects in that they too have state and
behaviorClasses can also define class variables. A class variable contains information that is
shared by all instances of the class .A class can also declare class methods. You can invoke a
class method directly from the class, whereas you must invoke instance methods on a
particular instance.
Inheritance - Inheritance is the process by which objects of one class acquire the property
of objects of another class. Each subclass inherits state .However, subclasses are not limited
to the states and behaviors provided to them by their superclass. Subclasses can add
variables and methods to the ones they inherit from the superclass. It supports the concept
of hierarchical classification it also provides the use of reusability. .
Polymorphism - This means the ability to take more than one form. An operation may
exhibit different behaviour in different instances. The behaviour depends upon the types of
data used in the operation. It plays an important role in allowing objects having different
internal structures to share external interface.
The Java Database Connectivity (JDBC) API is the industry standard for database-
independent connectivity between the Java programming language and a wide range of
databases – SQL databases and other tabular data sources, such as spreadsheets or flat files.
The JDBC API provides a call-level API for SQL-based database access.
JDBC technology allows you to use the Java programming language to exploit "Write Once,
Run Anywhere" capabilities for applications that require access to enterprise data. With a
JDBC technology-enabled driver, you can connect all corporate data even in a
heterogeneous environment.
Driver
Database
Database
The JDBC architecture is based on a collection of java interfaces and classes that together enable you
to connect to data sources , to create and execute SQL statements and to retrieve and modify data in
a database.
The JDBC-ODBC Bridge –“sun.jdbc.odbc.jdbcodbcDriver”-is included with JDK and it enables Java
applications to access data through drivers written to the ODBC standard. The driver bridge is useful
for accessing data in data sources for which no pure JDBC drivers exist. The bridge works by
translating the JDBC methods into ODBC function calls.
● Data Defination Language (DDL) – DDL statements are used to describe the tables
and the data they contain. The subset of SQL statements used for modeling the structure
(rather than the contents) of a database or cube. The DDL gives you the ability to create,
modify, and remove databases and database objects.
● Data Manipulation Language (DML) – DML statements that are used to operate on
data in the database. These are statements that allow you to create or alter objects (such as
tables, indexes, views, and so on) in the database. The subset of SQL statements used to
retrieve and manipulate data. DML can be further divided into 2 groups:-
SELECT - SQL statement used to request a selection, projection, join, query, and so on,
from a SQL Server database.
Primary key – Primary key constraints identify the column or set of columns whose values
uniquely identify a row in a table. No two rows in a table can have the same primary key
value. You cannot enter a NULL value for any column in a primary key.
Insert- The Insert logical operator inserts each row from its input into the object specified
in the Argument column. To insert the data into a relation we either specify a tuple to be
inserted or write a query.
Delete- The Delete logical operator deletes from an object rows that satisfy the optional
predicate in the Argument column. We can delete only whole tuples; we cannot delete
values on only particular attributes.
Update- The Update logical operator updates each row from its input in the object
specified in the Argument column. It provides a way of modifying existing data in a table.
SWING
SWING is a set of classes that provides powerful and flexible functionality. In addition with
several components provided by AWT, swing supplies several exciting additions, including
tabbed panes, scroll panes, trees and tables. It also changes the images as the state of any
component changes. Swing is built upon the foundation of the AWT. Swing components are
written entirely in Java and therefore are Platform-independent .Swing is also termed also
light-weight and provide pluggable look and feel.
There are 2 Swing classes that are quite important:
Jframe and Component – Jframe extends the AWT class Frame. It contains additional
features that enable it to support Swing components. JComponent extends the AWT
component and Container classes. It is the top level class for all Swing components and
provides Swing pluggable look and feel.
Here are some of the Swing component classes:
CLASS DESCRIPTION
Abstract Button Abstract super class for Swing buttons.
Button Group Encapsulates a mutually exclusive set of
buttons.
Image Icon Encapsulates an icon.
JApplet The SWING version of APPLET.
JButton The SWING push button class.
JCheckBox The SWING check box class.
JComboBox Encapsulates a combo box .
JLabels The SWING version of a label.
JRadioButton The SWING version of a radio button.
JScrollPane Encapsulates a scrollable window.
JTabbedPane Encapsulates a tabbed window.
JTextField The SWING version of Text field.
JTree Encapsulates a tree based-control.
● Icons – Icons are encapsulated by the Image Icon class, which paints an icon from an
image.
● JLabel – Labels are the instances of the JLabel class which extends JComponent. It can
display text or icon. These are passive controls that do not support any interaction with the
user.
● JButton – JButton class provides the functionality of a push button. JButton allows an
icon of string to be associated with the push button.
● JComboBox– It is provided through the JComboBox class. It normally displays one entry
and can also display a drop down list that allows a user to select a different entry.
● JTree - It is a component that presents a hierarchical view of data. A user has ability to
expand individual subtrees. These are implemented in Swing by JTree class.
1. It provides more powerful and more flexible components possible in AWT package.
For e.g. JButton can have both image as well as text field associated with it which is
not possible in awt package.
2. Unlike AWT components SWING components are not implemented by platform-
specific code. Instead they are written entirely in java and therefore are platform
independent. Thus term lightweight is used to describe such elements.
3. Further the Swing components can provide pluggable look and feel, which means
that it is easy to substitute another appearance and behavior for an element.
PRELIMINARY
DESIGN
(User Interface)
FORM
LAYOUTS
DATABASE
DESIGN
IMPLEMENTATION
PassWordTF = new
javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
LogInB = new javax.swing.JButton();
invalidl = new javax.swing.JLabel();
***************************************** invalid = new javax.swing.JLabel();
jDialog1Layout.createParallelGroup(javax.swing.Gr
/** This method is called from within the
oupLayout.Alignment.LEADING)
constructor to
.addGap(0, 300, Short.MAX_VALUE)
* initialize the form.
);
* WARNING: Do NOT modify this code. The
content of this method is
* always regenerated by the Form Editor.
setDefaultCloseOperation(javax.swing.WindowCon
*/
stants.EXIT_ON_CLOSE);
@SuppressWarnings("unchecked")
setTitle("City Sports Shop Management
// <editor-fold defaultstate="collapsed"
System");
desc="Generated Code">
setBounds(new java.awt.Rectangle(200, 70, 0,
private void initComponents() {
0));
jPopupMenu1 = new
jLabel3.setFont(new java.awt.Font("Tahoma",
javax.swing.JPopupMenu();
1, 12)); // NOI18N
jPopupMenu2 = new
jLabel3.setForeground(new java.awt.Color(0,
javax.swing.JPopupMenu();
153, 255));
jDialog1 = new javax.swing.JDialog();
jLabel3.setText("PASSWORD");
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel2.setFont(new java.awt.Font("Tahoma",
idtf = new javax.swing.JTextField();
1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, javax.swing.GroupLayout layout = new
153, 255)); javax.swing.GroupLayout(getContentPane());
jLabel2.setText("LOGIN ID"); getContentPane().setLayout(layout);
layout.setHorizontalGroup(
idtf.setBackground(new java.awt.Color(204,
255, 204)); layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING)
PassWordTF.setBackground(new .addGroup(layout.createSequentialGroup()
java.awt.Color(204, 255, 204)); .addGap(20, 20, 20)
jLabel4.setBackground(new .addGroup(layout.createParallelGroup(javax.swing
java.awt.Color(204, 204, 255)); .GroupLayout.Alignment.LEADING)
jLabel4.setFont(new java.awt.Font("Colonna .addComponent(jLabel1)
MT", 3, 24)); // NOI18N
jLabel4.setForeground(new java.awt.Color(51, .addGroup(javax.swing.GroupLayout.Alignment.TR
153, 255)); AILING, layout.createSequentialGroup()
jLabel4.setText("SHOP MANAGEMENT
SYSTEM"); .addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED, 115,
jLabel1.setIcon(new javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.ImageIcon(getClass().getResource("/sp .addComponent(jLabel4,
orts.png"))); // NOI18N javax.swing.GroupLayout.PREFERRED_SIZE, 370,
javax.swing.GroupLayout.PREFERRED_SIZE)
jLabel6.setFont(new java.awt.Font("Poor .addGap(5, 5, 5))
Richard", 0, 18));
jLabel6.setForeground(new java.awt.Color(0, .addGroup(javax.swing.GroupLayout.Alignment.TR
153, 255)); AILING, layout.createSequentialGroup()
jLabel6.setText("LOG IN TO CONTINUE"); .addGap(55, 55, 55)
jMenu1.setBorder(javax.swing.BorderFactory.creat jMenuBar1.add(jMenu1);
eEtchedBorder());
jMenu1.setText("Sports Club");
jMenu1.setFont(new java.awt.Font("Segoe jMenu2.setBorder(javax.swing.BorderFactory.creat
UI", 1, 18)); // NOI18N eEtchedBorder());
jMenu1.addActionListener(new jMenu2.setText("View");
java.awt.event.ActionListener() { jMenu2.setFont(new java.awt.Font("Segoe
public void UI", 1, 18)); // NOI18N
actionPerformed(java.awt.event.ActionEvent evt) { jMenu2.addActionListener(new
jMenu1ActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu2ActionPerformed(evt);
mnuCustAdd.setFont(new }
java.awt.Font("Segoe UI", 1, 14)); // NOI18N });
mnuCustAdd.setText("Cusomer Entry");
mnuCustAdd.addActionListener(new ListCust.setFont(new java.awt.Font("Segoe
java.awt.event.ActionListener() { UI", 1, 14)); // NOI18N
public void ListCust.setText("Customer List");
actionPerformed(java.awt.event.ActionEvent evt) { ListCust.addActionListener(new
mnuCustAddActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1.add(mnuCustAdd); ListCustActionPerformed(evt);
}
mnuCARSAdd.setFont(new });
java.awt.Font("Segoe UI", 1, 14)); // NOI18N jMenu2.add(ListCust);
}
ListCARS.setFont(new java.awt.Font("Segoe });
UI", 1, 14)); // NOI18N jMenu3.add(jMenuCARS1);
ListCARS.setText("CARS List");
ListCARS.addActionListener(new jMenuBar1.add(jMenu3);
java.awt.event.ActionListener() {
public void setJMenuBar(jMenuBar1);
actionPerformed(java.awt.event.ActionEvent evt) {
ListCARSActionPerformed(evt); javax.swing.GroupLayout layout = new
} javax.swing.GroupLayout(getContentPane());
}); getContentPane().setLayout(layout);
jMenu2.add(ListCARS); layout.setHorizontalGroup(
.addGroup(javax.swing.GroupLayout.Alignment.TR
jMenu3.setBorder(javax.swing.BorderFactory.creat AILING, layout.createSequentialGroup()
eEtchedBorder()); .addContainerGap(110,
jMenu3.setText("quit"); Short.MAX_VALUE)
jMenu3.setFont(new java.awt.Font("Segoe .addComponent(jLabel1,
UI", 1, 18)); // NOI18N javax.swing.GroupLayout.PREFERRED_SIZE, 107,
jMenu3.addActionListener(new javax.swing.GroupLayout.PREFERRED_SIZE)
java.awt.event.ActionListener() { .addGap(115, 115, 115))
public void );
actionPerformed(java.awt.event.ActionEvent evt) {
jMenu3ActionPerformed(evt); java.awt.Dimension screenSize =
} java.awt.Toolkit.getDefaultToolkit().getScreenSize(
}); );
setBounds((screenSize.width-527)/2,
jMenuCARS1.setFont(new (screenSize.height-401)/2, 527, 401);
java.awt.Font("Segoe UI", 1, 14)); // NOI18N }// </editor-fold>
jMenuCARS1.setText("Application");
jMenuCARS1.addActionListener(new private void
java.awt.event.ActionListener() { mnuCustAddActionPerformed(java.awt.event.Acti
public void onEvent evt) {
actionPerformed(java.awt.event.ActionEvent evt) { this.setVisible(false);
jMenuCARS1ActionPerformed(evt); new ShopINUI().setVisible(true);
} }
private void }
ListOrderActionPerformed(java.awt.event.ActionE
vent evt) {
this.setVisible(false); *****************************************
new OrdListUI().setVisible(true); CUSTOMER DETAILS
*****************************************
import java.sql.*; jLabel6.setFont(new java.awt.Font("Tahoma",
import javax.swing.JOptionPane; 1, 24));
jLabel6.setText("CARSHOWROOM Data Entry
public class ShopINUI extends javax.swing.JFrame { Form");
txtSHCity.setFont(new
setDefaultCloseOperation(javax.swing.WindowCon java.awt.Font("Tahoma", 1, 12));
stants.EXIT_ON_CLOSE);
setTitle("CARSHOWROOM Data Entry Form"); btnClear.setFont(new
setCursor(new java.awt.Font("Tahoma", 1, 12));
java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSO btnClear.setText("Clear");
R)); btnClear.addActionListener(new
java.awt.event.ActionListener() {
txtSHPhone.setFont(new public void
java.awt.Font("Tahoma", 1, 12)); actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
}); .addComponent(jLabel3))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing
.addComponent(txtSHno, .GroupLayout.Alignment.LEADING, false)
javax.swing.GroupLayout.PREFERRED_SIZE, .addComponent(btnClear,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.Compo .addComponent(btnBack,
nentPlacement.RELATED) javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(btnSave,
.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.DEFAULT_SIZE, 35,
.addComponent(txtSHName, Short.MAX_VALUE))
javax.swing.GroupLayout.PREFERRED_SIZE, .addGap(24, 24, 24))
javax.swing.GroupLayout.DEFAULT_SIZE, );
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)) java.awt.Dimension screenSize =
.addGap(16, 16, 16) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
);
.addGroup(layout.createParallelGroup(javax.swing setBounds((screenSize.width-526)/2,
.GroupLayout.Alignment.BASELINE) (screenSize.height-388)/2, 526, 388);
.addComponent(txtSHAddress, }// </editor-fold>
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, private void
javax.swing.GroupLayout.PREFERRED_SIZE) btnBackActionPerformed(java.awt.event.ActionEv
.addComponent(jLabel3)))) ent evt) {
.addGap(18, 18, 18) this.setVisible(false);
new MainMenuUI().setVisible(true);
.addGroup(layout.createParallelGroup(javax.swing }
.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4) private void
.addComponent(txtSHCity, btnSaveActionPerformed(java.awt.event.ActionEv
javax.swing.GroupLayout.PREFERRED_SIZE, ent evt) {
javax.swing.GroupLayout.DEFAULT_SIZE, try {
javax.swing.GroupLayout.PREFERRED_SIZE)) Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
// TODO add your handling code here:
DriverManager.getConnection("jdbc:mysql://local txtSHno.setText("");
host:3306/CARSHOWROOM","root","root"); txtSHName.setText("");
Statement stmt = null; txtSHAddress.setText("");
ResultSet rs = null; // ResultSet for txtSHCity.setText("");
CARSHOWROOM table. txtSHPhone.setText("");
String SQL = "SELECT * FROM }
CARSHOWROOM";
stmt = con.createStatement(); // /**
Connection string for ResultSet - rs. * @param args the command line arguments
rs = stmt.executeQuery(SQL); */
public static void main(String args[]) {
// Data transfer from JTextField control to java.awt.EventQueue.invokeLater(new
variables Runnable() {
String shno = txtSHno.getText().trim(); public void run() {
String shname = txtSHName.getText(); new ShopINUI().setVisible(true);
String shadd = txtSHAddress.getText(); }
String shcity = txtSHCity.getText(); });
double shphone = }
Double.parseDouble(txtSHPhone.getText());
if (shno.length() <= 4) { // Variables declaration - do not modify
String strSQL = "INSERT INTO private javax.swing.JButton btnBack;
CARSHOWROOM(Shopper_id, Name, Address, private javax.swing.JButton btnClear;
City, Phone) VALUES private javax.swing.JButton btnSave;
('"+(shno)+"','"+(shname)+"','"+(shadd)+"','"+(shcit private javax.swing.JLabel jLabel1;
y)+"',"+(shphone)+")"; private javax.swing.JLabel jLabel2;
JOptionPane.showMessageDialog(this, private javax.swing.JLabel jLabel3;
"Record successfully inserted"); private javax.swing.JLabel jLabel4;
int rowsEffected = private javax.swing.JLabel jLabel5;
stmt.executeUpdate(strSQL); private javax.swing.JLabel jLabel6;
System.out.println(rowsEffected + " rows private javax.swing.JTextField txtSHAddress;
effected"); private javax.swing.JTextField txtSHCity;
} private javax.swing.JTextField txtSHName;
else { private javax.swing.JTextField txtSHPhone;
JOptionPane.showMessageDialog(this, private javax.swing.JTextField txtSHno;
"Customer ID should not more than 4 character."); // End of variables declaration
}
con.close(); }
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessa
ge()); *****************************************
e.printStackTrace(); CAR
}
DETAILS********************************
}
*********
btnBack.setFont(new
setDefaultCloseOperation(javax.swing.WindowCon java.awt.Font("Tahoma", 1, 12));
stants.EXIT_ON_CLOSE); btnBack.setText("Back to Main");
setTitle("Sports CARS Entry Form"); btnBack.addActionListener(new
java.awt.event.ActionListener() {
jLabel3.setFont(new java.awt.Font("Tahoma", public void
1, 12)); actionPerformed(java.awt.event.ActionEvent evt) {
jLabel3.setText("CARS Id.:"); btnBackActionPerformed(evt);
}
jLabel1.setFont(new java.awt.Font("Tahoma", });
1, 24));
jLabel1.setText("Sports CARS Entry Form"); txtCARSDesc.setFont(new
java.awt.Font("Tahoma", 1, 12));
txtCARSno.setFont(new
java.awt.Font("Tahoma", 1, 12)); jLabel15.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel15.setText("Description:");
.addComponent(txtCARSName,
jLabel14.setFont(new javax.swing.GroupLayout.DEFAULT_SIZE, 123,
java.awt.Font("Tahoma", 1, 12)); Short.MAX_VALUE)
jLabel14.setText("CARS Name:"); .addGap(81, 81, 81))
.addComponent(txtCARSPrice,
javax.swing.GroupLayout layout = new javax.swing.GroupLayout.PREFERRED_SIZE, 92,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.PREFERRED_SIZE)
getContentPane().setLayout(layout); .addComponent(txtCARSno,
layout.setHorizontalGroup( javax.swing.GroupLayout.PREFERRED_SIZE, 90,
javax.swing.GroupLayout.PREFERRED_SIZE))
layout.createParallelGroup(javax.swing.GroupLayo .addGap(118, 118, 118))
ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TR
.addGap(59, 59, 59) AILING, layout.createSequentialGroup()
.addContainerGap(109,
.addGroup(layout.createParallelGroup(javax.swing Short.MAX_VALUE)
.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1)
.addComponent(jLabel15, .addGap(80, 80, 80))
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, .addGroup(javax.swing.GroupLayout.Alignment.TR
Short.MAX_VALUE) AILING, layout.createSequentialGroup()
.addComponent(jLabel14, .addContainerGap(78, Short.MAX_VALUE)
javax.swing.GroupLayout.Alignment.LEADING, .addComponent(btnSave)
javax.swing.GroupLayout.DEFAULT_SIZE, 73, .addGap(47, 47, 47)
Short.MAX_VALUE) .addComponent(btnBack)
.addGap(48, 48, 48)
.addGroup(layout.createSequentialGroup() .addComponent(btnClear)
.addGap(19, 19, 19) .addGap(64, 64, 64))
.addComponent(jLabel3, );
javax.swing.GroupLayout.DEFAULT_SIZE, layout.setVerticalGroup(
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)) layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27) .addGap(27, 27, 27)
.addComponent(jLabel13, .addComponent(jLabel1)
javax.swing.GroupLayout.DEFAULT_SIZE, 46, .addGap(35, 35, 35)
Short.MAX_VALUE)))
.addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(jLabel3,
.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE, 29,
.addComponent(txtCARSDesc, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE, 204, .addComponent(txtCARSno))
javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18)
.addGroup(javax.swing.GroupLayout.Alignment.TR .addGroup(layout.createParallelGroup(javax.swing
AILING, layout.createSequentialGroup() .GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(txtCARSName)) }
.addGap(21, 21, 21)
private void
.addGroup(layout.createParallelGroup(javax.swing btnSaveActionPerformed(java.awt.event.ActionEv
.GroupLayout.Alignment.BASELINE) ent evt) {
.addComponent(jLabel15) try {
.addComponent(txtCARSDesc, Class.forName("com.mysql.jdbc.Driver");
javax.swing.GroupLayout.PREFERRED_SIZE, Connection con = (Connection)
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) DriverManager.getConnection("jdbc:mysql://local
.addGap(33, 33, 33) host:3306/CARSHOWROOM","root","root");
Statement stmt = null;
.addGroup(layout.createParallelGroup(javax.swing ResultSet rs = null; // ResultSet for
.GroupLayout.Alignment.BASELINE) CARSHOWROOM table.
.addComponent(jLabel13) String SQL = "SELECT * FROM CARS";
.addComponent(txtCARSPrice)) stmt = con.createStatement(); //
.addGap(47, 47, 47) Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING, false) // Data transfer from JTextField control to
.addComponent(btnClear, variables
javax.swing.GroupLayout.DEFAULT_SIZE, String CARSno = txtCARSno.getText();
javax.swing.GroupLayout.DEFAULT_SIZE, String CARSname = txtCARSName.getText();
Short.MAX_VALUE) String desc = txtCARSDesc.getText();
.addComponent(btnBack, double CARSprice =
javax.swing.GroupLayout.DEFAULT_SIZE, Double.parseDouble(txtCARSPrice.getText());
javax.swing.GroupLayout.DEFAULT_SIZE, String strSQL = "INSERT INTO CARS(CARS_Id,
Short.MAX_VALUE) CARS_Name, Description, Price) VALUES
.addComponent(btnSave, ('"+(CARSno)+"','"+(CARSname)+"','"+(desc)+"',"+(C
javax.swing.GroupLayout.PREFERRED_SIZE, 33, ARSprice)+")";
javax.swing.GroupLayout.PREFERRED_SIZE)) JOptionPane.showMessageDialog(this,
.addGap(30, 30, 30)) "Record successfully inserted");
); int rowsEffected =
stmt.executeUpdate(strSQL);
java.awt.Dimension screenSize = System.out.println(rowsEffected + " rows
java.awt.Toolkit.getDefaultToolkit().getScreenSize( effected");
); con.close();
setBounds((screenSize.width-482)/2, } catch (Exception e) {
(screenSize.height-403)/2, 482, 403);
}// </editor-fold> JOptionPane.showMessageDialog(this,e.getMessa
ge());
private void e.printStackTrace();
btnClearActionPerformed(java.awt.event.ActionEv }
ent evt) { }
// TODO add your handling code here:
txtCARSno.setText(""); private void
txtCARSName.setText(""); btnBackActionPerformed(java.awt.event.ActionEv
txtCARSDesc.setText(""); ent evt) {
txtCARSPrice.setText(""); this.setVisible(false);
new MainMenuUI().setVisible(true);
} /** This method is called from within the
constructor to
/** * initialize the form.
* @param args the command line arguments * WARNING: Do NOT modify this code. The
*/ content of this method is
public static void main(String args[]) { * always regenerated by the Form Editor.
java.awt.EventQueue.invokeLater(new */
Runnable() { @SuppressWarnings("unchecked")
public void run() { // <editor-fold defaultstate="collapsed"
new CARSINUI().setVisible(true); desc="Generated Code">
} private void initComponents() {
});
} buttonGroup1 = new
javax.swing.ButtonGroup();
// Variables declaration - do not modify jLabel9 = new javax.swing.JLabel();
private javax.swing.JButton btnBack; txtOrdno = new javax.swing.JTextField();
private javax.swing.JButton btnClear; jLabel2 = new javax.swing.JLabel();
private javax.swing.JButton btnSave; jLabel3 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel1; jLabel4 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel13; btnClear = new javax.swing.JButton();
private javax.swing.JLabel jLabel14; txtOrdDate = new javax.swing.JTextField();
private javax.swing.JLabel jLabel15; txtOrdQty = new javax.swing.JTextField();
private javax.swing.JLabel jLabel3; btnBack = new javax.swing.JButton();
private javax.swing.JTextField txtCARSDesc; jLabel10 = new javax.swing.JLabel();
private javax.swing.JTextField txtCARSName; btnSave = new javax.swing.JButton();
private javax.swing.JTextField txtCARSPrice; jLabel1 = new javax.swing.JLabel();
private javax.swing.JTextField txtCARSno; jLabel8 = new javax.swing.JLabel();
// End of variables declaration txtCARSPrice = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
} jLabel7 = new javax.swing.JLabel();
txtSID = new javax.swing.JTextField();
txtSName = new javax.swing.JTextField();
***************************************** jLabel6 = new javax.swing.JLabel();
ORDER DETAILS txtCARSID = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
UI*************************************** jList1 = new javax.swing.JList();
** jScrollPane2 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
import java.sql.*; jPanel1 = new javax.swing.JPanel();
import javax.swing.DefaultListModel; rdYes = new javax.swing.JRadioButton();
import javax.swing.JOptionPane; rdNo = new javax.swing.JRadioButton();
jLabel11 = new javax.swing.JLabel();
public class OrderINUI extends javax.swing.JFrame txtDisc = new javax.swing.JTextField();
{
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jLabel1) .addComponent(jLabel11)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.Compo .addComponent(txtDisc,
nentPlacement.UNRELATED) javax.swing.GroupLayout.PREFERRED_SIZE, 76,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel3))
.addGap(27, 27, 27)) .addPreferredGap(javax.swing.LayoutStyle.Compo
.addGroup(layout.createSequentialGroup() nentPlacement.RELATED)
.addGap(156, 156, 156)
.addComponent(jLabel10) .addGroup(layout.createParallelGroup(javax.swing
.addContainerGap(175, .GroupLayout.Alignment.LEADING)
Short.MAX_VALUE)) .addComponent(jScrollPane1,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE,
.addGap(68, 68, 68) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(btnSave) javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30) .addComponent(jScrollPane2,
.addComponent(btnBack, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addComponent(btnClear, .addPreferredGap(javax.swing.LayoutStyle.Compo
javax.swing.GroupLayout.PREFERRED_SIZE, 87, nentPlacement.RELATED)
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(144, .addGroup(layout.createParallelGroup(javax.swing
Short.MAX_VALUE)) .GroupLayout.Alignment.LEADING)
);
layout.setVerticalGroup( .addGroup(layout.createSequentialGroup()
layout.createParallelGroup(javax.swing.GroupLayo .addGroup(layout.createParallelGroup(javax.swing
ut.Alignment.LEADING) .GroupLayout.Alignment.BASELINE)
.addGroup(layout.createSequentialGroup() .addComponent(jLabel5)
.addGap(11, 11, 11) .addComponent(txtSID,
.addComponent(jLabel10) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGap(18, 18, 18) javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing .addGap(18, 18, 18)
.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2) .addGroup(layout.createParallelGroup(javax.swing
.addComponent(jLabel1) .GroupLayout.Alignment.BASELINE)
.addComponent(txtOrdno, .addComponent(jLabel7)
javax.swing.GroupLayout.PREFERRED_SIZE, .addComponent(txtSName,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(txtOrdDate, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE, .addGap(30, 30, 30)
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing
.addGap(23, 23, 23) .GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(txtOrdQty,
.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel3) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jLabel4)) javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(btnSave,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(btnBack,
.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 34,
Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup() .addGap(19, 19, 19))
.addComponent(txtCARSID, );
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, java.awt.Dimension screenSize =
javax.swing.GroupLayout.PREFERRED_SIZE) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGap(18, 18, 18) );
setBounds((screenSize.width-633)/2,
.addGroup(layout.createParallelGroup(javax.swing (screenSize.height-529)/2, 633, 529);
.GroupLayout.Alignment.BASELINE) }// </editor-fold>
.addComponent(jLabel8)
.addComponent(txtCARSPrice, private void
javax.swing.GroupLayout.PREFERRED_SIZE, btnClearActionPerformed(java.awt.event.ActionEv
javax.swing.GroupLayout.DEFAULT_SIZE, ent evt) {
javax.swing.GroupLayout.PREFERRED_SIZE))) // TODO add your handling code here:
.addComponent(jLabel6)) txtOrdno.setText("");
txtOrdDate.setText("");
.addPreferredGap(javax.swing.LayoutStyle.Compo txtSID.setText("");
nentPlacement.UNRELATED) txtCARSID.setText("");
.addComponent(jPanel1, txtSName.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE, 43, txtCARSPrice.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE))) txtOrdQty.setText("");
.addGap(18, 18, 18) }
LIST************************************* jButton2.setFont(new
**** java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton2.setText("Back to Menu");
import java.sql.*; jButton2.addActionListener(new
import javax.swing.table.*; java.awt.event.ActionListener() {
import javax.swing.JOptionPane; public void
actionPerformed(java.awt.event.ActionEvent evt) {
public class CustListUI extends javax.swing.JFrame jButton2ActionPerformed(evt);
{ }
});
/** Creates new form CustListUI */
public CustListUI() { jTable1.setModel(new
initComponents(); javax.swing.table.DefaultTableModel(
} new Object [][] {
{null, null, null, null, null},
/** This method is called from within the {null, null, null, null, null},
constructor to {null, null, null, null, null},
* initialize the form. {null, null, null, null, null},
{null, null, null, null, null}, );
{null, null, null, null, null}, layout.setVerticalGroup(
{null, null, null, null, null},
{null, null, null, null, null}, layout.createParallelGroup(javax.swing.GroupLayo
{null, null, null, null, null}, ut.Alignment.LEADING)
{null, null, null, null, null} .addGroup(layout.createSequentialGroup()
}, .addGap(20, 20, 20)
new String [] { .addComponent(jLabel1)
"Customer ID", "Name", "Address", "City", .addGap(18, 18, 18)
"Phone" .addComponent(jScrollPane1,
} javax.swing.GroupLayout.PREFERRED_SIZE, 172,
)); javax.swing.GroupLayout.PREFERRED_SIZE)
jScrollPane1.setViewportView(jTable1); .addGap(35, 35, 35)
setDefaultCloseOperation(javax.swing.WindowCon
***************************************** stants.EXIT_ON_CLOSE);
ORDER
setTitle("List of orders");
LIST*************************************
****
jButton2.setFont(new
import java; java.awt.Font("Tahoma", 1, 11)); // NOI18N
import javax.swing.table.*;
jButton2.setText("Back to Menu");
import java.sql.*;
jButton2.addActionListener(new
import javax.swing.JOptionPane; java.awt.event.ActionListener() {
public class OrdListUI extends javax.swing.JFrame { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
/** Creates new form OrdListUI */
}
public OrdListUI() {
});
initComponents();
}
jButton1.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
/** This method is called from within the jButton1.setText("Display/Query");
constructor to
jButton1.addActionListener(new
* initialize the form. java.awt.event.ActionListener() {
* WARNING: Do NOT modify this code. The public void
content of this method is actionPerformed(java.awt.event.ActionEvent evt) {
* always regenerated by the Form Editor. jButton1ActionPerformed(evt);
*/ }
@SuppressWarnings("unchecked") });
// <editor-fold defaultstate="collapsed"
desc="Generated Code">
jTable1.setModel(new
private void initComponents() { javax.swing.table.DefaultTableModel(
new Object [][] {
.addGroup(layout.createParallelGroup(javax.swing
{null, null, null, null, null, null, null, null}, .GroupLayout.Alignment.LEADING)
));
layout.createParallelGroup(javax.swing.GroupLayo
jScrollPane1.setViewportView(jTable1); ut.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 172,
jLabel1.setFont(new java.awt.Font("Tahoma", javax.swing.GroupLayout.PREFERRED_SIZE)
1, 24)); // NOI18N
.addGap(35, 35, 35)
jLabel1.setText("Order List");
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane()); .addComponent(jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE, 37,
getContentPane().setLayout(layout); javax.swing.GroupLayout.PREFERRED_SIZE)
layout.setHorizontalGroup( .addComponent(jButton2,
javax.swing.GroupLayout.DEFAULT_SIZE, 37,
Short.MAX_VALUE))
layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING) .addGap(27, 27, 27))
.addGroup(layout.createSequentialGroup() );
.addContainerGap()
java.awt.Dimension screenSize = Connection con = (Connection)
java.awt.Toolkit.getDefaultToolkit().getScreenSize( DriverManager.getConnection("jdbc:mysql://local
); host:3306/CARSHOWROOM","root","root");
private void
jButton2ActionPerformed(java.awt.event.ActionEv // Iterate through the result and display on
ent evt) { screen
}
JOptionPane.showMessageDialog(this,
// SQL Query e.getMessage());
String query = "SELECT * FROM orderCARS"; public static void main(String args[]) {
try { java.awt.EventQueue.invokeLater(new
Runnable() {
// Connect to MySQL database
public void run() {
}); }
BIBILOGRAPHY
Writtten by:
2. Oxford 12th IP