1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Vector;
public class MediatheqFrm extends JFrame implements ActionListener
{
public MediatheqFrm()
{
super("Médiathèque");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.init();
}
private void init()
{
...
//Panel
Component CDPanel = this.MakeCDPanelWithBorderLayout();
Component VidPanel = this.MakeVideoPanelWithBorderLayout();
Component PersPanel = this.MakePersWithBorderLayout();
//Boîte à onglets
ImageIcon CDIcon = new ImageIcon("./cd.gif");
ImageIcon VideoIcon = new ImageIcon("./video.gif");
ImageIcon PersIcon = new ImageIcon("./personne.gif");
ImageIcon EmpIcon = new ImageIcon("./emprunt.gif");
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("", CDIcon, CDPanel, "Liste des CD");
tabbedPane.addTab("", VideoIcon, VidPanel, "Listes des Videos");
tabbedPane.addTab("", PersIcon, PersPanel, "Listes des Personnes");
tabbedPane.addTab("", EmpIcon, new JPanel(), "Listes des Emprunts");
//Placement de la barre d'outil dans la fenêtre
this.setJMenuBar(barreMenu);
this.setSize(600,400);
this.add(tabbedPane);
}
...
...
...
public JPanel MakeCDPanelWithBorderLayout()
{
JPanel panelWithBorderLayout = new JPanel(false);
panelWithBorderLayout.setLayout(new BorderLayout());
JPanel panelGridLayout = this.MakeCDPanelWithGridLayout();
panelWithBorderLayout.add("West", panelGridLayout);
JList CDList = new JList(); // <================================Ici, j'ai créé ma JList
panelWithBorderLayout.add("Center", CDList);
return panelWithBorderLayout;
}
...
...
...
public void actionPerformed(ActionEvent evt)
{
String action = evt.getActionCommand();
if (action.equals("Quitter"))
{
System.exit(0);
}
else if (action.equals("CDAjouter"))
{
System.out.println("Ajout d'un CD");
}
...
...
else if (action.equals("ChargeDonnees"))
{
System.out.println("Chargement des données");
//Création de la BDD
Database BDD = new Database();
//Chargement des données
BDD.chargeLesDonneesCD("CD");
BDD.chargeLesDonneesVideo("Video");
BDD.chargeLesDonneesPersonne("Personne");
//Vectoriser les données
ArrayList lesCD = BDD.getLesCD();
Vector dataList = new Vector();
for (int i = 0; lesCD.size() > i; i++)
{
CD unCD = (CD)lesCD.get(i);
dataList.add(unCD.getNom());
}
CDList = new JList(dataList); // <===================================Ici CDList cannot Be Resolved
}
} |
Partager