Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.ducherudy.mesclasses;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Fenetre extends JFrame implements ActionListener {
- private static final long serialVersionUID = 1L;
- JTabbedPane tabbedPane = new JTabbedPane();
- JPanel panVins = new JPanel();
- JPanel panAjout = new JPanel();
- JPanel panSuppMod = new JPanel();
- Color colorBack = new Color(133,22,54);
- public Fenetre(){
- Dimension monecran = Toolkit.getDefaultToolkit().getScreenSize();
- int x = (monecran.width/2);
- int y = (monecran.height/2);
- this.pack();
- this.setTitle("Ma Cave à Vin");
- this.setSize(530,400);
- this.setLocation((x-(this.getWidth()/2)),(y-(this.getHeight()/2)));
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setResizable(false);
- this.setVisible(true);
- tabbedPane.addTab("Gestion des Vins",panVins);
- tabbedPane.addTab("Ajout d'un Vin", panAjout);
- tabbedPane.addTab("Supprimer ou Modifier un Vin", panSuppMod);
- this.setContentPane(tabbedPane);
- gestionCave();
- ajoutVins();
- suppModVins();
- }
- public void gestionCave(){
- JTextField monVin = new JTextField();
- JList mesVins = new JList();
- JLabel nomB = new JLabel("Bouteille : ");
- JLabel contB = new JLabel("Contenance : ");
- JLabel prixB = new JLabel("Prix : ");
- JLabel anneeB = new JLabel("Année :");
- JLabel qteB = new JLabel("Quantité : ");
- JLabel catB = new JLabel("Catégorie : ");
- JLabel regB = new JLabel("Region : ");
- JLabel paysB = new JLabel("Pays : ");
- JLabel cepB = new JLabel("Cepage : ");
- JLabel appB = new JLabel("Appellation : ");
- JTextField texteBout = new JTextField();
- JTextField nomT = new JTextField();
- JTextField contT = new JTextField();
- JTextField prixT = new JTextField();
- JTextField anneeT = new JTextField();
- JTextField qteT = new JTextField();
- JTextField catT = new JTextField();
- JTextField regT = new JTextField();
- JTextField paysT = new JTextField();
- JTextField cepT = new JTextField();
- JTextField appT = new JTextField();
- texteBout.setSize(510, 30);
- texteBout.setLocation(5,305);
- texteBout.setText("Texte concernant une bouteille");
- texteBout.setEditable(false);
- panVins.add(texteBout);
- monVin.setSize(200,20);
- monVin.setLocation(5, 10);
- mesVins.setSize(200, 260);
- mesVins.setLocation(5, 40);
- mesVins.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- mesVins.setLayoutOrientation(JList.HORIZONTAL_WRAP);
- //Les JLabel
- nomB.setSize(100,20);
- nomB.setLocation(210, 10);
- nomB.setForeground(Color.YELLOW);
- contB.setSize(100,20);
- contB.setLocation(210, 40);
- contB.setForeground(Color.YELLOW);
- prixB.setSize(100,20);
- prixB.setLocation(210, 70);
- prixB.setForeground(Color.YELLOW);
- anneeB.setSize(100,20);
- anneeB.setLocation(210, 100);
- anneeB.setForeground(Color.YELLOW);
- qteB.setSize(100,20);
- qteB.setLocation(210, 130);
- qteB.setForeground(Color.YELLOW);
- catB.setSize(100,20);
- catB.setLocation(210, 160);
- catB.setForeground(Color.YELLOW);
- regB.setSize(100,20);
- regB.setLocation(210, 190);
- regB.setForeground(Color.YELLOW);
- paysB.setSize(100,20);
- paysB.setLocation(210, 220);
- paysB.setForeground(Color.YELLOW);
- cepB.setSize(100,20);
- cepB.setLocation(210, 250);
- cepB.setForeground(Color.YELLOW);
- appB.setSize(100,20);
- appB.setLocation(210, 280);
- appB.setForeground(Color.YELLOW);
- //les JTextField
- nomT.setSize(200,20);
- nomT.setLocation(315, 10);
- nomT.setEditable(false);
- contT.setSize(200,20);
- contT.setLocation(315, 40);
- contT.setEditable(false);
- prixT.setSize(200,20);
- prixT.setLocation(315, 70);
- prixT.setEditable(false);
- anneeT.setSize(200,20);
- anneeT.setLocation(315, 100);
- anneeT.setEditable(false);
- qteT.setSize(200,20);
- qteT.setLocation(315, 130);
- qteT.setEditable(false);
- catT.setSize(200,20);
- catT.setLocation(315, 160);
- catT.setEditable(false);
- regT.setSize(200,20);
- regT.setLocation(315, 190);
- regT.setEditable(false);
- paysT.setSize(200,20);
- paysT.setLocation(315, 220);
- paysT.setEditable(false);
- cepT.setSize(200,20);
- cepT.setLocation(315, 250);
- cepT.setEditable(false);
- appT.setSize(200,20);
- appT.setLocation(315, 280);
- appT.setEditable(false);
- panVins.setBackground(colorBack);
- panVins.setBorder(BorderFactory.createLineBorder(Color.black));
- //Partie Gauche
- panVins.add(monVin);
- panVins.add(mesVins);
- //Les JLabels
- panVins.add(nomB);
- panVins.add(contB);
- panVins.add(prixB);
- panVins.add(anneeB);
- panVins.add(qteB);
- panVins.add(catB);
- panVins.add(regB);
- panVins.add(paysB);
- panVins.add(cepB);
- panVins.add(appB);
- //les JTextField
- panVins.add(nomT);
- panVins.add(contT);
- panVins.add(prixT);
- panVins.add(anneeT);
- panVins.add(qteT);
- panVins.add(catT);
- panVins.add(regT);
- panVins.add(paysT);
- panVins.add(cepT);
- panVins.add(appT);
- panVins.setVisible(true);
- panVins.setLayout(null);
- }
- private void ajoutVins() {
- //NOUVELLES BOUTEILLE
- JLabel boutLbl = new JLabel("BOUTEILLE");
- JLabel nomBLbl = new JLabel("Nom :");
- JLabel contBLbl = new JLabel("Contenance :");
- JLabel prixBLbl = new JLabel("Prix :");
- JLabel anneeBLbl = new JLabel("Annee :");
- JLabel qteBLbl = new JLabel("Quantité :");
- JLabel cepBLbl = new JLabel("Cépage :");
- JLabel catBLbl = new JLabel("Catégorie :");
- JLabel paysBLbl = new JLabel("Pays :");
- JLabel regBLbl = new JLabel("Région :");
- JLabel appBLbl = new JLabel("Appéllation :");
- JTextField nomTF = new JTextField();
- JTextField contTF = new JTextField();
- JTextField prixTF = new JTextField();
- JTextField anneeTF = new JTextField();
- JTextField qteTF = new JTextField();
- JComboBox cepCB = new JComboBox();
- JComboBox appCB = new JComboBox();
- JComboBox regCB = new JComboBox();
- JComboBox paysCB = new JComboBox();
- JComboBox catCB = new JComboBox();
- //NOUVELLES CATEGORIE
- JLabel catLbl = new JLabel("CATEGORIE");
- JLabel libelleCLbl = new JLabel("Libellé :");
- JTextField libelleCTF = new JTextField();
- //NOUVEAU CEPAGE
- JLabel cepLbl = new JLabel("CEPAGE");
- JLabel libelleCepLbl = new JLabel("Libellé :");
- JTextField libelleCepTF = new JTextField();
- //NOUVELLE APPELLATION
- JLabel appLbl = new JLabel("APPELLATION");
- JLabel libelleAppLbl = new JLabel("Libellé :");
- JTextField libelleAppTF = new JTextField();
- //NOUVEAU PAYS
- JLabel paysLbl = new JLabel("PAYS");
- JLabel codePLbl = new JLabel("Code :");
- JLabel libellePLbl = new JLabel("Libellé :");
- JTextField codePTF = new JTextField();
- JTextField libellePTF = new JTextField();
- //NOUVELLE REGION
- JLabel regRLbl = new JLabel("REGION");
- JLabel libelleRLbl = new JLabel("Libellé :");
- JTextField libelleRTF = new JTextField();
- JButton boutBtn = new JButton("Ajouter");
- JButton cepBtn = new JButton("Ajouter");
- JButton appBtn = new JButton("Ajouter");
- JButton regBtn = new JButton("Ajouter");
- JButton paysBtn = new JButton("Ajouter");
- JButton catBtn = new JButton("Ajouter");
- boutLbl.setSize(90,15);
- boutLbl.setLocation(0,0);
- boutLbl.setForeground(Color.YELLOW);
- nomBLbl.setSize(90,15);
- nomBLbl.setLocation(0,15);
- nomBLbl.setForeground(Color.YELLOW);
- nomTF.setSize(90,15);
- nomTF.setLocation(95,15);
- contBLbl.setSize(90,15);
- contBLbl.setLocation(0,30);
- contBLbl.setForeground(Color.YELLOW);
- contTF.setSize(90,15);
- contTF.setLocation(95,30);
- prixBLbl.setSize(90,15);
- prixBLbl.setLocation(0,45);
- prixBLbl.setForeground(Color.YELLOW);
- prixTF.setSize(90,15);
- prixTF.setLocation(95,45);
- anneeBLbl.setSize(90,15);
- anneeBLbl.setLocation(0,60);
- anneeBLbl.setForeground(Color.YELLOW);
- anneeTF.setSize(90,15);
- anneeTF.setLocation(95,60);
- qteBLbl.setSize(90,15);
- qteBLbl.setLocation(0,75);
- qteBLbl.setForeground(Color.YELLOW);
- qteTF.setSize(90,15);
- qteTF.setLocation(95,75);
- catBLbl.setSize(90,15);
- catBLbl.setLocation(0,90);
- catBLbl.setForeground(Color.YELLOW);
- catCB.setSize(90,15);
- catCB.setLocation(95,90);
- paysBLbl.setSize(90,15);
- paysBLbl.setLocation(0,105);
- paysBLbl.setForeground(Color.YELLOW);
- paysCB.setSize(90,15);
- paysCB.setLocation(95,105);
- regBLbl.setSize(90,15);
- regBLbl.setLocation(0,120);
- regBLbl.setForeground(Color.YELLOW);
- regCB.setSize(90,15);
- regCB.setLocation(95,120);
- cepBLbl.setSize(90,15);
- cepBLbl.setLocation(0,135);
- cepBLbl.setForeground(Color.YELLOW);
- cepCB.setSize(90,15);
- cepCB.setLocation(95,135);
- appBLbl.setSize(90,15);
- appBLbl.setLocation(0,150);
- appBLbl.setForeground(Color.YELLOW);
- appCB.setSize(90,15);
- appCB.setLocation(95,150);
- boutBtn.setSize(185,20);
- boutBtn.setLocation(0,170);
- boutBtn.setName("boutBtn");
- boutBtn.addActionListener(this);
- catLbl.setSize(90,15);
- catLbl.setLocation(0,215);
- catLbl.setForeground(Color.YELLOW);
- libelleCLbl.setSize(90,15);
- libelleCLbl.setLocation(0,230);
- libelleCLbl.setForeground(Color.YELLOW);
- libelleCTF.setSize(90,15);
- libelleCTF.setLocation(95,230);
- catBtn.setSize(185,20);
- catBtn.setLocation(0,250);
- catBtn.setName("catBtn");
- catBtn.addActionListener(this);
- //2EME COLONNE
- cepLbl.setSize(90,15);
- cepLbl.setLocation(200,0);
- cepLbl.setForeground(Color.YELLOW);
- libelleCepLbl.setSize(90,15);
- libelleCepLbl.setLocation(200,15);
- libelleCepLbl.setForeground(Color.YELLOW);
- libelleCepTF.setSize(90,15);
- libelleCepTF.setLocation(295,15);
- cepBtn.setSize(185,20);
- cepBtn.setLocation(200,35);
- cepBtn.setName("cepBtn");
- cepBtn.addActionListener(this);
- appLbl.setSize(90,15);
- appLbl.setLocation(200,80);
- appLbl.setForeground(Color.YELLOW);
- libelleAppLbl.setSize(90,15);
- libelleAppLbl.setLocation(200,95);
- libelleAppLbl.setForeground(Color.YELLOW);
- libelleAppTF.setSize(90,15);
- libelleAppTF.setLocation(295,95);
- appBtn.setSize(185,20);
- appBtn.setLocation(200,115);
- appBtn.setName("appBtn");
- appBtn.addActionListener(this);
- paysLbl.setSize(90,15);
- paysLbl.setLocation(200,160);
- paysLbl.setForeground(Color.YELLOW);
- codePLbl.setSize(90,15);
- codePLbl.setLocation(200,175);
- codePLbl.setForeground(Color.YELLOW);
- codePTF.setSize(90,15);
- codePTF.setLocation(295,175);
- libellePLbl.setSize(90,15);
- libellePLbl.setLocation(200,190);
- libellePLbl.setForeground(Color.YELLOW);
- libellePTF.setSize(90,15);
- libellePTF.setLocation(295,190);
- paysBtn.setSize(185,20);
- paysBtn.setLocation(200,210);
- paysBtn.setName("paysBtn");
- paysBtn.addActionListener(this);
- regRLbl.setSize(90,15);
- regRLbl.setLocation(200,255);
- regRLbl.setForeground(Color.YELLOW);
- libelleRLbl.setSize(90,15);
- libelleRLbl.setLocation(200,270);
- libelleRLbl.setForeground(Color.YELLOW);
- libelleRTF.setSize(90,15);
- libelleRTF.setLocation(295,270);
- regBtn.setSize(185,20);
- regBtn.setLocation(200,290);
- regBtn.setName("regBtn");
- regBtn.addActionListener(this);
- panAjout.add(boutLbl);
- panAjout.add(nomBLbl);
- panAjout.add(contBLbl);
- panAjout.add(prixBLbl);
- panAjout.add(anneeBLbl);
- panAjout.add(qteBLbl);
- panAjout.add(cepBLbl);
- panAjout.add(regBLbl);
- panAjout.add(appBLbl);
- panAjout.add(paysBLbl);
- panAjout.add(catBLbl);
- panAjout.add(catCB);
- panAjout.add(paysCB);
- panAjout.add(regCB);
- panAjout.add(cepCB);
- panAjout.add(appCB);
- panAjout.add(nomTF);
- panAjout.add(contTF);
- panAjout.add(prixTF);
- panAjout.add(anneeTF);
- panAjout.add(qteTF);
- panAjout.add(catLbl);
- panAjout.add(libelleCLbl);
- panAjout.add(libelleCTF);
- panAjout.add(cepLbl);
- panAjout.add(libelleCepLbl);
- panAjout.add(libelleCepTF);
- panAjout.add(appLbl);
- panAjout.add(libelleAppLbl);
- panAjout.add(libelleAppTF);
- panAjout.add(paysLbl);
- panAjout.add(codePLbl);
- panAjout.add(libellePLbl);
- panAjout.add(codePTF);
- panAjout.add(libellePTF);
- panAjout.add(regRLbl);
- panAjout.add(libelleRLbl);
- panAjout.add(libelleRTF);
- panAjout.add(boutBtn);
- panAjout.add(catBtn);
- panAjout.add(cepBtn);
- panAjout.add(regBtn);
- panAjout.add(appBtn);
- panAjout.add(paysBtn);
- panAjout.setBackground(colorBack);
- panAjout.setBorder(BorderFactory.createLineBorder(Color.black));
- panAjout.setLayout(null);
- panAjout.setVisible(true);
- }
- private void suppModVins() {
- JTextField monVin = new JTextField();
- JList mesVins = new JList();
- JLabel nomB = new JLabel("Bouteille : ");
- JLabel contB = new JLabel("Contenance : ");
- JLabel prixB = new JLabel("Prix : ");
- JLabel anneeB = new JLabel("Année :");
- JLabel qteB = new JLabel("Quantité : ");
- JLabel catB = new JLabel("Catégorie : ");
- JLabel regB = new JLabel("Region : ");
- JLabel paysB = new JLabel("Pays : ");
- JLabel cepB = new JLabel("Cepage : ");
- JLabel appB = new JLabel("Appellation : ");
- JTextField nomT = new JTextField();
- JTextField contT = new JTextField();
- JTextField prixT = new JTextField();
- JTextField anneeT = new JTextField();
- JTextField qteT = new JTextField();
- JTextField catT = new JTextField();
- JTextField regT = new JTextField();
- JTextField paysT = new JTextField();
- JTextField cepT = new JTextField();
- JTextField appT = new JTextField();
- JButton majB = new JButton("Mettre à jour");
- JButton suppB = new JButton("Supprimer");
- monVin.setSize(200,20);
- monVin.setLocation(5, 10);
- mesVins.setSize(200, 300);
- mesVins.setLocation(5, 40);
- mesVins.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- mesVins.setLayoutOrientation(JList.HORIZONTAL_WRAP);
- panSuppMod.setBackground(colorBack);
- panSuppMod.setBorder(BorderFactory.createLineBorder(Color.black));
- //Partie Gauche
- panSuppMod.add(monVin);
- panSuppMod.add(mesVins);
- //Les JLabel
- nomB.setSize(100,20);
- nomB.setLocation(210, 10);
- nomB.setForeground(Color.YELLOW);
- contB.setSize(100,20);
- contB.setLocation(210, 40);
- contB.setForeground(Color.YELLOW);
- prixB.setSize(100,20);
- prixB.setLocation(210, 70);
- prixB.setForeground(Color.YELLOW);
- anneeB.setSize(100,20);
- anneeB.setLocation(210, 100);
- anneeB.setForeground(Color.YELLOW);
- qteB.setSize(100,20);
- qteB.setLocation(210, 130);
- qteB.setForeground(Color.YELLOW);
- catB.setSize(100,20);
- catB.setLocation(210, 160);
- catB.setForeground(Color.YELLOW);
- regB.setSize(100,20);
- regB.setLocation(210, 190);
- regB.setForeground(Color.YELLOW);
- paysB.setSize(100,20);
- paysB.setLocation(210, 220);
- paysB.setForeground(Color.YELLOW);
- cepB.setSize(100,20);
- cepB.setLocation(210, 250);
- cepB.setForeground(Color.YELLOW);
- appB.setSize(100,20);
- appB.setLocation(210, 280);
- appB.setForeground(Color.YELLOW);
- //les JTextField
- nomT.setSize(200,20);
- nomT.setLocation(315, 10);
- contT.setSize(200,20);
- contT.setLocation(315, 40);
- prixT.setSize(200,20);
- prixT.setLocation(315, 70);
- anneeT.setSize(200,20);
- anneeT.setLocation(315, 100);
- qteT.setSize(200,20);
- qteT.setLocation(315, 130);
- catT.setSize(200,20);
- catT.setLocation(315, 160);
- regT.setSize(200,20);
- regT.setLocation(315, 190);
- paysT.setSize(200,20);
- paysT.setLocation(315, 220);
- cepT.setSize(200,20);
- cepT.setLocation(315, 250);
- appT.setSize(200,20);
- appT.setLocation(315, 280);
- majB.setSize(140,30);
- majB.setLocation(210, 310);
- suppB.setSize(140, 30);
- suppB.setLocation(370, 310);
- panSuppMod.add(nomB);
- panSuppMod.add(contB);
- panSuppMod.add(prixB);
- panSuppMod.add(anneeB);
- panSuppMod.add(qteB);
- panSuppMod.add(catB);
- panSuppMod.add(regB);
- panSuppMod.add(paysB);
- panSuppMod.add(cepB);
- panSuppMod.add(appB);
- //les JTextField
- panSuppMod.add(nomT);
- panSuppMod.add(contT);
- panSuppMod.add(prixT);
- panSuppMod.add(anneeT);
- panSuppMod.add(qteT);
- panSuppMod.add(catT);
- panSuppMod.add(regT);
- panSuppMod.add(paysT);
- panSuppMod.add(cepT);
- panSuppMod.add(appT);
- panSuppMod.add(majB);
- panSuppMod.add(suppB);
- panSuppMod.setLayout(null);
- panSuppMod.setVisible(true);
- }
- @Override
- public void actionPerformed(ActionEvent arg0) {
- // TODO Auto-generated method stub
- Object obj = arg0.getSource();
- if (((JButton) obj).getName()=="boutBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Bouteille","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- if (((JButton) obj).getName()=="cepBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Cépage","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- if (((JButton) obj).getName()=="catBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Catégorie","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- if (((JButton) obj).getName()=="regBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Région","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- if (((JButton) obj).getName()=="appBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Appellation","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- if (((JButton) obj).getName()=="paysBtn"){
- JOptionPane.showMessageDialog(this,"Bouton Pays","Le Message du Bouton",JOptionPane.INFORMATION_MESSAGE,null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement