-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldCurrency.java
More file actions
67 lines (53 loc) · 1.63 KB
/
WorldCurrency.java
File metadata and controls
67 lines (53 loc) · 1.63 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
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class WorldCurrency extends JFrame {
JTextField taka, usd;
JButton toUSD, reset;
WorldCurrency(String title) {
setTitle(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,200);
JPanel panel = new JPanel();
JLabel l1 = new JLabel("Taka : ");
panel.add(l1);
taka = new JTextField(10);
taka.setText("0.0");
panel.add(taka); // 1 USD = 84.75 Taka;
JLabel l2 = new JLabel("U$D : ");
panel.add(l2);
usd = new JTextField(10);
usd.setText("0.0");
panel.add(usd);
toUSD = new JButton("get U$D value");
reset = new JButton("reset");
panel.add(toUSD);
panel.add(reset);
toUSD.addActionListener(new Inner());
reset.addActionListener(new Inner());
add(panel);
setVisible(true);
}
class Inner implements ActionListener {
@Override
public void actionPerformed(ActionEvent actionEvent)
{
if(actionEvent.getSource() == toUSD) {
String s = taka.getText();
double money = Double.parseDouble(s);
money = money * 84;
s = "" + money;
usd.setText(s);
}
else if(actionEvent.getSource() == reset) {
usd.setText("0.0");
taka.setText("0.0");
}
}
}
//main method
public static void main(String[] args)
{
new WorldCurrency("Currency Converter");
}
}