Voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import java.awt.*;
import java.io.*;
import javax.swing.*;
 
import java.awt.event.*;
 
 
 
 
public class FenetreFilms extends JFrame implements ActionListener
{
 
	private JLabel numéro = new JLabel("Numéro :",SwingConstants.LEFT);
	private JLabel titre = new JLabel("Titre :",SwingConstants.LEFT);
	private JLabel langue = new JLabel("Langue :",SwingConstants.LEFT);
	private JLabel texte = new JLabel("Entrez le numéro ou le titre du film");
	private JLabel img = new JLabel(new ImageIcon("images.gif")); 
	private JLabel img2 = new JLabel(new ImageIcon("images2.gif"));
	private JTextField zoneNuméro = new JTextField(10);
	private JTextField zoneTitre = new JTextField(10);
	private JTextField zoneLangue = new JTextField(10);
	private JRadioButton location = new JRadioButton("Location");
	private JRadioButton retour = new JRadioButton("Retour");
	private JButton annuler = new JButton("Annuler");
	private JButton ok = new JButton("OK");
	private JButton terminer = new JButton("Terminer");
	private JButton gauche = new JButton(new ImageIcon("precedente.gif"));
	private JButton droite = new JButton(new ImageIcon("suivante.gif"));
	private JPanel descriptions = new JPanel();
	private JPanel info = new JPanel();
	private JPanel selection = new JPanel();
	private ButtonGroup groupe = new ButtonGroup();
 
 
	//création d'un objet
	Videotheque eric = new Videotheque("Vidéo Ahuntsic");
 
 
	public FenetreFilms()
	{
		super("VIDEO AHUNTSIC");
		initComposants();
		this.pack();
		setVisible(true);
		setLocation(200,200);
 
 
 
	}
	public void initComposants(){
		Container c = getContentPane();
		c.setLayout(new BorderLayout());
		descriptions.setLayout(new FlowLayout());;
		descriptions.setBackground(Color.BLACK);
		selection.setBackground(Color.BLACK);
		texte.setForeground(Color.WHITE);
		info.setLayout(new GridLayout(5,2,10,10));
		info.setBackground(new Color(38,48,84));
		selection.setLayout(new FlowLayout());
		descriptions.add(texte);
		info.add(numéro);
		numéro.setForeground(Color.WHITE);
		zoneNuméro.addActionListener(this);
		info.add(zoneNuméro);
		info.add(titre);
		titre.setForeground(Color.WHITE);
		zoneTitre.addActionListener(this);
		info.add(zoneTitre);
		info.add(langue);
		langue.setForeground(Color.WHITE);
		zoneLangue.addActionListener(this);
		info.add(zoneLangue);
		location.addActionListener(this);
		location.setBackground(new Color(38,48,84));
		info.add(location);
		location.setForeground(Color.GREEN);
		retour.addActionListener(this);
		info.add(retour);
		retour.setForeground(Color.GREEN);
		retour.setBackground(new Color(38,48,84));
		annuler.addActionListener(this);
		selection.add(annuler);
		ok.addActionListener(this);
		selection.add(ok);
		gauche.addActionListener(this);
		gauche.setMargin(new Insets(0,0,0,0));
		gauche.setEnabled(false);
		selection.add(gauche);
		droite.addActionListener(this);
		droite.setMargin(new Insets(0,0,0,0));
		droite.setEnabled(false);
		droite.addActionListener(this);
		selection.add(droite);
		terminer.addActionListener(this);
		selection.add(terminer);
 
 
		groupe.add(retour);
		groupe.add(location);
 
 
		c.add(descriptions, BorderLayout.NORTH);
		c.add(info, BorderLayout.CENTER);
		c.add(selection, BorderLayout.SOUTH);
 
 
	}
	public void actionPerformed(ActionEvent e){
		int posi=-1;
		final int NEGATIVE=-1;
 
 
		if(e.getSource()==zoneNuméro){
			int num = Integer.parseInt(zoneNuméro.getText());
			posi= eric.rechercherFilm(num);
 
 
			if(posi==NEGATIVE)
				texte.setText("Le film demandé est inexistant");
 
			else {
				zoneTitre.setText(eric.getFilm(posi).getTitre());
				zoneLangue.setText(eric.getFilm(posi).getLangue());
				texte.setText("Cliquez sur OK pour confirmer le retour ou la location");
				gauche.setEnabled(true);
				droite.setEnabled(true);
			}
		}  
		else if(e.getSource()==zoneTitre){
				String unTitre=zoneTitre.getText();
				posi= eric.rechercherFilm(unTitre);
 
				if(posi==NEGATIVE)
					texte.setText("Le film demandé est inexistant");
				else {
					String texte= ""+eric.getFilm(posi).getNumero();
					String texte2= eric.getFilm(posi).getLangue();
					zoneNuméro.setText(texte);
					zoneLangue.setText(texte2);
 
				}
		}
		//action pour le bouton annuler
		else if ( e.getSource()==annuler)
		{
			zoneNuméro.setText("");
			zoneTitre.setText("");
			zoneLangue.setText("");
			texte.setText("Entrez le numéro ou le titre du film");
			gauche.setEnabled(false);
			droite.setEnabled(false);
 
		//louer un film ou retourner film
		} else if( e.getSource()== ok){
 
			final int NEG=-1;
			String message="";
			int numéro = Integer.parseInt(zoneNuméro.getText());
			int indice = eric.rechercherFilm(numéro);
			if(indice!=NEG){
				if(retour.isSelected()){
				message=eric.getFilm(indice).retournerFilm();
				}else
				message=eric.getFilm(indice).louerFilm();
		    texte.setText(message);
			}else
				texte.setText("Le film demandé est inexistant");
		}
 
		//action pour le bouton precedent
		else if(e.getSource()==gauche){
			int num = Integer.parseInt(zoneNuméro.getText());
			int indice = eric.rechercherFilm(num);
			indice--;
 
 
			String texte=""+eric.getFilm(indice).getNumero();
			String texte2= eric.getFilm(indice).getLangue();
			String texte3=eric.getFilm(indice).getTitre();
			zoneNuméro.setText(texte);
			zoneLangue.setText(texte2);
			zoneTitre.setText(texte3);
 
 
 
 
 
	//action pour le bouton suivant
	}else if(e.getSource()==droite){
		int num = Integer.parseInt(zoneNuméro.getText());
		int indice = eric.rechercherFilm(num);
		indice++;
 
		String texte=""+eric.getFilm(indice).getNumero();
		String texte2= eric.getFilm(indice).getLangue();
		String texte3=eric.getFilm(indice).getTitre();
		zoneNuméro.setText(texte);
		zoneLangue.setText(texte2);
		zoneTitre.setText(texte3);
 
 
 
 
		//action du bouton terminer
		}else if(e.getSource()==terminer){
 
			eric.ecrireFichier();
			eric.trierFilm();
			eric.listerFilms();
			System.exit(0);
		}
	}
 
	public void afficherFilm(int i){
		zoneNuméro.setText(""+eric.getFilm(i).getNumero());
		zoneTitre.setText(""+eric.getFilm(i).getTitre());
		zoneLangue.setText(""+eric.getFilm(i).getLangue());
	}
	public static void main(String[] args){
		FenetreFilms fenetre= new FenetreFilms();
		fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
En cliquant sur les flèches suivants ou précédents, je veux que quand je suis rendu au dernier film et que je clique sur suivant une autre fois, il faut que sa retourne au premier film et quand je suis au premier film et que je clique sur prédécédent, il faut que sa retourne sur le dernier film.

Merci