Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author David Caron
- *
- */
- package gui;
- import tda.InterfaceTDA;
- import tda.InterfaceTDAIterateur;
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class PanneauIterateur extends JPanel{
- // Des attributs à ajouter
- private InterfaceTDAIterateur tda;
- PanneauCentral panneauCentral;
- JButton boutonPremier;
- JButton boutonDernier;
- JButton boutonSuivant;
- JButton boutonPrecedent;
- JComboBox modesInsertion;
- public void initComposantes(){
- boutonPremier = new JButton("<|");
- boutonDernier = new JButton("|>");
- boutonSuivant = new JButton(">>");
- boutonPrecedent = new JButton("<<");
- modesInsertion = new JComboBox();
- add(boutonPremier);
- add(boutonPrecedent);
- add(boutonSuivant);
- add(boutonDernier);
- add(modesInsertion);
- }
- /**
- *
- * @param tda
- * @param panneauCentral
- */
- public PanneauIterateur(InterfaceTDA tda, PanneauCentral panneauCentral) {
- this.panneauCentral = panneauCentral;
- initComposantes();
- setVisible(false);
- }
- /**
- *
- * @param tda
- */
- public void setTDA(InterfaceTDA tda) {
- setVisible(false);
- if(tda.implementeIterateur()) {
- this.tda = (InterfaceTDAIterateur) tda;
- setVisible(true);
- }
- }
- /**
- * Écouteur premier
- */
- class ecouteurPremier implements ActionListener {
- public void actionPerformed(ActionEvent event) {
- if (tda.estVide() || tda.getPosition() == 0 ){
- JOptionPane.showMessageDialog(null,
- "Le TDA est vide ou Position TDA Deja sur le Premier");
- }
- tda.setPcDebut();
- panneauCentral.afficherTDA(tda);
- }
- }
- /**
- * Écouteur dernier
- */
- class ecouteurDernier implements ActionListener {
- public void actionPerformed(ActionEvent event) {
- if (tda.estVide() || tda.getPosition() == tda.getNbElements() ){
- JOptionPane.showMessageDialog(null,
- "Le TDA est vide ou Position TDA Deja sur le Dernier");
- }
- tda.setPcFin();
- panneauCentral.afficherTDA(tda);
- }
- }
- /**
- * Écouteur suivant
- */
- class ecouteurSuivant implements ActionListener {
- public void actionPerformed(ActionEvent event) {
- if (tda.getPosition() == tda.getNbElements() ){
- JOptionPane.showMessageDialog(null,
- "Il n'y as pas de suivant");
- }
- if (tda.estVide()){
- JOptionPane.showMessageDialog(null,
- "Le TDA est Vide");
- }
- tda.setPcSuivant();
- panneauCentral.afficherTDA(tda);
- }
- }
- /**
- * Écouteur precedent
- */
- class ecouteurPrecedent implements ActionListener {
- public void actionPerformed(ActionEvent event) {
- if (tda.getPosition() == 1 ){
- JOptionPane.showMessageDialog(null,
- "Il n'y as pas de precedent");
- }
- if (tda.estVide()){
- JOptionPane.showMessageDialog(null,
- "Le TDA est Vide");
- }
- tda.setPcPrecedent();
- panneauCentral.afficherTDA(tda);
- }
- }
- }
- /**
- * Écouteur modeInsertion
- */
- class ecouteurModeInsertion implements ActionListener {
- public void actionPerformed(ActionEvent event) {
- if(InterfaceTDAIterateur.APRES){
- }
- if(InterfaceTDAIterateur.AVANT){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement