-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeed Tracker.java
More file actions
117 lines (107 loc) · 3.08 KB
/
Copy pathSpeed Tracker.java
File metadata and controls
117 lines (107 loc) · 3.08 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class speed extends JFrame
{
int x=0;
speed()
{
velocity();
}
public void velocity()
{
setBounds(300,200 ,300,200 );
setTitle("Speed Tracker");
//setResizable(true);
ImageIcon icon=new ImageIcon("photo.jpg");
setIconImage(icon.getImage());
Container c;
c=this.getContentPane();
c.setLayout(null);
c.setBackground(Color.LIGHT_GRAY);
Font f=new Font("Times New Roamn",Font.BOLD,25);
Font g=new Font("Times New Roamn",Font.BOLD,15);
Font ff=new Font("Times New Roman",Font.BOLD,10);
JLabel lb=new JLabel("00");
lb.setBounds(130,20,140,50);
lb.setFont(f);
c.add(lb);
JButton minus=new JButton("(-)");
minus.setBounds(50,80,60,25);
minus.setFont(g);
minus.setToolTipText("It will decrease the speed");
c.add(minus);
JButton reset=new JButton("Reset");
reset.setBounds(110,80,60,25);
reset.setFont(ff);
reset.setToolTipText("It will set the speed 0");
c.add(reset);
JButton plus=new JButton("(+)");
plus.setBounds(170,80,60,25);
plus.setFont(g);
plus.setToolTipText("It will increase the speed");
c.add(plus);
minus.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(x==0)
{
JOptionPane.showMessageDialog(null,"Your Speed is already minimum value");
}
else
{
x=x-1;
String s="";
if(x<10)
{
s="0";
}
else
{
s="";
}
lb.setText(s+Integer.toString(x));
}
}
});
plus.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(x==50)
{
JOptionPane.showMessageDialog(null,"Your Speed is already maximum value");
}
else
{
x=x+1;
String s="";
if(x<10)
{
s="0";
}
else
{
s="";
}
lb.setText(s+Integer.toString(x));
}
}
});
reset.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
lb.setText("00");
x=0;
}
});
}
public static void main(String[] args)
{
speed sp=new speed();
sp.setVisible(true);
sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}