You are on page 1of 5

import java.awt.

Color;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

public class Main {

public static void Converter() {

JFrame frame;

JLabel l1, l2, l3;

JTextField t1, t2, t3;

JButton b1, b2,b3, b4;

frame = new JFrame("Converter");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

b1 = new JButton("ТЕНГЕ:");

b1.setBounds(30, 30, 100, 25);

b1.setFont(new Font(null, Font.BOLD, 14));

b2 = new JButton("ДОЛЛАР:");

b2.setBounds(30, 80, 100, 25);

b2.setFont(new Font(null, Font.BOLD, 14));

b3 = new JButton("РУБЛЬ:");

b3.setBounds(30, 130, 100, 25);


b3.setFont(new Font(null, Font.BOLD, 14));

b4 = new JButton("ЖОЮ");

b4.setBounds(30, 180, 100, 25);

t1 = new JTextField("0");

t1.setBounds(140, 30, 180, 25);

t1.setFont(new Font(null, Font.BOLD, 14));

t2 = new JTextField("0");

t2.setBounds(140, 80, 180, 25);

t2.setFont(new Font(null, Font.BOLD, 14));

t3 = new JTextField("0");

t3.setBounds(140, 130, 180, 25);

t3.setFont(new Font(null, Font.BOLD, 14));

b1.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

double d = Double.parseDouble(t1.getText());

double d1 = d/445;

double d2 = d/6.2;

String str = String.valueOf(d1);

String str1 = String.valueOf(d2);

t2.setText(str);

t3.setText(str1);

}
});

b2.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

double s = Double.parseDouble(t2.getText());

double s1 = s*445;

double s2 = s*72;

String tenge = String.valueOf(s1);

String rubl = String.valueOf(s2);

t1.setText(tenge);

t3.setText(rubl);

});

b3.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

double a = Double.parseDouble(t3.getText());

double a1 = a*6.2;

double a2 = a/72;

String tenge = String.valueOf(a1);

String dollar = String.valueOf(a2);

t1.setText(tenge);

t2.setText(dollar);

}
});

b4.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

t1.setText("");

t2.setText("");

t3.setText("");

});

frame.add(b1);

frame.add(b2);

frame.add(b3);

frame.add(b4);

frame.add(t1);

frame.add(t2);

frame.add(t3);

frame.setLayout(null);

frame.setSize(450, 320);

frame.getContentPane().setBackground(Color.orange);

frame.setVisible(true);

public static void main(String[] args) {

Converter();

}
}

You might also like