Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package info1.vue;
- import com.mashape.unirest.http.exceptions.UnirestException;
- import info1.controleurs.ChoixPartieRetour;
- import info1.network.BadIdException;
- import info1.network.Game;
- import info1.network.Network;
- import javax.swing.*;
- import java.awt.*;
- import java.util.List;
- import java.util.Vector;
- public class ListeParties extends JFrame {
- private Network serveur;
- private List<Game> listePartie;
- private JButton retour;
- private JButton rejoindre;
- private JList liste;
- public ListeParties(String titre) {
- super(titre);
- JPanel general = new JPanel();
- general.setLayout(new BorderLayout());
- this.getContentPane().add(general);
- JPanel panelListe = new JPanel();
- panelListe.setLayout(new FlowLayout());
- JPanel panelBoutons = new JPanel();
- panelBoutons.setLayout(new GridLayout(1,4,100,0));
- retour = new JButton("Retour");
- rejoindre = new JButton("Rejoindre");
- JPanel vide = new JPanel();
- JPanel vide2 = new JPanel();
- panelBoutons.add(vide);
- panelBoutons.add(retour);
- panelBoutons.add(rejoindre);
- panelBoutons.add(vide2);
- try {
- listePartie = this.getListePartie();
- } catch (UnirestException e) {
- e.printStackTrace();
- }
- liste = new JList((Vector) listePartie);
- panelListe.add(liste);
- liste.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- liste.setLayoutOrientation(JList.HORIZONTAL_WRAP);
- liste.setPreferredSize(new Dimension(1000,700));
- general.add(panelListe, BorderLayout.CENTER);
- general.add(panelBoutons, BorderLayout.SOUTH);
- //Listener
- ChoixPartieRetour ret = new ChoixPartieRetour(this);
- retour.addActionListener(ret);
- this.setPreferredSize(new Dimension(1200, 800));
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.pack();
- this.setVisible(true);
- }
- public static void main(String[] args) {
- new ListeParties("Choix d'une partie" );
- }
- public List<Game> getListePartie() throws UnirestException {
- return serveur.listInitializedGames("http://localhost:3000/api/v0");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement