Ajp MP
Ajp MP
MICRO PROJECT
Academic year: 2024-2025
Certificate
Seal Of
Institution
Annexure - I
Sr.
Name of resources/Material Specifications Qty
No.
Processor: i3
1. Computer 1
RAM : 4.00 GB
2. Microsoft Word Word -2016 1
3. Printer Hp Laser Jet 1
https://www.academia.edu 1
4. Book/ website name
6.0 Name of Team Members with Roll No:
03 1948 Om Patil
1.0 Rationale: The rationale behind the Quiz Application like is to ensure the reliability, security, and functionality
of its core features. With millions of daily users, even minor glitches can result in significant user dissatisfaction
and data breaches. By developing comprehensive test cases, testers can identify potential bugs and performance
issues early. This not only improves user experience but also safeguards sensitive information. Effective testing
helps the platform maintain its competitive edge in a fast-evolving digital environment.
2 Literature Survey .
Information Collection
3 Completion of the
Target as per project
proposal
4 Analysis of Data and
representation
5 Quality of Prototype
/Model/Content
6 Report Preparation
(B) Individual Presentation/Viva Out of 4
7 Presentation
8 Viva
PAG
SR CONTENT E NO.
NO
.
6. Acknowledgement 20
Usage in Project:
1. Frame Setup: Your JFrame setup for each main class (e.g., Login, Quiz,
Rules, Score) relies on AWT to manage the overall window where
components are displayed.
2. Button and Label Customization: You define and style elements such as
JButton and JLabel for functionality and visual presentation. AWT allows
these buttons and labels to have specific properties for color, size, and fonts.
3. Event Handling: The use of ActionListener for button clicks (start, next,
back, etc.) leverages AWT’s event-handling mechanisms, enabling interactive
behavior for the user.
4. Graphics: In the Quiz class, AWT’s Graphics object handles custom drawing,
like displaying the timer countdown and "Times up" message.
5. Image Handling: AWT is used in scaling images and displaying them in your
frames. The Image and ImageIcon objects facilitate loading, scaling, and
rendering images within your application.
Swing:
• Swing is a Java GUI toolkit that extends AWT, offering more advanced and flexible
components.
• Unlike AWT, Swing is platform-independent and provides lightweight components,
meaning it doesn't rely on the native system’s GUI.
• It includes components like JFrame, JPanel, JButton, JTextField, and JTextArea.
Usage in Project:
1. Component Creation:
JFrame: Each main window, such as Login, Quiz, Rules, and Score, extends
JFrame, which serves as the main container for adding and arranging GUI
components.
JLabel: Used extensively for displaying static text, instructions, headings, and quiz
questions. The JLabel component provides options for text styling, positioning, and
alignment.
JButton: Buttons like "Next," "Submit," "Play Again," and "Start" are built with
JButton. These enable user interaction, each button being configured to trigger
different actions and events based on user choices.
JRadioButton: Used for the multiple-choice options in the Quiz class, allowing
users to select one answer per question. JRadioButton provides a clean, easy-to-
understand layout for multiple-choice selections.
ButtonGroup: To group JRadioButton options together so only one selection can be
made at a time.
2. Layout and Styling:
Swing components allow for customization of fonts, colors, and layout positioning.
Components like JLabel, JButton, and JRadioButton are styled to improve
readability and visual appeal.
3. Event Handling:
Through ActionListener, Swing’s event-handling framework allows buttons and
other interactive elements to respond to user actions, such as moving to the next
question, using a lifeline, or submitting the quiz. Each button click initiates logic
based on user input.
4. Containers and Hierarchy:
The layout of components in JFrame allows you to create different sections (like the
quiz question area, options, and navigation buttons). Swing’s getContentPane() lets
you set backgrounds and layout options directly in the container.
5. User Interaction:
Swing components in combination (e.g., JRadioButton with ButtonGroup, JButton
with ActionListener) allow for a responsive and interactive user experience. They
create a seamless workflow for users, from the login to the quiz and the final scoring
page.
Event:
package quiz.application;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Login extends JFrame implements ActionListener{
JButton rules, back;
JTextField tfname;
Login() {
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setSize(1200, 500);
setLocation(200, 150);
setVisible(true);
}
package quiz.application;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Quiz extends JFrame implements ActionListener {
String questions[][] = new String[10][5];
String answers[][] = new String[10][2];
String useranswers[][] = new String[10][1];
JLabel qno, question;
JRadioButton opt1, opt2, opt3, opt4;
ButtonGroup groupoptions;
JButton next, submit, lifeline;
String name;
Quiz(String name) {
this.name = name;
setBounds(50, 0, 1440, 850);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
questions[0][0] = "Which is used to find and fix bugs in the Java programs.?";
questions[0][1] = "JVM";
questions[0][2] = "JDB";
questions[0][3] = "JDK";
questions[0][4] = "JRE";
questions[1][0] = "What is the return type of the hashCode() method in the Object class?";
questions[1][1] = "int";
questions[1][2] = "Object";
questions[1][3] = "long";
questions[1][4] = "void";
questions[4][0] = "In which memory a String is stored, when we create a string using new operator?";
questions[4][1] = "Stack";
questions[4][2] = "String memory";
questions[4][3] = "Random storage space";
questions[4][4] = "Heap memory";
questions[9][0] = "Which of the following option leads to the portability and security of Java?";
questions[9][1] = "Bytecode is executed by JVM";
questions[9][2] = "The applet makes the Java code secure and portable";
questions[9][3] = "Use of exception handling";
questions[9][4] = "Dynamic binding between objects";
answers[0][1] = "JDB";
answers[1][1] = "int";
answers[2][1] = "java.util package";
answers[3][1] = "Marker Interface";
answers[4][1] = "Heap memory";
answers[5][1] = "Remote interface";
answers[6][1] = "import";
answers[7][1] = "Java Archive";
answers[8][1] = "java.lang.StringBuilder";
answers[9][1] = "Bytecode is executed by JVM";
start(count);
setVisible(true);
}
ans_given = 1;
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] = groupoptions.getSelection().getActionCommand();
}
if (count == 8) {
next.setEnabled(false);
submit.setEnabled(true);
}
count++;
start(count);
} else if (ae.getSource() == lifeline) {
if (count == 2 || count == 4 || count == 6 || count == 8 || count == 9) {
opt2.setEnabled(false);
opt3.setEnabled(false);
} else {
opt1.setEnabled(false);
opt4.setEnabled(false);
}
lifeline.setEnabled(false);
} else if (ae.getSource() == submit) {
ans_given = 1;
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] = groupoptions.getSelection().getActionCommand();
}
if (timer > 0) {
g.drawString(time, 1100, 500);
} else {
g.drawString("Times up!!", 1100, 500);
}
timer--; // 14
try {
Thread.sleep(1000);
repaint();
} catch (Exception e) {
e.printStackTrace();
}
if (ans_given == 1) {
ans_given = 0;
timer = 15;
} else if (timer < 0) {
timer = 15;
opt1.setEnabled(true);
opt2.setEnabled(true);
opt3.setEnabled(true);
opt4.setEnabled(true);
if (count == 8) {
next.setEnabled(false);
submit.setEnabled(true);
}
if (count == 9) { // submit button
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] = groupoptions.getSelection().getActionCommand();
}
opt2.setText(questions[count][2]);
opt2.setActionCommand(questions[count][2]);
opt3.setText(questions[count][3]);
opt3.setActionCommand(questions[count][3]);
opt4.setText(questions[count][4]);
opt4.setActionCommand(questions[count][4]);
groupoptions.clearSelection();
}
public static void main(String[] args) {
new Quiz("User");
}
}
Rules(String name) {
this.name = name;
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setSize(800, 650);
setLocation(350, 100);
setVisible(true);
}
JLabel heading = new JLabel("Thankyou " + name + " for playing Simple Minds");
heading.setBounds(45, 30, 700, 30);
heading.setFont(new Font("Tahoma", Font.PLAIN, 26));
add(heading);
setVisible(true);
}
We would like to express our special thanks or gratitude to our professor Mr. Rajesh
Garud for guiding and supporting us in completing the microproject. His advice helped
us tremendously all the time. We are deeply indebted to him as without her constructive
feedback their project would not have been a success.
Also, profound gratitude towards all group’s members without their kind support it
would not have been possible for completion of their microproject. We could learn a lot
of things through their microproject. Once again, we all those who have encouraged and
helped us in preparing their microproject
Conclusion:
The Java Chat Application effectively demonstrates real-time communication
between multiple clients and a server using socket programming. It features a
user-friendly graphical interface built with Swing and AWT, allowing users to
send and receive messages seamlessly. The server broadcasts messages to all
connected clients, ensuring synchronized communication. This project
showcases essential concepts in Java programming, GUI development, and
networking, serving as a solid foundation for future enhancements like user
authentication or multimedia support. Overall, it highlights the potential for
building interactive applications in Java.
Reference:
1. https://www.geeksforgeeks.org/
2. https://en.wikipedia.org/