Car Showroom Project File
Car Showroom Project File
Car Showroom Project File
A PROJECT ON
Submitted By : Submitted To :
Name : Name :
Date : Date :
Roll No : ………………………….
Address : ………………………….
………………………….
Phone No : ………………………….
Supervisor : ………………………….
Student Name
Introduction
Java Details
Priliminary Design
Form Layouts
Database Design
Implementation
Bibliography
Teacher Remarks
project.
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 upgrades made in operating systems,
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.
Portable- Java compiler generates bytecode instructions that can be implemented on any
machine and also the size of the primitive data types are machine independent.
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.
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
CAR SHOWROOM SYSTEM | Created by : Student Name
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
behavior Classes can also define class variables. A class variable contains information that is
CAR SHOWROOM SYSTEM | Created by : Student Name
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.
Advantages of JDBC Technology :
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
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.
● 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.
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.
Class.forName("java.sql.Driver");
.addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.UNRELATED)
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);
mnuCARSAdd.setText("CARS Entry");
mnuCARSAdd.addActionListener(new ListCARS.setFont(new java.awt.Font("Segoe
java.awt.event.ActionListener() { UI", 1, 14)); // NOI18N
public void ListCARS.setText("CARS List");
actionPerformed(java.awt.event.ActionEvent evt) { ListCARS.addActionListener(new
mnuCARSAddActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1.add(mnuCARSAdd); ListCARSActionPerformed(evt);
}
mnuOrder.setFont(new java.awt.Font("Segoe });
UI", 1, 14)); // NOI18N jMenu2.add(ListCARS);
.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);
} }
});
jMenu3.add(jMenuCARS1); private void
mnuCARSAddActionPerformed(java.awt.event.Acti
jMenuBar1.add(jMenu3); onEvent evt) {
this.setVisible(false);
setJMenuBar(jMenuBar1); new CARSINUI().setVisible(true);
}
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane()); private void
getContentPane().setLayout(layout); mnuOrderActionPerformed(java.awt.event.Action
layout.setHorizontalGroup( Event evt) {
private void }
ListOrderActionPerformed(java.awt.event.ActionE
vent evt) {
this.setVisible(false); *****************************************
new OrdListUI().setVisible(true); CUSTOMER DETAILS
*****************************************
}
import java.sql.*;
private void import javax.swing.JOptionPane;
jMenu3ActionPerformed(java.awt.event.ActionEve
nt evt) { public class ShopINUI extends javax.swing.JFrame {
// TODO add your handling code here:
/** Creates new form ShopINUI */
} public ShopINUI() {
initComponents();
private void }
jMenuCARS1ActionPerformed(java.awt.event.Acti
onEvent evt) {
.addGroup(layout.createParallelGroup(javax.swing layout.createParallelGroup(javax.swing.GroupLayo
.GroupLayout.Alignment.LEADING) ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel6)
private void
.addGroup(layout.createParallelGroup(javax.swing
btnSaveActionPerformed(java.awt.event.ActionEv
.GroupLayout.Alignment.BASELINE)
ent evt) {
.addComponent(jLabel4)
try {
.addComponent(txtSHCity,
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
host:3306/CARSHOWROOM","root","root");
.addPreferredGap(javax.swing.LayoutStyle.Compo
Statement stmt = null;
nentPlacement.UNRELATED)
ResultSet rs = null; // ResultSet for
CARSHOWROOM table.
.addGroup(layout.createParallelGroup(javax.swing String SQL = "SELECT * FROM
.GroupLayout.Alignment.BASELINE) CARSHOWROOM";
.addComponent(jLabel5) stmt = con.createStatement(); //
.addComponent(txtSHPhone, Connection string for ResultSet - rs.
javax.swing.GroupLayout.PREFERRED_SIZE,
JOptionPane.showMessageDialog(this,e.getMessa
*****************************************
ge());
e.printStackTrace(); CAR DETAILS
} *****************************************
}
import java.sql.*;
private void import javax.swing.JOptionPane;
btnClearActionPerformed(java.awt.event.ActionEv
ent evt) { public class CARSINUI extends javax.swing.JFrame {
// TODO add your handling code here:
txtSHno.setText(""); /** Creates new form CARSINUI */
txtSHName.setText(""); public CARSINUI() {
txtSHAddress.setText(""); initComponents();
txtSHCity.setText(""); }
txtSHPhone.setText("");
} /** 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
* always regenerated by the Form Editor.
txtCARSno.setFont(new jLabel15.setFont(new
java.awt.Font("Tahoma", 1, 12)); java.awt.Font("Tahoma", 1, 12));
jLabel15.setText("Description:");
txtCARSName.setFont(new
java.awt.Font("Tahoma", 1, 12)); jLabel14.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel13.setFont(new jLabel14.setText("CARS Name:");
java.awt.Font("Tahoma", 1, 12));
jLabel13.setText("Price:"); javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
btnClear.setFont(new getContentPane().setLayout(layout);
java.awt.Font("Tahoma", 1, 12)); layout.setHorizontalGroup(
btnClear.setText("Clear");
btnClear.addActionListener(new layout.createParallelGroup(javax.swing.GroupLayo
java.awt.event.ActionListener() { ut.Alignment.LEADING)
public void .addGroup(layout.createSequentialGroup()
actionPerformed(java.awt.event.ActionEvent evt) { .addGap(59, 59, 59)
.addGroup(javax.swing.GroupLayout.Alignment.TR .addGroup(layout.createParallelGroup(javax.swing
AILING, layout.createSequentialGroup() .GroupLayout.Alignment.BASELINE)
.addComponent(txtCARSName, .addComponent(jLabel14)
javax.swing.GroupLayout.DEFAULT_SIZE, 123, .addComponent(txtCARSName))
Short.MAX_VALUE) .addGap(21, 21, 21)
.addGap(81, 81, 81))
.addComponent(txtCARSPrice, .addGroup(layout.createParallelGroup(javax.swing
javax.swing.GroupLayout.PREFERRED_SIZE, 92, .GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)
.addComponent(txtCARSno, .addComponent(txtCARSDesc,
javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(118, 118, 118)) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(javax.swing.GroupLayout.Alignment.TR
AILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)
jPanel1Layout.createParallelGroup(javax.swing.Gr .addGroup(layout.createParallelGroup(javax.swing
oupLayout.Alignment.LEADING) .GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(13, 13, 13)
.addGroup(jPanel1Layout.createParallelGroup(java .addComponent(txtSID,
x.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.PREFERRED_SIZE, 88,
.addComponent(rdYes) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(rdNo))
.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,
.addComponent(txtOrdno, javax.swing.GroupLayout.PREFERRED_SIZE))))
javax.swing.GroupLayout.PREFERRED_SIZE, 62, .addComponent(jLabel3))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27))
.addComponent(jScrollPane1, .addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE, 203, .addGap(156, 156, 156)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel10)
.addGap(119, 119, 119) .addContainerGap(175,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing
.addGap(68, 68, 68)
.GroupLayout.Alignment.LEADING)
.addComponent(btnSave)
.addGap(30, 30, 30)
.addGroup(layout.createSequentialGroup()
.addComponent(btnBack,
.addComponent(jLabel2)
javax.swing.GroupLayout.PREFERRED_SIZE, 163,
.addGap(18, 18, 18)
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtOrdDate,
.addGap(26, 26, 26)
javax.swing.GroupLayout.PREFERRED_SIZE, 112,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING) .GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(txtCARSID,
javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(18, 18, 18)
javax.swing.GroupLayout.PREFERRED_SIZE))
DefaultTableModel model =
.addGroup(layout.createSequentialGroup()
(DefaultTableModel) jTable1.getModel();
.addGap(161, 161, 161)
// Clear the existing table
.addComponent(jButton1)
int rows = model.getRowCount();
.addGap(39, 39, 39)
if (rows > 0) {
.addComponent(jButton2)))))
for (int i = 0; i < rows; i++) {
.addContainerGap())
model.removeRow(0);
);
}
layout.setVerticalGroup(
}
// SQL Query
layout.createParallelGroup(javax.swing.GroupLayo String query = "SELECT * FROM
ut.Alignment.LEADING) CARSHOWROOM";
.addGroup(layout.createSequentialGroup() try {
.addGap(20, 20, 20) // Connect to MySQL database
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jScrollPane1,
Class.forName("com.mysql.jdbc.Driver").newInsta
javax.swing.GroupLayout.PREFERRED_SIZE, 172,
nce();
javax.swing.GroupLayout.PREFERRED_SIZE)
Connection con = (Connection)
.addGap(35, 35, 35)
DriverManager.getConnection("jdbc:mysql://local
jTable1.setModel(new
jButton2 = new javax.swing.JButton(); javax.swing.table.DefaultTableModel(
jButton1 = new javax.swing.JButton(); new Object [][] {
jScrollPane1 = new javax.swing.JScrollPane(); {null, null, null, null, null, null, null, null},
jTable1 = new javax.swing.JTable(); {null, null, null, null, null, null, null, null},
jLabel1 = new javax.swing.JLabel(); {null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null}, .addGap(70, 70, 70)
}
layout.createParallelGroup(javax.swing.GroupLayo
));
ut.Alignment.LEADING)
jScrollPane1.setViewportView(jTable1);
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 172,
javax.swing.GroupLayout.PREFERRED_SIZE)
jLabel1.setFont(new java.awt.Font("Tahoma",
1, 24)); // NOI18N .addGap(35, 35, 35)
jLabel1.setText("Order List");
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
.addContainerGap()
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGroup(layout.createParallelGroup(javax.swing );
.GroupLayout.Alignment.LEADING)
setBounds((screenSize.width-624)/2,
.addComponent(jScrollPane1, (screenSize.height-393)/2, 624, 393);
javax.swing.GroupLayout.DEFAULT_SIZE, 588,
Short.MAX_VALUE) }// </editor-fold>
Class.forName("com.mysql.jdbc.Driver").newInsta });
nce();
}
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local private javax.swing.JLabel jLabel1;
host:3306/CARSHOWROOM","root","root");
private javax.swing.JScrollPane jScrollPane1;
// Create SQL statement and execute query.
private javax.swing.JTable jTable1;
Statement stmt = con.createStatement();
// End of variables declaration
ResultSet rs = stmt.executeQuery(query);
}
// Iterate through the result and display on
screen
2. Oxford 12th IP