0% found this document useful (0 votes)
23 views

Ajp Suraj1

advance java project

Uploaded by

Suraj Nalawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Ajp Suraj1

advance java project

Uploaded by

Suraj Nalawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

lOMoARcPSD|38973805

Ajeenkya DY Patil School of Engineering (Charholi)Via Lohegaon,


Pune 412 105

Department of Computer Engineering 2024-25 [5th Sem]

Micro Project Report on

Advance Java Programming


On
Online Spectacles Shop

Submitted by:

Roll No. Name Enrolment No.

61 Suraj Nalawade 2216490234

Under the Guidance of


Mrs.Nita Pawar
lOMoARcPSD|38973805

Ajeenkya DY Patil School of Engineering (Charholi) Via Lohegaon,


Pune 412 105

Department of Computer Engineering 2024-25 [5th Sem]


CERTIFICATE

This is to certify that Project report entitled " Online Spectacles Shop" is
submitted in the partial fulfillment of requirement for the award of the Diploma
in Computer Engineering by Maharashtra State Board of Technical Education as
record of student’s own work carried out by them under the guidance and
supervision at Ajeenkya DY Patil School of Engineering (Charholi), during the
academic year 2023-24.

Roll No. Name Enrolment No.


61 Suraj Nalawade 2216490234

Place: Charholi(Bk) Date: / /2024

(Mrs. Nita Pawar) (Mrs. Nita Pawar)


Guide Head of Computer Department
lOMoARcPSD|38973805

ACKNOWLEDGEMEMT

It is with profoundly sense of gratitude that we


acknowledge from our guide Mrs. Mayuri Narudkar She has
been guide in the true sense of word, a guide who satisfaction
from our word & progress.

We are highly obliged to Mrs. Nita Pawar Head of


Computer Department for aberrance & good co-operation
given to us for bringing this project to almost standard.

We are grateful to our principal Dr. Nagesh Shelke for


proceeding acknowledgement to us in the connection of this
project concluding. We appreciate the assistance of all staff
that helps us in for their sincere & obliging help to make our
project Proposal

Micro-Project Report
lOMoARcPSD|38973805

Subject: Advance Java Programming (22517)

Title: Online Spectacles Shop

1. Rationale:

Java technology is widely used for web applications development. Based on the object-
oriented concepts and core Java concepts, this course will equip the students with the required
knowledge and skill of object-oriented programming approach needed for the development of
robust, powerful web applications. Through this course students will get hands-on experience
on GUI Technologies viz. AWT and Swings, event handling mechanisms and network
programming. The course also gives coverage to various web applications aspects like
Database Interaction, server-side components, and servlets.

2. Aim/Benefits of the Micro-Project:

A micro-project helps the students to develop skills specific to collaborative efforts, allowing
students to tackle more complex problems then they could do on their own.

1. Delegate the roles and responsibilities.


2. Share diverse perspectives.
3. Students will develop industry-oriented course outcomes.
4. To develop additional skills integral to the future, such as critical thinking and time
management.

3. Course Outcomes Achieved:

1. Develop programs using GUI Framework (AWT & Swing).


2. Handle events of AWT and Swing components.
3. Develop programs using database.

4. Literature Review:
Swing components are part of the Java Foundation Classes (JFC) library used for creating
graphical user interfaces (GUIs) in Java applications. Swing provides a rich set of
components for building interactive and visually appealing desktop applications. Here are
some key Swing components:

1. JFrame:

`JFrame` is a top-level container that represents the main window of a Java application. It can
hold other Swing components and provides basic functionalities like resizing, minimizing,
and closing the window.
lOMoARcPSD|38973805

2. JPanel:

`JPanel` is a container used to organize components in a smaller area within a `JFrame`. It is


often used to group related components together.

3. JButton:

`JButton` is a component that represents a clickable button. It is widely used for triggering
actions in response to user input.

4. JLabel:

`JLabel` is used for displaying a single line of read-only text or an image. It's often used to
provide descriptions or captions for other components.

5. JTextField:

`JTextField` is a text input component that allows the user to enter and edit a single line of text.

6. JTextArea:

`JTextArea` is a multi-line text input component. It allows the user to enter and edit multiple
lines of text.

7. JCheckBox:

`JCheckBox` is a component that represents a checkbox, which can be checked or unchecked


by the user.

8. JRadioButton:

`JRadioButton` is a component that represents a radio button. It's used in groups where only
one option can be selected at a time.

9. JComboBox:

`JComboBox` is a drop-down list that allows the user to select an item from a list of predefined
options.

10. JList:

`JList` is a component that displays a list of items. Users can select one or more items from the
list.

11. JScrollPane:

`JScrollPane` is a component that provides a scrollable view of another component, such as a


`JTextArea` or `JList`. It is used when the content inside a component is larger than the
visible area.

12. JSlider:
lOMoARcPSD|38973805

`JSlider` is used to allow the user to slide a knob within a bounded interval. It's commonly
used for settings like volume control.

13. JMenuBar, JMenu, JMenuItem:

These components are used to create menus in a Swing application. `JMenuBar` represents a
menu bar, `JMenu` represents a menu, and `JMenuItem` represents an item in a menu.

14. Layout Managers:

Swing provides various layout managers (such as `Flow Layout`, `Border Layout`, `Grid
Layout`, and `Grid BagLayout`) that determine how components are arranged within a
container.

Swing components are part of the Java Standard Edition (SE) platform and provide a
powerful framework for creating desktop applications with rich user interfaces. They allow
developers to create cross-platform applications that can run on any system with Java
support.

5. Actual Methodology Followed –


Sr. Details of Activity Planned Start Planned Name of
No. Date Finish Date Responsible
Team
Members

1. Proposal of Micro Suraj


Project
2. Test Case Suraj

3. Test Plan Suraj

4. Defect Report Suraj

5. Micro Project Report Suraj

6. Actual Resources Used –


Sr. Name of Specifications Quantity Remarks
No Resources
Google Search Engine 1 Available
Chrome Google Docs
1. https://docs.oracle.com/en/java/
2. Microsoft MS. Office 2022 1 Available
Word
lOMoARcPSD|38973805

7. Output of the Microproject:


import java.awt.BorderLayout; import
java.awt.Color; import java.awt.Component;
import java.awt.Dimension; import
java.awt.FlowLayout; import java.awt.Font;
import java.awt.GridLayout; import
java.awt.event.ActionEvent; import
java.awt.event.ActionListener; import
java.awt.event.KeyEvent; import
java.awt.event.KeyListener; import
java.util.ArrayList; import java.util.List;

import javax.swing.BorderFactory; import


javax.swing.Box; import
javax.swing.BoxLayout; import
javax.swing.ImageIcon; import
javax.swing.JButton; import
javax.swing.JFrame; import
javax.swing.JLabel; import
javax.swing.JOptionPane; import
javax.swing.JPanel; import
javax.swing.JScrollPane; import
javax.swing.JTextField; import
javax.swing.SwingConstants; import
javax.swing.SwingUtilities;

public class Micro_Project extends JFrame { public


class SpectacleItem { private String name;
private String imagePath; private int quantity;

public SpectacleItem(String name, String imagePath, int quantity) { this.name = name;


this.imagePath = imagePath; this.quantity = quantity;
}
public String getName() { return name;
}
public String getImagePath() { return
imagePath;
}
public int getQuantity() { return quantity;
}
public void incrementQuantity() { quantity++;
}
}

private final JTextField searchBar;


private final List<JPanel> allSpecListings = new ArrayList<>(); private final
List<SpectacleItem> cartItems = new ArrayList<>(); // New list to store cart items private String
text; private JPanel specListing;

String[][] specs = {{"John Jacobs", "Round", "photos/spectacle1.png"},


{"Vincent Chase", "Cat Eye", "photos/spectacle2.jpeg"}, {"New Balance",
"Clubmaster", "photos/spectacle3.png"}, {"Carrera", "Transparent",
lOMoARcPSD|38973805

"photos/spectacle4.png"}, {"Fossil", "Blend Edit",


"photos/spectacle5.png"}, {"Rhapsody", "Air Clip On",
"photos/spectacle6.jpeg"}, {"Safari", "Air Flex", "photos/spectacle7.png"},
{"Rich Acetate", "Retro Aviator", "photos/spectacle8.jpeg"}};

public Micro_Project() {
setTitle("Online Spectacle Shop"); setBounds(300, 100, 1200,
800);
getContentPane().setBackground(new Color(152, 115, 172)); setLayout(new
BorderLayout());

JPanel specPanel = new JPanel(); specPanel.setLayout(new GridLayout(0,


3)); specPanel.setBackground(Color.LIGHT_GRAY);

for (int i = 0; i < specs.length; i++) { for (int j = 0; j <


specs[i].length; j++) { System.out.println(specs[i][j]);
specListing = createSpecListing(specs[i][0], specs[i][1], specs[i][2]); }
specPanel.add(specListing); allSpecListings.add(specListing);
}

JScrollPane bookScrollPane = new JScrollPane(specPanel);

JPanel searchPanel = new JPanel(); searchPanel.setOpaque(false);


searchPanel.setLayout(new BoxLayout(searchPanel,
BoxLayout.Y_AXIS));

JLabel titleLabel = new JLabel("SPECTACLE SHOP"); titleLabel.setFont(new


Font("Product Sans", Font.BOLD, 30)); titleLabel.setForeground(Color.WHITE);
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
searchPanel.add(titleLabel);

JPanel searchBarPanel = new JPanel(); searchBarPanel.setOpaque(false);


searchBarPanel.setLayout(new BoxLayout(searchBarPanel,
BoxLayout.X_AXIS));

searchBar = new JTextField(20);


searchBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); searchBar.setFont(new
Font("Product Sans", Font.PLAIN, 16)); searchBar.setPreferredSize(new Dimension(20, 40));
searchBar.setBackground(new Color(255, 255, 255));
searchBar.setForeground(Color.BLACK);

searchBar.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}

@Override
public void keyPressed(KeyEvent e) { text =
searchBar.getText(); System.out.println(text);
}
lOMoARcPSD|38973805

@Override
public void keyReleased(KeyEvent e) {
}
});

Component rigidSpace = Box.createRigidArea(new Dimension(10, 0));


JButton searchButton = new JButton("Search");
searchButton.setBackground(Color.WHITE); searchButton.setForeground(Color.BLACK);
searchButton.setPreferredSize(new Dimension(120, 40));
searchButton.setBorderPainted(false);

searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { String query =
text.toLowerCase(); for (JPanel bookListing : allSpecListings) {
String title = ((JLabel) ((JPanel)
bookListing.getComponent(1)).getComponent(0)).getText().toLowerCase();
bookListing.setVisible(title.contains(query));
}
System.out.println(query);
}
});

JButton cartButton = new JButton("Cart"); cartButton.setBackground(Color.WHITE);


cartButton.setForeground(Color.BLACK); cartButton.setPreferredSize(new Dimension(120,
40)); cartButton.setBorderPainted(false);

cartButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Show the CartDisplayScreen with the cart items.
new CartDisplayScreen(cartItems);
}
});

searchBarPanel.add(searchButton); searchBarPanel.add(rigidSpace);
searchBarPanel.add(cartButton); // Add the cart button searchPanel.add(searchBarPanel);

add(searchPanel, BorderLayout.NORTH); add(bookScrollPane,


BorderLayout.CENTER);

setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private JPanel createSpecListing(String title, String description,
String imageName) {
JPanel specsListing = new JPanel(); specsListing.setBackground(Color.WHITE);
specsListing.setLayout(new BorderLayout());

ImageIcon specImage = new ImageIcon(Micro_Project.class.getResource(imageName));


lOMoARcPSD|38973805

JLabel imageLabel = new JLabel(specImage); specsListing.add(imageLabel,


BorderLayout.NORTH);

JPanel detailsPanel = new JPanel(new BorderLayout()); JLabel titleLabel = new


JLabel(title, SwingConstants.CENTER); titleLabel.setFont(new Font("Product Sans",
Font.BOLD, 14));
detailsPanel.add(titleLabel, BorderLayout.NORTH);

JLabel descriptionArea = new JLabel(description, SwingConstants.CENTER);


descriptionArea.setOpaque(false); descriptionArea.setFocusable(false);
detailsPanel.add(descriptionArea, BorderLayout.CENTER);

JPanel buttonsPanel = new JPanel(new FlowLayout());


JButton buyButton = new JButton("Buy Now");
JButton addToCartButton = new JButton("Add to Cart");
JButton addToWishlistButton = new JButton("Add to Wishlist");

buyButton.setBackground(Color.WHITE); buyButton.setBorderPainted(false);
addToCartButton.setBackground(Color.WHITE); addToCartButton.setBorderPainted(false);
addToWishlistButton.setBackground(Color.WHITE);
addToWishlistButton.setBorderPainted(false);

addToCartButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { // Check if the spectacle
is already in the cart. SpectacleItem existingItem = findCartItem(title);
if (existingItem != null) {
// If it’s in the cart, increment the quantity.
existingItem.incrementQuantity();
} else {
// If it’s not in the cart, add it as a new item with quantity 1.
cartItems.add(new SpectacleItem(title, imageName, 1));
}
JOptionPane.showMessageDialog(Micro_Project.this, "Added to
Cart: " + title);
}
});

buyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(Micro_Project.this, "Button
Clicked: Buy Now");
}
});

addToWishlistButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(Micro_Project.this, "Button
Clicked: Add To Wishlist");
lOMoARcPSD|38973805

}
});

buttonsPanel.add(buyButton); buttonsPanel.add(addToCartButton);
buttonsPanel.add(addToWishlistButton);

specsListing.add(detailsPanel, BorderLayout.CENTER); specsListing.add(buttonsPanel,


BorderLayout.SOUTH);

return specsListing;
}
private SpectacleItem findCartItem(String name) { for
(SpectacleItem item : cartItems) { if
(item.getName().equals(name)) { return item;
} }
return null;
}

public class CartDisplayScreen extends JFrame {


public CartDisplayScreen(List<SpectacleItem> cartItems) { Component rigidSpace =
Box.createRigidArea(new Dimension(10,
0));
setTitle("Cart Display");
setBounds(400, 200, 800, 600); // Adjust the frame size to accommodate images.
getContentPane().setBackground(Color.WHITE); setLayout(new BorderLayout());

JLabel titleLabel = new JLabel("Cart Items:"); titleLabel.setFont(new Font("Product


Sans", Font.BOLD, 20)); titleLabel.setHorizontalAlignment(SwingConstants.CENTER);

JPanel itemListPanel = new JPanel();


itemListPanel.setLayout(new GridLayout(0, 1)); // Two columns for text and images.

for (SpectacleItem item : cartItems) { JPanel itemPanel =


new JPanel(new FlowLayout(FlowLayout.LEFT)); // Adjust layout here.

// Change the background color of the item panel.


itemPanel.setBackground(new Color(210, 210, 210)); // Set the desired background color.

// Add an image label for the item to the left.


ImageIcon itemImage = new
ImageIcon(Micro_Project.class.getResource(item.getImagePath()));
JLabel imageLabel = new JLabel(itemImage);
JLabel itemLabel = new JLabel(item.getName()); itemLabel.setFont(new
Font("Product Sans", Font.PLAIN, 16));

JLabel quantityLabel = new JLabel("Quantity: " + item.getQuantity());


quantityLabel.setFont(new Font("Product Sans", Font.PLAIN, 16));
itemPanel.add(imageLabel); itemPanel.add(itemLabel);
itemPanel.add(rigidSpace); itemPanel.add(quantityLabel);
itemListPanel.add(itemPanel);
}
lOMoARcPSD|38973805

JScrollPane scrollPane = new JScrollPane(itemListPanel);

add(titleLabel, BorderLayout.NORTH); add(scrollPane,


BorderLayout.CENTER);

setVisible(true);
}
}
public class CartScreen extends JFrame { private String
selectedSpectacleName;

public CartScreen(String spectacleName) {


this.selectedSpectacleName = spectacleName; setTitle("Cart");
setBounds(400, 200, 400, 300);
getContentPane().setBackground(Color.WHITE); setLayout(new
BorderLayout());

JLabel titleLabel = new JLabel("Selected Spectacle: " + selectedSpectacleName);


titleLabel.setFont(new Font("Product Sans", Font.BOLD, 20));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);

JButton addToCartButton = new JButton("Add to Cart");


addToCartButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Add the selected spectacle to the cart (you can implement cart functionality here).
JOptionPane.showMessageDialog(CartScreen.this, "Added to Cart: " +
selectedSpectacleName);
}
});

JPanel panel = new JPanel(); panel.setLayout(new FlowLayout());


panel.add(addToCartButton);

add(titleLabel, BorderLayout.NORTH); add(panel,


BorderLayout.CENTER);

setVisible(true);
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(Micro_Project::new);
}
}
lOMoARcPSD|38973805
lOMoARcPSD|38973805
lOMoARcPSD|38973805

8. Skills Developed/Leaning Outcome:


¥ Familiarity with Swing components and their functionality.
¥ Ability to handle user interactions and events triggered by Swing components.
¥ Knowledge of different layout managers for arranging Swing components with
containers effectively.
¥ Skills in creating visually appealing and user-friendly interfaces using Swing
components.

9. Applications of Micro-Project:

¥ Develop interactive and user-friendly desktop applications for various purposes.


¥ Design tools to visualize data using charts, graphs, and other graphical representations
for data analysis and decision – making.
¥ Create utilities such as calculators, file managers, or image editors with graphical
interfaces for improved user experience.

10. Conclusion:
In conclusion, the completion of our advanced Java programming project, where we utilized
Swing components to design an online spectacles shop, marks a significant milestone in our
journey. Through meticulous design and implementation, we have created a seamless and
visually appealing platform that enhances the online shopping experience for customers
seeking eyewear. Leveraging the power of Swing components, we have crafted an intuitive
user interface, integrating features such as product catalogues, interactive image galleries,
shopping cart functionality, and secure payment gateways. Our project not only demonstrates
our mastery of Java programming but also showcases our ability to apply advanced concepts
in graphical user interface development. The successful implementation of this online
spectacles shop underscores our proficiency in both backend and frontend technologies,
setting the stage for future innovative projects in the realm of advanced Java programming
and usercentric application design.

11. Bibliography

¥ Complete Java Reference – Schildt, Herbet


¥ Java 2 Programming Black Book – Holzner, Steven et al.
¥ Java Server Programming Tutorial JAVA EE6 Black Book – Kogent Learning
Solutions.

Mrs. Nita pawar


(Subject Teacher)

You might also like