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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
import javax.swing.*;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.border.EmptyBorder;
import javax.swing.border.*;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.BorderFactory;
import javax.swing.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.ItemListener;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Graphique extends JFrame {
public Graphique() {
super("Projet Train");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Container contentPane = this.getContentPane();
//BorderLayout layout = new BorderLayout();
//contentPane.setLayout(layout);
String voie;
JTextField display= new JTextField(5);
Container tout = getContentPane();
BorderLayout monLayout = new BorderLayout();
tout.setLayout(monLayout);
//PARTIE CHOIX RAME
JPanel choix = new JPanel(new BorderLayout());
String[] combobox1 = { "0", "1", "2",
"3", "4", "5",
"6", "7" };
JComboBox rame = new JComboBox(combobox1);
rame.setSelectedIndex(4);
// Le PROB est là
rame.addActionListener(this);
choix.add(rame ,BorderLayout.CENTER);
choix.add(display,BorderLayout.WEST);
choix.setBorder(BorderFactory.createTitledBorder("Choix de la rame sur laquelle vous voullez travailler"));
tout.add(choix,BorderLayout.NORTH);
//PARTIE MOTRICE
JTextField poids = new JTextField(5);
JPanel motrice = new JPanel(new GridLayout(0,1));
JPanel m1 = new JPanel(new GridLayout(2, 1));
JPanel m2 = new JPanel();
JPanel m3 = new JPanel();
JPanel m4 = new JPanel(new GridLayout(2, 1));
JButton ajoutermotrice = new JButton("Ajouter Motrice");
m1.add(ajoutermotrice);
JButton retirerdmotrice = new JButton("Retirer la dernière motrice ajoutée");
m1.add(retirerdmotrice);
;
tout.add(motrice,BorderLayout.WEST);
motrice.add(m1);
motrice.add(m2);
motrice.add(m3);
motrice.add(m4);
m2.setLayout(new GridLayout(3,1));
JRadioButton vapeur = new JRadioButton("Vapeur");
vapeur.setSelected(true);
JRadioButton electrique = new JRadioButton("Electrique");
JRadioButton diesel = new JRadioButton("Diesel");
ButtonGroup type = new ButtonGroup();
type.add(diesel);
type.add(electrique);
type.add(vapeur);
m2.add(vapeur);
m2.add(electrique);
m2.add(diesel);
m2.setBorder(BorderFactory.createTitledBorder("Type"));
m3.setLayout(new GridLayout(2,1));
JRadioButton poussee = new JRadioButton("Poussée");
vapeur.setSelected(true);
JRadioButton traction = new JRadioButton("Traction");
ButtonGroup mode = new ButtonGroup();
mode.add(poussee);
mode.add(traction);
m3.add(traction);
m3.add(poussee);
m3.setBorder(BorderFactory.createTitledBorder("Mode"));
JLabel messagepoids = new JLabel(" Entrez le poids de la motrice");
m4.add(poids);
m4.add(messagepoids);
m4.setBorder(BorderFactory.createTitledBorder("Poids"));
motrice.setBorder(BorderFactory.createTitledBorder("Menu Motrice"));
//PARTIE VOITURE
JTextField Nbre = new JTextField(5);
JPanel voiture = new JPanel(new GridLayout(4,1));
JPanel v1 = new JPanel(new GridLayout(2, 1));
JPanel v2 = new JPanel(new GridLayout(2, 1));
JButton ajoutervoiture = new JButton("Ajouter Voiture");
v1.add(ajoutervoiture);
JButton retirerdvoiture = new JButton("Retirer la dernière voiture ajoutée");
v1.add(retirerdvoiture);
voiture.add(v1);
JLabel messagepassagers = new JLabel(" Entrez le nombre de passagers");
v2.add(Nbre);
v2.add(messagepassagers);
v2.setBorder(BorderFactory.createTitledBorder("Nbe Passagers"));
voiture.add(v2);
voiture.setBorder(BorderFactory.createTitledBorder("Menu voiture"));
tout.add(voiture,BorderLayout.EAST);
//PARTIE AFFICHAGE RESULTAT
JPanel rame = new JPanel();
rame.setBorder(BorderFactory.createTitledBorder("Gare"));
JPanel rame1 = new JPanel(new GridLayout(0,1));
JLabel lvoie0 = new JLabel(" Voie 0");
JTextField voie0 = new JTextField(50);
rame1.add(lvoie0);
rame1.add(voie0);
JLabel lvoie1 = new JLabel(" Voie 1");
JTextField voie1 = new JTextField(50);
rame1.add(lvoie1);
rame1.add(voie1);
JLabel lvoie2 = new JLabel(" Voie 2");
JTextField voie2 = new JTextField(50);
rame1.add(lvoie2);
rame1.add(voie2);
JLabel lvoie3 = new JLabel(" Voie 3");
JTextField voie3 = new JTextField(50);
rame1.add(lvoie3);
rame1.add(voie3);
JLabel lvoie4 = new JLabel(" Voie 4");
JTextField voie4 = new JTextField(50);
rame1.add(lvoie4);
rame1.add(voie4);
JLabel lvoie5 = new JLabel(" Voie 5");
JTextField voie5 = new JTextField(50);
rame1.add(lvoie5);
rame1.add(voie5);
JLabel lvoie6 = new JLabel(" Voie 6");
JTextField voie6 = new JTextField(50);
rame1.add(lvoie6);
rame1.add(voie6);
JLabel lvoie7 = new JLabel(" Voie 7");
JTextField voie7 = new JTextField(50);
rame1.add(lvoie7);
rame1.add(voie7);
rame.add(rame1);
tout.add(rame,BorderLayout.CENTER);
//PARTIE SOUTH
JPanel sud = new JPanel(new BorderLayout());
sud.setBorder(BorderFactory.createTitledBorder("Option"));
JPanel sud1 = new JPanel(new GridLayout(2,1));
JPanel sud2 = new JPanel(new BorderLayout());
JPanel sud21 = new JPanel(new GridLayout(2,1));
JPanel sud22 = new JPanel(new GridLayout(2,2));
JPanel sud3 = new JPanel(new BorderLayout());
//JPanel f1 = new JPanel(new GridLayout(2, 1));
JButton retirermotrice = new JButton("Retirer motrice ");
sud1.add(retirermotrice);
JButton retirervoiture = new JButton("Retirer voiture ");
sud1.add(retirervoiture);
JLabel mchoixm = new JLabel(" Choisir un numero de motrice");
sud21.add(mchoixm);
JComboBox choixm = new JComboBox();
choixm.setEditable(true);
JLabel vide1 = new JLabel(" ");
sud22.add(choixm);
sud22.add(vide1);
/*
JLabel mchoixramem = new JLabel(" Choisir une rame");
sud2.add(mchoixramem);
JComboBox choixramem = new JComboBox();
sud2.add(choixramem);
*/
JLabel mchoixv = new JLabel(" Choisir un numero de voiture");
sud21.add(mchoixv,BorderLayout.WEST);
JComboBox choixv = new JComboBox();
choixv.setEditable(true);
JLabel vide2 = new JLabel(" ");
sud22.add(choixv,BorderLayout.CENTER);
sud22.add(vide2);
/* JLabel mchoixramev = new JLabel(" Choisir une rame");
sud2.add(mchoixramev);
JComboBox choixramev = new JComboBox();
sud2.add(choixramev);
*/
JButton quitter = new JButton("Quitter");
sud3.add(quitter);
sud2.add(sud21,BorderLayout.WEST);
sud2.add(sud22,BorderLayout.CENTER);
//sud.add(choixrame,BorderLayout.EAST);
sud.add(sud1,BorderLayout.WEST);
sud.add(sud2,BorderLayout.CENTER);
sud.add(sud3,BorderLayout.EAST);
tout.add(sud,BorderLayout.SOUTH);
this.pack();
//this.setSize(800,600);
this.setVisible(true);
}
// Méthode principale : démarrage du programme
public static void main(String[] args) {
new Graphique();
}
} |
Partager