CCB Premier Import
This commit is contained in:
6
Convertisseur/.classpath
Normal file
6
Convertisseur/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
Convertisseur/.project
Normal file
17
Convertisseur/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Convertisseur</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
Convertisseur/.settings/org.eclipse.jdt.core.prefs
Normal file
11
Convertisseur/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
BIN
Convertisseur/bin/Convertisseur.class
Normal file
BIN
Convertisseur/bin/Convertisseur.class
Normal file
Binary file not shown.
133
Convertisseur/src/Convertisseur.java
Normal file
133
Convertisseur/src/Convertisseur.java
Normal file
@@ -0,0 +1,133 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class Convertisseur extends JFrame implements ActionListener {
|
||||
|
||||
private JLabel lbTitre = new JLabel("Convertisseur");
|
||||
private JButton btEuro = new JButton("Euro");
|
||||
private JButton btFr = new JButton("Franc");
|
||||
private JButton btAc = new JButton("Annuler");
|
||||
private JButton btApropos = new JButton("<EFBFBD> propos");
|
||||
private JButton btTaux = new JButton("Taux");
|
||||
private JButton btQuitter = new JButton("Quitter");
|
||||
|
||||
private JTextField txtMontant = new JTextField();
|
||||
|
||||
private String devise;
|
||||
private float taux;
|
||||
|
||||
public Convertisseur() {
|
||||
|
||||
this.devise = "Franc";
|
||||
this.taux = (float)6.56;
|
||||
|
||||
this.setBounds(200, 200, 450, 300);
|
||||
this.setTitle("Convertisseur");
|
||||
this.setResizable(false);
|
||||
this.setLayout(null);
|
||||
this.lbTitre.setBounds(175, 20, 200, 20);
|
||||
this.add(this.lbTitre);
|
||||
|
||||
ImageIcon icon = new ImageIcon("src/convertisseur.png");
|
||||
JLabel lbIcon = new JLabel(icon);
|
||||
lbIcon.setBounds(10, 10, 70, 70);
|
||||
this.add(lbIcon);
|
||||
|
||||
this.btEuro.setBounds(50, 100, 100, 20);
|
||||
this.add(this.btEuro);
|
||||
this.txtMontant.setBounds(170, 100, 100, 20);
|
||||
this.add(this.txtMontant);
|
||||
this.btFr.setBounds(290, 100, 100, 20);
|
||||
this.add(this.btFr);
|
||||
|
||||
this.btApropos.setBounds(50, 170, 100, 20);
|
||||
this.add(this.btApropos);
|
||||
this.btAc.setBounds(170, 170, 100, 20);
|
||||
this.add(this.btAc);
|
||||
this.btTaux.setBounds(290, 170, 100, 20);
|
||||
this.add(this.btTaux);
|
||||
this.btQuitter.setBounds(170, 220, 100, 20);
|
||||
this.add(this.btQuitter);
|
||||
|
||||
this.btAc.addActionListener(this);
|
||||
this.btEuro.addActionListener(this);
|
||||
this.btFr.addActionListener(this);
|
||||
this.btApropos.addActionListener(this);
|
||||
this.btTaux.addActionListener(this);
|
||||
this.btQuitter.addActionListener(this);
|
||||
|
||||
this.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Convertisseur monC = new Convertisseur();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getSource() == this.btAc) {
|
||||
this.txtMontant.setText("");
|
||||
} else if (e.getSource() == this.btEuro) {
|
||||
if (this.txtMontant.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(this,"Veuillez saisir un montant", "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
float mt=0;
|
||||
try {
|
||||
mt = Float.parseFloat(this.txtMontant.getText());
|
||||
mt=(float) (mt/this.taux);
|
||||
this.txtMontant.setText(""+mt);
|
||||
}
|
||||
catch(NumberFormatException exp) {
|
||||
JOptionPane.showMessageDialog(this,"Veuillez v<>rifier votre montant", "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
} else if (e.getSource() == this.btFr) {
|
||||
if (this.txtMontant.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(this,"Veuillez saisir un montant", "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
float mt=0;
|
||||
try {
|
||||
mt = Float.parseFloat(this.txtMontant.getText());
|
||||
mt=(float) (mt*this.taux);
|
||||
this.txtMontant.setText(""+mt);
|
||||
}
|
||||
catch(NumberFormatException exp) {
|
||||
JOptionPane.showMessageDialog(this,"Veuillez v<>rifier votre montant", "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
} else if (e.getSource() == this.btApropos) {
|
||||
JOptionPane.showMessageDialog(this,"Logiciel r<>alis<69> le 15/12/2016\n"
|
||||
+ "\n Alexandre DA COSTA"
|
||||
+ "\n Utilisant le framework Swing",
|
||||
"Information", JOptionPane.INFORMATION_MESSAGE);
|
||||
} else if (e.getSource() == this.btQuitter) {
|
||||
int r = JOptionPane.showConfirmDialog(this, "Voulez-vous quitter ?", "Quitter", JOptionPane.OK_CANCEL_OPTION);
|
||||
if (r == 0) {
|
||||
this.dispose();
|
||||
}
|
||||
} else if (e.getSource() == this.btTaux) {
|
||||
try {
|
||||
this.devise = JOptionPane.showInputDialog(this, "Saisir le nom de la devise");
|
||||
this.taux = Float.parseFloat(JOptionPane.showInputDialog(this, "Saisir le taux de la devise"));
|
||||
this.btFr.setText(this.devise);
|
||||
} catch (NumberFormatException exp) {
|
||||
this.taux = (float) 6.56;
|
||||
this.devise = "Franc";
|
||||
this.btFr.setText(this.devise);
|
||||
} catch (NullPointerException exp) {
|
||||
this.taux = (float) 6.56;
|
||||
this.devise = "Franc";
|
||||
this.btFr.setText(this.devise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user