# Corrigé Serie1 IHM .pdf

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") );

TFCalories = new JTextField(10);
PanelCalories = new JPanel();

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

DoIt = new JButton("Do It !");
setLayout (new FlowLayout() ) ;
add(new Label("Percent of calories from fat"));
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 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(){
grGender = new ButtonGroup();
GenderPanel = new JPanel();
JLabel GLabel = new JLabel("Your Gender");
Box box1 = Box.createVerticalBox();
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();

);
);
);
);

HeightPanel= new JPanel();
JLabel HLabel = new JLabel("Your height");
Box box2 = Box.createVerticalBox();
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();

getContentPane().setLayout (new BorderLayout());
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;

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 "));
devisePanel =new JPanel() ;
deviseGroup=new ButtonGroup() ;
dollar=new
francFr=new
francSW=new
Peseta=new
sortiePanel =new JPanel();
sortie=new JTextField(15);
sortie.setEditable(false);

/*
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.setBackground(new Color(215,189,15));

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

panel3= new JPanel() ;
JBCreate= new JButton("Create") ;
JBQuitter= new JButton("Quitter") ;
panel3.setBackground(new Color(129,84,128));
getContentPane().setLayout(new BorderLayout());
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();}}

### Sur le même sujet..

Ce fichier a été mis en ligne par un utilisateur du site. Identifiant unique du document: 00044961.

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.