|
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
Débuter en java... [ par OriOn ]
Bonjour, voilà alors je voudrais me mettre à java, et je voudrais savoir qu'est ce qu'il faut que je télécharge pour pouvoir tester mes créations et q
Editeur Java [ par syndrael ]
Bonjour,Je débute et je voulais savoir quel éditeur vous utilisez de votre coté. Moi, je fais appel à JPADPro 3.6, ca change de la fenetre DOS !! LOL
interaction entre html et java via javascript [ par rmo ]
Bonjour à tous.Je cherche à trouver comment par une action sur un boutoon html, lancer une action dans une applet java.Merci.
Comment on fait pour simplement dessiner [ par MeltedMind ]
Bonjour, je me demandais comment l'on fait pour afficher un image en java. J'utilise Code Warrior pour java version 6.0, je suis un nouvel utilisateu
Icône pour application Java [ par Mikonyx ]
Est-il possible de remplacer la tasse de café présente dans toutes les applications Java par un icône personnel? Ah aussi... existe t'il un equivalent
chat multiclients (JAVA) [ par Yzermat ]
Je suis a la recherche d'un chat multiclients en java! Ce serait bien si il était assez bien commenté! C'est tres urgent et assez important , sinon je
Urgent : Broadcast en JAVA [ par skysee ]
Bonjour,Je voudrais réaliser en JAVA un broadcast sur un réseau pour en lister toutes les machines qui y sont connectées. L'affichage se réalisant com
Programmation BROADCAST en JAVA [ par skysee ]
Bonsoir,Je voudrais réaliser en JAVA un broadcast sur un réseau pour en lister tout les PC qui y sont connectées. L'affichage de ses PC se réalisant c
URGENT: Broadcast en JAVA [ par skysee ]
Bonjour,Je voudrais réaliser en JAVA un broadcast sur un réseau pour en lister toutes les machines qui y sont connectées. L'affichage se réalisant com
Compilateur JAVA [ par BobH ]
J'ai du formater mon disque et je n'ai plus j++ donc je cherche juste un compilateur, merci!
|
Téléchargements
Logiciels à télécharger sur le même thème :
|