-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.java
74 lines (63 loc) · 1.77 KB
/
Project.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Digital Clock Project
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.awt.*;
class Project extends JFrame
{
Project(String Title)
{
super(Title);
}
JLabel l1, l2;
SimpleDateFormat d1, d2;
void setComponents()
{
l1 = new JLabel();
l2 = new JLabel();
l1.setFont(new Font("Verdana", Font.BOLD, 40));
l2.setFont(new Font("Verdana", Font.BOLD, 40));
Color c = Color.RED;
Color c1 = c.brighter();
l1.setForeground(c1);
l2.setForeground(c1);
l1.setBackground(Color.BLACK);
l2.setBackground(Color.BLACK);
l1.setOpaque(true);
l2.setOpaque(true);
setLayout(null);
add(l1);
add(l2);
l1.setBounds(50,50,290,100);
l2.setBounds(70,250,220,100);
d1 = new SimpleDateFormat("hh:mm:ss a");
d2 = new SimpleDateFormat("EEEEE");
String time = d1.format(Calendar.getInstance().getTime());
l1.setText(time);
String day = d2.format(Calendar.getInstance().getTime());
l2.setText(day);
while(true)
{
time = d1.format(Calendar.getInstance().getTime());
l1.setText(time);
day = d2.format(Calendar.getInstance().getTime());
l2.setText(day);
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
public static void main(String[] args)
{
Project pj = new Project("Digital Clock");
pj.setVisible(true);
pj.setSize(500,500);
pj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pj.setComponents();
}
}