Dr. GÜRAY SONUGÜR

Dr. Öğr. Üyesi Güray SONUGÜR – Öğrenci Bilgi Paylaşım Platformu

Oto Fiyat Hesaplama

 

Oto Fiyat

Oto Fiyat

 

 

 

 

 

 

 

 

 

 

 

 

 

import java.awt.EventQueue;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import javax.swing.UIManager;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ButtonGroup;
import java.awt.Color;
import java.awt.Font;
public class OtoFiyat {

private JFrame frmOtoFiyatHesaplama;
private JTextField txtKurDegeri;
private JTextField txtDeger;
private final ButtonGroup buttonGroup = new ButtonGroup();
private JTextField txtKDKurDegeri;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
OtoFiyat window = new OtoFiyat();
window.frmOtoFiyatHesaplama.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public OtoFiyat() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmOtoFiyatHesaplama = new JFrame();
frmOtoFiyatHesaplama.getContentPane().setLocation(-195, -60);
frmOtoFiyatHesaplama.setTitle(“Oto Fiyat Hesaplama”);
frmOtoFiyatHesaplama.setBounds(100, 100, 364, 393);
frmOtoFiyatHesaplama.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmOtoFiyatHesaplama.getContentPane().setLayout(null);

JLabel lblTip = new JLabel(“Tip”);
lblTip.setBounds(54, 22, 34, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblTip);

final JComboBox comboTip = new JComboBox();
comboTip.setBounds(98, 19, 123, 20);
frmOtoFiyatHesaplama.getContentPane().add(comboTip);

JPanel panel = new JPanel();
panel.setBorder(UIManager.getBorder(“CheckBox.border”));
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setAlignment(FlowLayout.LEFT);
panel.setBounds(54, 60, 123, 88);
frmOtoFiyatHesaplama.getContentPane().add(panel);

JLabel lblOpsiyonlar = new JLabel(“Opsiyonlar”);
panel.add(lblOpsiyonlar);

final JCheckBox chkJant = new JCheckBox(“\u00C7elik Jant”);
panel.add(chkJant);

final JCheckBox chkSunroof = new JCheckBox(“Sunroof”);
panel.add(chkSunroof);

JPanel panel_1 = new JPanel();
panel_1.setBorder(UIManager.getBorder(“RadioButton.border”));
panel_1.setBounds(194, 60, 140, 113);
frmOtoFiyatHesaplama.getContentPane().add(panel_1);
panel_1.setLayout(null);

JLabel lblKurBilgisi = new JLabel(“Kur Bilgisi”);
lblKurBilgisi.setBounds(7, 11, 84, 14);
panel_1.add(lblKurBilgisi);

final JRadioButton radioTL = new JRadioButton(“T\u00FCrk Liras\u0131”);
buttonGroup.add(radioTL);
radioTL.setBounds(7, 32, 99, 23);
panel_1.add(radioTL);

final JRadioButton radioUSD = new JRadioButton(“Amerikan Dolar\u0131”);
buttonGroup.add(radioUSD);
radioUSD.setSelected(true);
radioUSD.setBounds(7, 58, 127, 23);
panel_1.add(radioUSD);

final JRadioButton radioKD = new JRadioButton(“Kanada Dolar\u0131”);
buttonGroup.add(radioKD);
radioKD.setBounds(7, 84, 109, 23);
panel_1.add(radioKD);

JLabel lblUsd = new JLabel(“1 USD:”);
lblUsd.setBounds(54, 187, 46, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblUsd);

txtKurDegeri = new JTextField();
txtKurDegeri.setBounds(98, 184, 86, 20);
frmOtoFiyatHesaplama.getContentPane().add(txtKurDegeri);
txtKurDegeri.setColumns(10);

JLabel lblTl = new JLabel(“TL”);
lblTl.setBounds(187, 184, 34, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblTl);

txtDeger = new JTextField();
txtDeger.setBounds(98, 270, 86, 20);
frmOtoFiyatHesaplama.getContentPane().add(txtDeger);
txtDeger.setColumns(10);

JLabel lblDeeri = new JLabel(“De\u011Feri:”);
lblDeeri.setBounds(54, 273, 46, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblDeeri);

final JLabel lblKur = new JLabel(“”);
lblKur.setBounds(192, 273, 46, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblKur);

final JLabel lblMesaj = new JLabel(“”);
lblMesaj.setFont(new Font(“Tahoma”, Font.PLAIN, 12));
lblMesaj.setForeground(Color.RED);
lblMesaj.setBounds(98, 301, 220, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblMesaj);

String[] dizi = new String[3];
dizi[0] = “A Serisi”;
dizi[1] = “B Serisi”;
dizi[2] = “C Serisi”;

ComboBoxModel comboModel = new DefaultComboBoxModel(dizi);
comboTip.setModel(comboModel);

JButton btnHesapla = new JButton(“Hesapla”);
btnHesapla.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)

{
lblKur.setText(“”);
lblMesaj.setText(null);
double toplamDeger=0;
if (comboTip.getSelectedIndex()==0)
toplamDeger=60000;
else if (comboTip.getSelectedIndex()==1)
toplamDeger=50000;
else
toplamDeger=40000;

if (chkSunroof.isSelected())
toplamDeger=toplamDeger*1.006;

if(chkJant.isSelected())
toplamDeger=toplamDeger+1000;

if (radioTL.isSelected())
{
if(txtKurDegeri.getText().isEmpty())
{
lblMesaj.setText(“Alanları Boş Bırakmayınız!!!”);
}
else
{
double kurDegeri=Double.parseDouble(txtKurDegeri.getText());
double TL_Degeri=kurCevir(kurDegeri, toplamDeger);
txtDeger.setText(String.valueOf(TL_Degeri));
lblKur.setText(“TL”);
}
}
else if(radioUSD.isSelected())
{
txtDeger.setText(String.valueOf(toplamDeger));
lblKur.setText(“USD”);
}
else if (radioKD.isSelected())
{
if(txtKDKurDegeri.getText().isEmpty())
{
lblMesaj.setText(“Alanları Boş Bırakmayınız!!!”);
}
else
{
double KDKurDegeri=Double.parseDouble(txtKDKurDegeri.getText());
double KD_Degeri=kurCevir(KDKurDegeri, toplamDeger);
txtDeger.setText(String.valueOf(KD_Degeri));
lblKur.setText(“KD”);
}
}

}
});
btnHesapla.setBounds(98, 236, 89, 23);
frmOtoFiyatHesaplama.getContentPane().add(btnHesapla);

JButton btnTemizle = new JButton(“Temizle”);
btnTemizle.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
comboTip.setSelectedIndex(0);
chkJant.setSelected(false);
chkSunroof.setSelected(false);
radioUSD.setSelected(true);
txtDeger.setText(null);
txtKDKurDegeri.setText(null);
txtKurDegeri.setText(null);
lblKur.setText(null);
lblMesaj.setText(null);
}
});
btnTemizle.setBounds(190, 236, 89, 23);
frmOtoFiyatHesaplama.getContentPane().add(btnTemizle);

JLabel lblKd = new JLabel(“1 USD”);
lblKd.setBounds(54, 219, 34, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblKd);

txtKDKurDegeri = new JTextField();
txtKDKurDegeri.setBounds(98, 212, 86, 20);
frmOtoFiyatHesaplama.getContentPane().add(txtKDKurDegeri);
txtKDKurDegeri.setColumns(10);

JLabel lblUsd_1 = new JLabel(“KD”);
lblUsd_1.setBounds(187, 215, 34, 14);
frmOtoFiyatHesaplama.getContentPane().add(lblUsd_1);

}
private static double kurCevir(double USD_Degeri, double tipDegeri)
{
return USD_Degeri*tipDegeri;
}
}