Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. /**
  2. *
  3. * @author David Caron
  4. *
  5. */
  6.  
  7. package gui;
  8.  
  9. import tda.InterfaceTDA;
  10. import tda.InterfaceTDAIterateur;
  11.  
  12. import javax.swing.*;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.ActionListener;
  15.  
  16.  
  17. public class PanneauIterateur extends JPanel{
  18.  
  19. // Des attributs à ajouter
  20. private InterfaceTDAIterateur tda;
  21. PanneauCentral panneauCentral;
  22. JButton boutonPremier;
  23. JButton boutonDernier;
  24. JButton boutonSuivant;
  25. JButton boutonPrecedent;
  26. JComboBox modesInsertion;
  27.  
  28. public void initComposantes(){
  29. boutonPremier = new JButton("<|");
  30. boutonDernier = new JButton("|>");
  31. boutonSuivant = new JButton(">>");
  32. boutonPrecedent = new JButton("<<");
  33. modesInsertion = new JComboBox();
  34. add(boutonPremier);
  35. add(boutonPrecedent);
  36. add(boutonSuivant);
  37. add(boutonDernier);
  38. add(modesInsertion);
  39. }
  40.  
  41. /**
  42. *
  43. * @param tda
  44. * @param panneauCentral
  45. */
  46. public PanneauIterateur(InterfaceTDA tda, PanneauCentral panneauCentral) {
  47. this.panneauCentral = panneauCentral;
  48. initComposantes();
  49. setVisible(false);
  50. }
  51.  
  52. /**
  53. *
  54. * @param tda
  55. */
  56. public void setTDA(InterfaceTDA tda) {
  57. setVisible(false);
  58. if(tda.implementeIterateur()) {
  59. this.tda = (InterfaceTDAIterateur) tda;
  60. setVisible(true);
  61. }
  62. }
  63.  
  64. /**
  65. * Écouteur premier
  66. */
  67. class ecouteurPremier implements ActionListener {
  68. public void actionPerformed(ActionEvent event) {
  69. if (tda.estVide() || tda.getPosition() == 0 ){
  70. JOptionPane.showMessageDialog(null,
  71. "Le TDA est vide ou Position TDA Deja sur le Premier");
  72. }
  73. tda.setPcDebut();
  74. panneauCentral.afficherTDA(tda);
  75. }
  76. }
  77.  
  78. /**
  79. * Écouteur dernier
  80. */
  81. class ecouteurDernier implements ActionListener {
  82. public void actionPerformed(ActionEvent event) {
  83. if (tda.estVide() || tda.getPosition() == tda.getNbElements() ){
  84. JOptionPane.showMessageDialog(null,
  85. "Le TDA est vide ou Position TDA Deja sur le Dernier");
  86. }
  87. tda.setPcFin();
  88. panneauCentral.afficherTDA(tda);
  89. }
  90. }
  91.  
  92.  
  93. /**
  94. * Écouteur suivant
  95. */
  96. class ecouteurSuivant implements ActionListener {
  97. public void actionPerformed(ActionEvent event) {
  98. if (tda.getPosition() == tda.getNbElements() ){
  99. JOptionPane.showMessageDialog(null,
  100. "Il n'y as pas de suivant");
  101. }
  102. if (tda.estVide()){
  103. JOptionPane.showMessageDialog(null,
  104. "Le TDA est Vide");
  105. }
  106.  
  107. tda.setPcSuivant();
  108. panneauCentral.afficherTDA(tda);
  109. }
  110. }
  111.  
  112.  
  113. /**
  114. * Écouteur precedent
  115. */
  116. class ecouteurPrecedent implements ActionListener {
  117. public void actionPerformed(ActionEvent event) {
  118. if (tda.getPosition() == 1 ){
  119. JOptionPane.showMessageDialog(null,
  120. "Il n'y as pas de precedent");
  121. }
  122. if (tda.estVide()){
  123. JOptionPane.showMessageDialog(null,
  124. "Le TDA est Vide");
  125. }
  126.  
  127. tda.setPcPrecedent();
  128. panneauCentral.afficherTDA(tda);
  129. }
  130.  
  131. }
  132. }
  133.  
  134.  
  135. /**
  136. * Écouteur modeInsertion
  137. */
  138. class ecouteurModeInsertion implements ActionListener {
  139. public void actionPerformed(ActionEvent event) {
  140. if(InterfaceTDAIterateur.APRES){
  141.  
  142. }
  143. if(InterfaceTDAIterateur.AVANT){
  144.  
  145. }
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement