AJP Micro
AJP Micro
Micro-Project Proposal
3.0. Action Plan (Sequence and time required for major activity)
Planned
Sr. Planned Name of Responsible
Details of activity Finish
No. Start Date Team Member
Date
3 Implementing Project
5 Presenting Project
4.0 Resource Required (Major resources such as raw material, some machining facility, software
etc.)
Approved by
1.0. Rationale
Creating a digital clock using Swing in java is an educational and practical exercise that can
enhance your java and GUI programming skills while providing valuable experience in real-
time applications, date and time handling, multithreading and user interface customization
.Its a solid foundation for more advance projects and serves as a demonstration of
programming abilities.
2.0. Aims/Benefits of the Micro-Project
step:
Import Statements:
The program begins with a series of import statements, which bring in the necessary classes
from the Java standard library and Swing library to create a graphical user interface.
Constructor:
The constructor of the MyFrame class is where the GUI is set up and initialized.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE):
This line sets the close operation for the frame, ensuring that the application will exit when
the window is closed.
setTitle("My Clock Program"): Sets the title of the window.
setLayout(new FlowLayout()): Specifies that the layout manager for the frame is a
FlowLayout, which arranges components in a left-to-right, top-to-bottom manner.
setSize(350, 200): Sets the initial size of the window to 350 pixels in width and 200 pixels in
height.
setResizable(false): Disables window resizing, so the user cannot change the size of the
frame.
Labels:
Three JLabel components (timeLabel, dayLabel, and dateLabel) are created to display the
time, day, and date information.
Fonts and colors are set for these labels.
Adding Components:
The labels are added to the frame using the add() method.
Setting Visibility:
setVisible(true): Makes the frame visible on the screen.
setTime() Method:
This method continuously updates the time, day, and date labels with the current values in a
loop, making the digital clock dynamic.
main() Method:
This is the entry point of the program. It creates an instance of the MyFrame class, which
initializes and displays the GUI window with the digital clock.
3 Implementing Project
5 Presenting Project
3 Database Package 01
Java code defines a Swing-based digital clock application. When you run this program, it will
create a graphical window displaying a digital clock with the current time, day of the week,
and date, and it will update this information in real-time.
The output of this code will be a graphical user interface (GUI) window that appears on
screen with the following components:
Time Label: A large label at the top of the window displaying the current time in the format
"hh:mm:ss a" (hours:minutes:seconds AM/PM).
Day Label: A label below the time label that shows the current day of the week (e.g.,
"Monday").
Date Label: Another label below the day label displaying the current date in the format
"Month dd, yyyy" (e.g., "November 07, 2023").
The time, day, and date labels will continuously update in real-time, with the time refreshing
every second.
(A) Process and Product Assessment (Convert above total marks out of 6 Marks)
Literature Review/
2
Information Collection
Quality of
5
Prototype/Model
6 Report Preparation
7 Presentation
(A) Process and Product Assessment (B) Individual Presentation/Viva Total Marks
Calendar calendar;
SimpleDateFormat timeFormat;
SimpleDateFormat dayFormat;
SimpleDateFormat dateFormat;
JLabel timeLabel;
JLabel dayLabel;
JLabel dateLabel;
String time;
String day;
String date;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("My Clock Program");
this.setLayout(new FlowLayout());
this.setSize(350,200);
this.setResizable(false);
this.add(timeLabel);
this.add(dayLabel);
this.add(dateLabel);
this.setVisible(true);
setTime();
}
day = dayFormat.format(Calendar.getInstance().getTime());
dayLabel.setText(day);
date = dateFormat.format(Calendar.getInstance().getTime());
dateLabel.setText(date);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new MyFrame();
}
}