Forums ProgMatique Forum Index Forums ProgMatique
Programmation (C/C++, JAVA, PHP, JavaScript, ...) et Informatique (Webmaster, Web)
Retour au site Progmatique

interface calculatrice

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Forums ProgMatique Forum Index » Programmation » Java
Previous topic :: Next topic  
Author Message
azza


Offline


Joined: 13 Apr 2011
Posts: 1


PostPosted: Wed 13 Apr 2011 - 19:35    Post subject: interface calculatrice Reply with quote

slt à ts aidez moi svp j'ai tapez cette code pou obtenir l'interface d'une calculatrice: 


import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
public class calculatrice extends JFrame { 
JTextField saisie=new JTextField(); 
JButton B0=new JButton("0"); 
JButton B1=new JButton("1"); 
JButton B2=new JButton("2"); 
JButton B3=new JButton("3"); 
JButton B4=new JButton("4"); 
JButton B5=new JButton("5"); 
JButton B6=new JButton("6"); 
JButton B7=new JButton("7"); 
JButton B8=new JButton("8"); 
JButton B9=new JButton("9"); 
JButton Bplus=new JButton("+"); 
JButton Bmoins=new JButton("-"); 
JButton Betoile=new JButton("*"); 
JButton Bdiv=new JButton("/"); 
JButton Begal=new JButton("="); 
JButton Bef=new JButton("Effacer"); 


public calculatrice(){ 
super("calculatrice"); 
this.getContentPane().setLayout(new BorderLayout()); 
this.getContentPane().add("North",saisie); 
JPanel p1=new JPanel(); 
p1.setLayout(new GridLayout(4,3)); 
p1.add(B1); 
p1.add(B2); 
p1.add(B3); 
p1.add(B4); 
p1.add(B5); 
p1.add(B6); 
p1.add(B7); 
p1.add(BCool
p1.add(B9); 
p1.add(Bplus); 
p1.add(B0); 
p1.add(Bmoins); 
this.getContentPane().add("Center",p1); 
JPanel p2=new JPanel(); 
p2.setLayout(new GridLayout(2,1)); 
JPanel p21=new JPanel(); 
p21.setLayout(new GridLayout(2,1)); 
p21.add(Betoile); 
p21.add(Bdiv); 
p2.add(p21); 
p2.add(Begal); 
this.getContentPane().add("East",p2); 
this.getContentPane().add("South",Bef); 
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true); 
this.pack(); 

public static void main(String[] args) { 
new calculatrice() ; 


ça marche b1 mais j'ai un truc ,comment implémenter l'écouteur ActionListener sur le bouton d'addition.j'attends votre réponse bientôt et merci
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Forums ProgMatique Forum Index » Programmation » Java All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  

Index | Create a forum | Free support forum | Free forums directory | Report a violation | Conditions générales d'utilisation
Powered by phpBB v2 © 2001, 2005 phpBB Group ¦ Theme: subSilver++