Corrigé Serie1 IHM .pdf


À propos / Télécharger Aperçu
Nom original: Corrigé Serie1 IHM.pdf
Auteur: Amine

Ce document au format PDF 1.5 a été généré par Acrobat PDFMaker 10.0 for Word / Adobe PDF Library 10.0, et a été envoyé sur fichier-pdf.fr le 29/03/2011 à 00:44, depuis l'adresse IP 41.143.x.x. La présente page de téléchargement du fichier a été vue 3022 fois.
Taille du document: 60 Ko (10 pages).
Confidentialité: fichier public


Aperçu du document


Serie1 IHM
Exercice1
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame_Calories extends JFrame implements ActionListener{
private JTextField TFFat;
private JPanel PanelFat;
private JTextField TFCalories;
private JPanel PanelCalories;
private JTextField TFResult;
private JPanel PanelResult;
private JButton DoIt;

public Frame_Calories(){
super("Calories from fat");
TFFat = new JTextField(10);
PanelFat = new JPanel();
PanelFat.add(new Label("Enter grams of fat") );
PanelFat.add(TFFat);

TFCalories = new JTextField(10);
PanelCalories = new JPanel();
PanelCalories.add(new Label("Enter total calories") );
PanelCalories.add(TFCalories);

TFResult = new JTextField(10);
TFResult.setEditable(false);
PanelResult = new JPanel();
PanelResult.setLayout(new FlowLayout());
PanelResult.add(new Label("Percent calories from fat") );

PanelResult.add(TFResult);
DoIt = new JButton("Do It !");
DoIt.addActionListener(this);
setLayout (new FlowLayout() ) ;
add(new Label("Percent of calories from fat"));
add(PanelFat);
add(PanelCalories);
add(PanelResult);
add(DoIt);
setSize( 290, 290);
setResizable( false );
setVisible(true);
}
private void calculate(){
double fat, percent,calories;
fat=Double.parseDouble(TFFat.getText());
calories=Double.parseDouble(TFCalories.getText() );
percent = ( (fat * 9) / calories ) * 100;
TFResult.setText(percent+" %");
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("Do It !"))calculate();
}
}

public class Test {
public static void main(String[] args) {
new Frame_Calories();
}
}

Exercice2
import java.awt.*;
import java.awt.event.*;

import java.text.*;
import javax.swing.*;
public class FrameWeight extends JFrame implements ActionListener{
private JRadioButton RBMale,RBFemale;
private ButtonGroup grGender;
private JPanel GenderPanel;
private JRadioButton h60_64, h64_68, h68_72, h72_76, h76_80;
private ButtonGroup grHeight;
private JPanel HeightPanel;
private JTextField resultatText;
private JPanel resultatPanel;
public FrameWeight(){
super("Your Ideal weight ");
grGender = new ButtonGroup();
RBMale = new JRadioButton("Male",false);
RBFemale= new JRadioButton("Female",true);
grGender.add(RBMale);
grGender.add(RBFemale);
GenderPanel = new JPanel();
JLabel GLabel = new JLabel("Your Gender");
GenderPanel.add(GLabel);
GenderPanel.add(RBMale);
GenderPanel.add(RBFemale);
Box box1 = Box.createVerticalBox();
GenderPanel.add(box1);
box1.add(GLabel);
box1.add(RBMale);
box1.add(RBFemale);
RBMale.addActionListener(this);
RBFemale.addActionListener(this);
RBMale.setActionCommand("M");
RBFemale.setActionCommand("F");

h60_64 = new JRadioButton("60 to 64 inches", true );
h64_68 = new JRadioButton("64 to 68 inches", false
h68_72 = new JRadioButton("68 to 72 inches", false
h72_76 = new JRadioButton("72 to 76 inches", false
h76_80 = new JRadioButton("76 to 80 inches", false
grHeight = new ButtonGroup();
grHeight.add(h60_64);
grHeight.add(h64_68);
grHeight.add(h68_72);
grHeight.add(h72_76);
grHeight.add(h76_80);

);
);
);
);

HeightPanel= new JPanel();
JLabel HLabel = new JLabel("Your height");
HeightPanel.add(HLabel);
HeightPanel.add(h60_64);
HeightPanel.add(h64_68);
HeightPanel.add(h68_72);
HeightPanel.add(h72_76);
HeightPanel.add(h76_80);
Box box2 = Box.createVerticalBox();
GenderPanel.add(box2);
box2.add(HLabel);
box2.add(h60_64);
box2.add(h64_68);
box2.add(h68_72);
box2.add(h72_76);
box2.add(h76_80);
h60_64.addActionListener(this);
h64_68.addActionListener(this);
h68_72.addActionListener(this);
h72_76.addActionListener(this);
h76_80.addActionListener(this);
h60_64.setActionCommand("h1");
h64_68.setActionCommand("h2");
h68_72.setActionCommand("h3");
h72_76.setActionCommand("h4");
h76_80.setActionCommand("h5");

resultatText = new JTextField(7);
resultatText.setEditable( false );
resultatPanel = new JPanel();
resultatPanel.add( new JLabel("Ideal Weight") );
resultatPanel.add( resultatText );

getContentPane().setLayout (new BorderLayout());
getContentPane().add(GenderPanel,BorderLayout.WEST);
getContentPane().add(HeightPanel,BorderLayout.EAST);
getContentPane().add(resultatPanel,BorderLayout.SOUTH);
setBounds(10, 10, 270, 270);
setVisible(true);}

public void actionPerformed (ActionEvent ev){
if (grGender.getSelection().getActionCommand().equals("M")){
if (grHeight.getSelection().getActionCommand().equals("h1"))
calcul(62.0,28.0);
if (grHeight.getSelection().getActionCommand().equals("h2"))
calcul(66.0,28.0);
if (grHeight.getSelection().getActionCommand().equals("h3"))
calcul(70.0,28.0);
if (grHeight.getSelection().getActionCommand().equals("h4"))

calcul(74.0,28.0);
if
(grHeight.getSelection().getActionCommand().equals("h5"))
calcul(78.0,28.0);
}
else if (grGender.getSelection().getActionCommand().equals("F")){
if (grHeight.getSelection().getActionCommand().equals("h1"))
calcul(62.0,30.0);
if
(grHeight.getSelection().getActionCommand().equals("h2"))
calcul(66.0,30.0);
if
(grHeight.getSelection().getActionCommand().equals("h3"))
calcul(70.0,30.0);
if
(grHeight.getSelection().getActionCommand().equals("h4"))
calcul(74.0,30.0);
if
(grHeight.getSelection().getActionCommand().equals("h5"))
calcul(78.0,30.0);
}
}
public void calcul(double h,double v){
double
w=(h*h)/v;
resultatText.setText(NumberFormat.getInstance().format(w));

}
}

______________________________________________________________________________
public class Test {
public static void main(String[] args) {
new FrameWeight();
}
}

Exercice 3
import java.awt.*;

import java.awt.event.*;
import javax.swing.*;
public class Conversion extends JFrame implements ActionListener {
private JPanel entreePanel;
private JTextField entree ;

private
private
private
private
private
private
private

JPanel devisePanel;
ButtonGroup deviseGroup;
JRadioButton dollar;
JRadioButton francFr;
JRadioButton francSW;
JRadioButton francsBG;
JRadioButton Peseta;

private JPanel sortiePanel;
private JTextField sortie;

public Conversion(){
super(" Conversion du

dirhams Marocains en diverses devises ");

entreePanel=new JPanel();
entree = new JTextField(15);
entreePanel.add(new JLabel("Donnez la valeur en DIRHAMS "));
entreePanel.add(entree);
devisePanel =new JPanel() ;
deviseGroup=new ButtonGroup() ;
dollar=new
JRadioButton("Dollar",false) ;
francFr=new
JRadioButton("Franc Français",false) ;
francSW=new
JRadioButton("Franc Swiss",false) ;
francsBG=new JRadioButton("Franc Belge",false) ;
Peseta=new
JRadioButton("10 Peseta",true) ;
deviseGroup.add(dollar);
deviseGroup.add(francFr);
deviseGroup.add(francSW);
deviseGroup.add(francsBG);
deviseGroup.add(Peseta);
devisePanel.add(dollar);
devisePanel.add(francFr);
devisePanel.add(francSW);
devisePanel.add(francsBG);
devisePanel.add(Peseta);
sortiePanel =new JPanel();
sortie=new JTextField(15);
sortie.setEditable(false);
sortiePanel.add(new JLabel("Monnaie convertie "));
sortiePanel.add(sortie);

getContentPane().add(entreePanel,BorderLayout.NORTH);
getContentPane().add(devisePanel,BorderLayout.CENTER);
getContentPane().add(sortiePanel,BorderLayout.SOUTH);

dollar.addActionListener(this);
francFr.addActionListener(this);
francSW.addActionListener(this);
francsBG.addActionListener(this);
Peseta.addActionListener(this);
/*
dollar.setActionCommand("DA");
francFr.setActionCommand("FF");
francSW.setActionCommand("FS");
francsBG.setActionCommand("FB");
Peseta.setActionCommand("PE");
*/
pack();
setVisible(true);

}

public void actionPerformed(ActionEvent ev) {
if (ev.getSource()==dollar)
sortie.setText(Double.parseDouble(entree.getText())*9.0+"
Dh");
if (ev.getSource()==francFr)
sortie.setText(Double.parseDouble(entree.getText())*1.5+"
Dh");
if (ev.getSource()==francSW)
sortie.setText(Double.parseDouble(entree.getText())*2.5+" Dh");
if (ev.getSource()==francsBG)
sortie.setText(Double.parseDouble(entree.getText())*3.0+" Dh");
if (ev.getSource()==Peseta)
sortie.setText(Double.parseDouble(entree.getText())*3.5+"
Dh");

}

}

public class MAIN {

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

Exercice 4
import
import
import
public

java.awt.*;
java.awt.event.*;
javax.swing.*;
class Article extends JFrame implements ActionListener {

private
private
private
private
private
private

JPanel panel1;
JTextField TFArticle;
JTextField TFReference;
JTextField TFPHT;
JTextField TFTVA;
JTextField TFTTC;

private JPanel panel2;
private TextArea TAinformations;
private JPanel panel3;
private JButton JBCreate;
private JButton JBQuitter;

public Article(){
super("Information sur l'article") ;
panel1=new JPanel() ;
TFArticle=new
JTextField(7) ;
TFReference=new
JTextField(7) ;
TFPHT=new
JTextField(7) ;
TFTVA=new
JTextField(7) ;
TFTTC=new
JTextField(7) ;
panel1.setLayout (new FlowLayout (FlowLayout.CENTER)) ;
panel1.add(new JLabel(" Article "));
panel1.add(TFArticle);
panel1.add(new JLabel(" Référence "));
panel1.add(TFReference);
panel1.add(new JLabel(" Prix HT "));
panel1.add(TFPHT);
panel1.add(new JLabel(" Taux TVA"));
panel1.add(TFTVA);
panel1.add(new JLabel(" Prix TTC"));

panel1.add(TFTTC);
panel1.setBackground(new Color(215,189,15));

panel2=new JPanel() ;
TAinformations=new TextArea(" Informations sur l'article
:\n",10,50,TextArea.SCROLLBARS_BOTH) ;
panel2.add(TAinformations);
panel2.setBackground(new Color(21,132,191));

panel3= new JPanel() ;
JBCreate= new JButton("Create") ;
JBQuitter= new JButton("Quitter") ;
panel3.add(JBCreate);
panel3.add(JBQuitter);
panel3.setBackground(new Color(129,84,128));
JBCreate.addActionListener(this);
JBQuitter.addActionListener(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(panel1,BorderLayout.NORTH);
getContentPane().add(panel2,BorderLayout.CENTER);
getContentPane().add(panel3,BorderLayout.SOUTH);
pack();
setVisible(true);
}

public void actionPerformed (ActionEvent e) {
if (e.getSource()==JBCreate){
TFTTC.setText(""+
Double.parseDouble(TFPHT.getText())*(1+(Double.parseDouble(TFTVA.getText())/10
0)));
String infos= new String();
infos="
Informations sur l'article :\n\t Nom article :\t
"+TFArticle.getText()+"\n\t Réference :\t"+TFReference.getText()+"\n\t Prix HT
:\t"+TFPHT.getText()+" Dh \n\t Taux TVA:\t"+TFTVA.getText()+" \n\t Prix TTC
:\t "+TFTTC.getText()+ " Dh";
TAinformations.setText(infos);}
if

(e.getSource()==JBQuitter)
System.exit(0);

}

public class Main {
public static void main(String[] args) {

new Article();}}


Aperçu du document Corrigé Serie1 IHM.pdf - page 1/10

 
Corrigé Serie1 IHM.pdf - page 2/10
Corrigé Serie1 IHM.pdf - page 3/10
Corrigé Serie1 IHM.pdf - page 4/10
Corrigé Serie1 IHM.pdf - page 5/10
Corrigé Serie1 IHM.pdf - page 6/10
 




Télécharger le fichier (PDF)




Sur le même sujet..





Ce fichier a été mis en ligne par un utilisateur du site. Identifiant unique du document: 00044961.
⚠️  Signaler un contenu illicite
Pour plus d'informations sur notre politique de lutte contre la diffusion illicite de contenus protégés par droit d'auteur, consultez notre page dédiée.