Bonjour,
Je dois faire un convertisseur de devises avec une interface graphique.
J'ai fais l'interface graphique et il me reste à faire appel à ce que j'écrirai dans l'espace JTextField et à utiliser les objets du JComboBox pour qu'en appuyant sur le bouton "convertir", la conversion se fasse.
Quelqu'un saurait-il m'expliquer comment m'y prendre ?
Voici où j'en suis :
Classe MainClasse Windows
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public class TestMain{ public static void main(String[] agrs){ windows fen = new windows(); } }Merci d'avance pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class windows extends JFrame { private JTextField Résultat; private JComboBox combo1; private JComboBox combo2; private JButton bouton; private JLabel label; private JLabel mylabel; public windows(){ this.setTitle(" Convertisseur"); this.setSize(400, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setResizable(false); this.setVisible(true); this.setContentPane(windows()); } private JPanel windows(){ JPanel panel = new JPanel(); panel.setBackground(Color.white); Résultat = new JTextField(); Résultat.setColumns(5); System.out.println(Résultat.getText()); panel.add(Résultat); Object[] choix = new Object[]{"EUR - Euro", "USD - US Dollar ", " Franc CFA "}; combo1 = new JComboBox(choix); panel.add(combo1); label = new JLabel("Vers"); panel.add(label); combo2 = new JComboBox(choix); panel.add(combo2); bouton = new JButton("convertir"); bouton.addActionListener(new Actionbouton()); panel.add(bouton); panel.add(bouton, BorderLayout.AFTER_LAST_LINE); return panel; } class Actionbouton implements ActionListener{ public void actionPerformed(ActionEvent e) { } } }
Partager