Forums ProgMatique
Programmation (C/C++, JAVA, PHP, JavaScript, ...) et Informatique (Webmaster, Web)
Retour au site Progmatique
Log in to check your private messages
Log in
Register
FAQ
Rechercher
interface calculatrice
Forums ProgMatique Forum Index
»
Programmation
»
Java
Previous topic
::
Next topic
Author
Message
azza
Offline
Joined: 13 Apr 2011
Posts: 1
Posted: Wed 13 Apr 2011 - 19:35
Post subject: interface calculatrice
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(B
;
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:
All Posts
1 Day
7 Days
2 Weeks
1 Month
3 Months
6 Months
1 Year
Oldest First
Newest First
Forums ProgMatique Forum Index
»
Programmation
»
Java
All times are GMT + 2 Hours
Page
1
of
1
Jump to:
Select a forum
----------------
ProgMatique
Le site
Forums
Mes freewares
MinorityScreen
MutePhone
Développements abandonnés
LanceGames
UtilRundll
SysViewNote
GenerMTag
SMAdmin
Programmation
C / C++
Php / MySQL
HTML / XHTML / CSS
Javascript / AJAX
Java
DotNET
VB.Net
ASP.net
C#
Langage Basic / visual Basic / VBA
Langages de script (batch, shell, fichier reg, etc...)
Autres langages
Challenges de programmation
Informatique en général
Ms-Dos
Windows
Réseaux & Sécurité informatique
Linux / logiciels libres
Webmastering
Veille Informatique
Détente
Discussions diverses
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++