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
| import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
public class Menu extends JPanel{
private final Graphe graphe;
JComboBox cItiOri;
JComboBox cItiDest;
public Menu(final Fenetre fen, Graphe g)
{
graphe=g;
this.setBackground(Color.lightGray);
setSize(200, 600);
setLayout(new FlowLayout(FlowLayout.CENTER));
Box vBox = Box.createVerticalBox();
Box hBox = Box.createHorizontalBox();
Box hBox1 = Box.createHorizontalBox();
Box hBox2 = Box.createHorizontalBox();
Box hBox3 = Box.createHorizontalBox();
JLabel ligne = new JLabel("Situer une ligne");
hBox.add(ligne);
hBox.add(Box.createHorizontalGlue());
Vector listeLigne = getListLigne();
JComboBox cLigne = new JComboBox(listeLigne);
cLigne.addActionListener(new selectLigne());
hBox.add(cLigne);
vBox.add(hBox);
vBox.add(Box.createVerticalStrut(30));
JLabel station = new JLabel("Situer une station");
hBox1.add(station);
hBox1.add(Box.createHorizontalGlue());
Vector listeStation = getListStation();
JComboBox cStation = new JComboBox(listeStation);
cStation.addActionListener(new selectStation());
hBox1.add(cStation);
vBox.add(hBox1);
vBox.add(Box.createVerticalStrut(30));
JLabel itineraire = new JLabel("Itinéraire : ");
vBox.add(itineraire);
cItiOri = new JComboBox(listeStation);
hBox2.add(cItiOri);
hBox2.add(Box.createHorizontalStrut(5));
cItiDest = new JComboBox(listeStation);
hBox2.add(cItiDest);
vBox.add(hBox2);
vBox.add(Box.createVerticalStrut(30));
JButton bOk = new JButton("Validez");
bOk.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent evenement)
{
String ori = cItiOri.getSelectedItem().toString();
String dest = cItiDest.getSelectedItem().toString();
Graphe.chemin(graphe, Graphe.getStation(ori).get_num(), Graphe.getStation(dest).get_num());
}
});
vBox.add(bOk);
vBox.add(Box.createVerticalStrut(60));
JButton bReset = new JButton("Recharger");
bReset.addActionListener(
new ActionListener()
{
public void actionPerformed (ActionEvent evenement)
{
Graphe.resetStation();
}
}
);
hBox3.add(bReset);
hBox3.add(Box.createHorizontalStrut(5));
JButton bLignes = new JButton("changer de fichier");
bLignes.addActionListener(
new ActionListener()
{
public void actionPerformed (ActionEvent evenement)
{
String[] fichier = {"lignes.data", "lignes2.data", "lignes3.data", "lignes4.data",
"lignes5.data", "lignes6.data"};
String fic = (String)JOptionPane.showInputDialog (fen, "Choisissez votre fichier d'entrée",
"Choix du fichier en entrée", //titre de la boîte
JOptionPane.QUESTION_MESSAGE, null, fichier,fichier[0]);
graphe.changementFichier(fic);
}
}
);
hBox3.add(bLignes);
vBox.add(hBox3);
this.add(vBox);
} |
Partager