import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Convert extends JPanel implements ActionListener{ public Convert(){ //JPanel panneau=new JPanel(); setLayout(new GridLayout(3,2)); setSize(100,100); JTextArea champ1=new JTextArea(10,1); add(champ1); JLabel euro=new JLabel("Euros"); euro.setHorizontalAlignment(SwingConstants.CENTER); add(euro); //ActionListener listener=new ButtonListener(this); JButton euro_en_livre=new JButton("Euro->Livre"); add(euro_en_livre); euro_en_livre.addActionListener(this); JButton livre_en_euro=new JButton("Livre->Euro"); add(livre_en_euro); JTextArea champ2=new JTextArea(10,1); add(champ2); livre_en_euro.addActionListener(this); JLabel pounds=new JLabel("Pounds"); pounds.setHorizontalAlignment(SwingConstants.CENTER); add(pounds); } public void actionPerformed(ActionEvent e){ if(e.getActionCommand().equals("Euro->Livre")){ double valeur = Double.parseDouble(champ1.getText()); valeur/= 1.2413; champ2.setText(valeur+""); }else{ double valeur = Double.parseDouble(champ2.getText()); valeur *= 0.78; champ1.setText(valeur+""); } } public static void main(String args[]){ JFrame fenetre=new JFrame("Convertisseur"); //panneau.setBackground(Color.BLUE); fenetre.getContentPane().add(new Convert()); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setVisible(true); } }