Accueil > > > SIMULATEUR DE L’ALGORITHME PRODUCTEUR/CONSOMMATEUR (INGÉNIEUR ISIMS 2008)
SIMULATEUR DE L’ALGORITHME PRODUCTEUR/CONSOMMATEUR (INGÉNIEUR ISIMS 2008)
Information sur la source
Description
C’est une petite application avec des composantes graphiques du package swing de java qui fait la simulation de l’algorithme producteur/consommateur
J’espère que ça vous aide bonne continuation
Source
- import javax.swing.*;
- import java.awt.event.*;
- import java.awt.*;
-
- public class TestBuffer extends JFrame implements ActionListener
- {
- public Bufer buffer;
- public Producteur producteur;
- public Consommateur consommateur;
- public Container container;
- public ImageIcon[] image;
- public JButton compteur;
- public JPanel totale;
- public JPanel producteurP;
- public JPanel consommateurP;
- public JPanel controler;
- public JPanel p_controler;
- public JPanel c_controler;
- public JLabel titre;
-
- public ImageIcon pro_img;
- public ImageIcon con_img;
- public JButton pro;
- public JButton con;
- public ImageIcon on_img;
- public ImageIcon off_img;
- public JButton pro_on;
- public JButton con_on;
- public JButton pro_off;
- public JButton con_off;
-
- public ImageIcon xon_img;
- public ImageIcon xoff_img;
- public JButton xon;
- public JButton xoff;
-
- public ImageIcon controle_img;
- public JButton controle;
-
- public static TestBuffer t;
-
- public ImageIcon logo;
-
- public TestBuffer()
- {
- try
- {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- SwingUtilities.updateComponentTreeUI(this);
- }
- catch (Exception e)
- {
- System.out.println("FrmUsers.FrmUsers : impossible d'appliquer le thème du système");
- }
-
- logo = new ImageIcon("logo.png");
- this.setIconImage(logo.getImage());
- this.setTitle("Producteur/Consommateur");
-
- controle_img=new ImageIcon("controle.png");
- controle=new JButton();
- controle.setIcon(controle_img);
-
- pro_img=new ImageIcon("producteur.png");
- con_img=new ImageIcon("consommateur.png");
- pro=new JButton();
- pro.setIcon(pro_img);
- con=new JButton();
- con.setIcon(con_img);
-
- xon_img=new ImageIcon("xon.png");
- xoff_img=new ImageIcon("xoff.png");
- xon=new JButton();
- xon.setIcon(xon_img);
- xoff=new JButton();
- xoff.setIcon(xoff_img);
-
- on_img=new ImageIcon("on.png");
- off_img=new ImageIcon("off.png");
- pro_on=new JButton();
- pro_on.setIcon(on_img);
- con_on=new JButton();
- con_on.setIcon(on_img);
- pro_off=new JButton();
- pro_off.setIcon(off_img);
- con_off=new JButton();
- con_off.setIcon(off_img);
-
- totale = new JPanel();
- totale.setLayout(new BoxLayout(totale, BoxLayout.Y_AXIS));
-
- controler = new JPanel();
- controler.setLayout(new BoxLayout(controler,BoxLayout.X_AXIS));
- producteurP = new JPanel();
- producteurP.setLayout(new BoxLayout(producteurP, BoxLayout.X_AXIS));
- p_controler = new JPanel();
- p_controler.setLayout(new BoxLayout(p_controler, BoxLayout.Y_AXIS));
- p_controler.add(pro_on);
- p_controler.add(pro_off);
- producteurP.add(pro);
- producteurP.add(p_controler);
- controler.add(producteurP);
-
- controler.add(xoff);
- controler.add(xon);
-
- consommateurP = new JPanel();
- consommateurP.setLayout(new BoxLayout(consommateurP, BoxLayout.X_AXIS));
- c_controler = new JPanel();
- c_controler.setLayout(new BoxLayout(c_controler, BoxLayout.Y_AXIS));
- c_controler.add(con_on);
- c_controler.add(con_off);
- consommateurP.add(c_controler);
- consommateurP.add(con);
- controler.add(consommateurP);
-
- totale.add(controler);
-
- compteur=new JButton();
- image = new ImageIcon[10];
- for(int i=0;i<10;i++)
- {
- image[i] = new ImageIcon(i+".png");
- System.out.println(image[i]);
- }
- compteur.setIcon(image[0]);
- container=this.getContentPane();
- buffer = new Bufer(10,compteur,image);
- producteur = new Producteur (buffer);
- consommateur = new Consommateur (buffer);
- container.add(compteur,BorderLayout.NORTH);
- container.add(controle,BorderLayout.CENTER);
- container.add(totale,BorderLayout.SOUTH);
- this.setVisible(true);
- this.pack();
- pro_on.addActionListener(this);
- pro_off.addActionListener(this);
- con_on.addActionListener(this);
- con_off.addActionListener(this);
- xon.addActionListener(this);
- xoff.addActionListener(this);
- }
-
- public static void main(String args[])
- {
- t=new TestBuffer();
- t.producteur.start();
- t.consommateur.start();
- }
-
- public void actionPerformed(ActionEvent action)
- {
- if(action.getSource().equals(pro_on))
- {
- t.producteur=new Producteur (buffer);
- t.producteur.start();
- }
- if(action.getSource().equals(pro_off))
- {
- t.producteur.stop();
- }
- if(action.getSource().equals(con_on))
- {
- t.consommateur=new Consommateur (buffer);
- t.consommateur.start();
- }
- if(action.getSource().equals(con_off))
- {
- t.consommateur.stop();
- }
- if(action.getSource().equals(xon))
- {
- t.producteur=new Producteur (buffer);
- t.consommateur=new Consommateur (buffer);
- t.producteur.start();
- t.consommateur.start();
- }
- if(action.getSource().equals(xoff))
- {
- t.producteur.stop();
- t.consommateur.stop();
- }
- }
- }
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TestBuffer extends JFrame implements ActionListener
{
public Bufer buffer;
public Producteur producteur;
public Consommateur consommateur;
public Container container;
public ImageIcon[] image;
public JButton compteur;
public JPanel totale;
public JPanel producteurP;
public JPanel consommateurP;
public JPanel controler;
public JPanel p_controler;
public JPanel c_controler;
public JLabel titre;
public ImageIcon pro_img;
public ImageIcon con_img;
public JButton pro;
public JButton con;
public ImageIcon on_img;
public ImageIcon off_img;
public JButton pro_on;
public JButton con_on;
public JButton pro_off;
public JButton con_off;
public ImageIcon xon_img;
public ImageIcon xoff_img;
public JButton xon;
public JButton xoff;
public ImageIcon controle_img;
public JButton controle;
public static TestBuffer t;
public ImageIcon logo;
public TestBuffer()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception e)
{
System.out.println("FrmUsers.FrmUsers : impossible d'appliquer le thème du système");
}
logo = new ImageIcon("logo.png");
this.setIconImage(logo.getImage());
this.setTitle("Producteur/Consommateur");
controle_img=new ImageIcon("controle.png");
controle=new JButton();
controle.setIcon(controle_img);
pro_img=new ImageIcon("producteur.png");
con_img=new ImageIcon("consommateur.png");
pro=new JButton();
pro.setIcon(pro_img);
con=new JButton();
con.setIcon(con_img);
xon_img=new ImageIcon("xon.png");
xoff_img=new ImageIcon("xoff.png");
xon=new JButton();
xon.setIcon(xon_img);
xoff=new JButton();
xoff.setIcon(xoff_img);
on_img=new ImageIcon("on.png");
off_img=new ImageIcon("off.png");
pro_on=new JButton();
pro_on.setIcon(on_img);
con_on=new JButton();
con_on.setIcon(on_img);
pro_off=new JButton();
pro_off.setIcon(off_img);
con_off=new JButton();
con_off.setIcon(off_img);
totale = new JPanel();
totale.setLayout(new BoxLayout(totale, BoxLayout.Y_AXIS));
controler = new JPanel();
controler.setLayout(new BoxLayout(controler,BoxLayout.X_AXIS));
producteurP = new JPanel();
producteurP.setLayout(new BoxLayout(producteurP, BoxLayout.X_AXIS));
p_controler = new JPanel();
p_controler.setLayout(new BoxLayout(p_controler, BoxLayout.Y_AXIS));
p_controler.add(pro_on);
p_controler.add(pro_off);
producteurP.add(pro);
producteurP.add(p_controler);
controler.add(producteurP);
controler.add(xoff);
controler.add(xon);
consommateurP = new JPanel();
consommateurP.setLayout(new BoxLayout(consommateurP, BoxLayout.X_AXIS));
c_controler = new JPanel();
c_controler.setLayout(new BoxLayout(c_controler, BoxLayout.Y_AXIS));
c_controler.add(con_on);
c_controler.add(con_off);
consommateurP.add(c_controler);
consommateurP.add(con);
controler.add(consommateurP);
totale.add(controler);
compteur=new JButton();
image = new ImageIcon[10];
for(int i=0;i<10;i++)
{
image[i] = new ImageIcon(i+".png");
System.out.println(image[i]);
}
compteur.setIcon(image[0]);
container=this.getContentPane();
buffer = new Bufer(10,compteur,image);
producteur = new Producteur (buffer);
consommateur = new Consommateur (buffer);
container.add(compteur,BorderLayout.NORTH);
container.add(controle,BorderLayout.CENTER);
container.add(totale,BorderLayout.SOUTH);
this.setVisible(true);
this.pack();
pro_on.addActionListener(this);
pro_off.addActionListener(this);
con_on.addActionListener(this);
con_off.addActionListener(this);
xon.addActionListener(this);
xoff.addActionListener(this);
}
public static void main(String args[])
{
t=new TestBuffer();
t.producteur.start();
t.consommateur.start();
}
public void actionPerformed(ActionEvent action)
{
if(action.getSource().equals(pro_on))
{
t.producteur=new Producteur (buffer);
t.producteur.start();
}
if(action.getSource().equals(pro_off))
{
t.producteur.stop();
}
if(action.getSource().equals(con_on))
{
t.consommateur=new Consommateur (buffer);
t.consommateur.start();
}
if(action.getSource().equals(con_off))
{
t.consommateur.stop();
}
if(action.getSource().equals(xon))
{
t.producteur=new Producteur (buffer);
t.consommateur=new Consommateur (buffer);
t.producteur.start();
t.consommateur.start();
}
if(action.getSource().equals(xoff))
{
t.producteur.stop();
t.consommateur.stop();
}
}
}
Conclusion
J’espère que ça vous aide bonne continuation
Historique
- 25 avril 2008 00:47:25 :
- J’ai ajouté la source
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Forum
PARSER DE XMLPARSER DE XML par fioreT
Cliquez pour lire la suite par fioreT
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|