|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
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
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Scanner un port avec JAVA [ par aminos88 ]
J'ai un programme Java qui permet de scanner un port d'une machine mais le problème que ce programme n'est fonctionnel que sur la machine locale je ne
une classe java qui fait l insertion dans une table oracle 10g [ par lerache ]
bonjour tous;je suis entrin de realiser une application avec j2ee pour mon PFE, j ai deja ecrit la classe qui fait la connection avec la base de donn
Ecouteur avec java sous Oracle [ par lion2080 ]
Bonjour T.M :J'ai un petit problème consernant Java & Oracle.J'ai un table dans une base de données oracle, je veut lancer un thread java qui fait
comparaison de 2 fichiers texte (pb boucle while je pense) [ par tomski ]
Bonjour,Jessaye de comparer 2 fichiers texte ligne par ligne.Chaque ligne est decoupee (split(";")) et chaque mot est stocké dans un array.Ensuite je
Probleme de parser [ par dess5 ]
Bonjour,je souhaite parser un fichier xml sous eclipse et je n'arrive pas à le faire j'ai toujour catte erreur :java.lang.ClassNotFoundException<
Liaison iReport / Application java Netbeans de bureau [ par hyunikel ]
Salut, S'il vous plait, quelqu'un sait comment lier entre un document iReport et une application java Netbeans de bureau?Je m'explique...*Comment po
rendre un projet java executable [ par d3dzied ]
svp aider moi comment rendre un programme java executable???
souci actionperformed [ par jeremieT ]
Bonjour, j'ai un soucis dans mon projet java: je voudrais mettre le programme en "pause " jusqu'a ce que je clique sur un bouton.(je ne peux pas mettr
C to Java [ par helmi2008 ]
Bonjour à tous,J'en un programme écrit en c que je dois le transformer en java..Vu que je métrise pas le langage C je trouve beaucoup de difficultés..
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

LG KP501
Entre 9€ et 159€
|