Advertisement
Guest User

testest

a guest
Jun 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. package info1.vue;
  2.  
  3. import com.mashape.unirest.http.exceptions.UnirestException;
  4. import info1.controleurs.ChoixPartieRetour;
  5. import info1.network.BadIdException;
  6. import info1.network.Game;
  7. import info1.network.Network;
  8.  
  9. import javax.swing.*;
  10. import java.awt.*;
  11. import java.util.List;
  12. import java.util.Vector;
  13.  
  14. public class ListeParties extends JFrame {
  15.  
  16. private Network serveur;
  17. private List<Game> listePartie;
  18.  
  19. private JButton retour;
  20. private JButton rejoindre;
  21. private JList liste;
  22.  
  23. public ListeParties(String titre) {
  24.  
  25. super(titre);
  26.  
  27. JPanel general = new JPanel();
  28. general.setLayout(new BorderLayout());
  29. this.getContentPane().add(general);
  30.  
  31. JPanel panelListe = new JPanel();
  32. panelListe.setLayout(new FlowLayout());
  33. JPanel panelBoutons = new JPanel();
  34. panelBoutons.setLayout(new GridLayout(1,4,100,0));
  35. retour = new JButton("Retour");
  36. rejoindre = new JButton("Rejoindre");
  37. JPanel vide = new JPanel();
  38. JPanel vide2 = new JPanel();
  39.  
  40. panelBoutons.add(vide);
  41. panelBoutons.add(retour);
  42. panelBoutons.add(rejoindre);
  43. panelBoutons.add(vide2);
  44.  
  45. try {
  46. listePartie = this.getListePartie();
  47. } catch (UnirestException e) {
  48. e.printStackTrace();
  49. }
  50.  
  51. liste = new JList((Vector) listePartie);
  52. panelListe.add(liste);
  53. liste.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  54. liste.setLayoutOrientation(JList.HORIZONTAL_WRAP);
  55. liste.setPreferredSize(new Dimension(1000,700));
  56.  
  57. general.add(panelListe, BorderLayout.CENTER);
  58. general.add(panelBoutons, BorderLayout.SOUTH);
  59.  
  60.  
  61. //Listener
  62.  
  63. ChoixPartieRetour ret = new ChoixPartieRetour(this);
  64. retour.addActionListener(ret);
  65.  
  66.  
  67.  
  68. this.setPreferredSize(new Dimension(1200, 800));
  69. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  70. this.pack();
  71. this.setVisible(true);
  72.  
  73. }
  74.  
  75. public static void main(String[] args) {
  76. new ListeParties("Choix d'une partie" );
  77.  
  78. }
  79.  
  80. public List<Game> getListePartie() throws UnirestException {
  81. return serveur.listInitializedGames("http://localhost:3000/api/v0");
  82. }
  83.  
  84.  
  85.  
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement