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
|
package graphique.vue;
import java.awt.BorderLayout;
//import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
//import java.awt.Font;
//import java.awt.GridBagConstraints;
//import java.awt.GridBagLayout;
import java.awt.GridLayout;
//import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
//import javax.swing.JTextField;
import javax.swing.border.Border;
public class Fenetre extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
//instanciation d'un objet JFrame
// private JFrame fenetre = new JFrame();
protected JLabel label1 = new JLabel("Départ");
protected JLabel label2 = new JLabel("Arrivée");
protected JLabel label3 = new JLabel("Heure");
protected JLabel label4 = new JLabel("Date");
protected JTextArea depart = new JTextArea();
protected JTextArea arrivee = new JTextArea();
protected JPanel pan = new JPanel();
protected JPanel top = new JPanel();
// protected JComboBox combo1 = new JComboBox();
// JComboBox combo2 = new JComboBox();
// JComboBox combo3 = new JComboBox();
protected JButton recherche = new JButton("Rechercher");
public Fenetre(){
this.setTitle(" APP");
this.setSize(600,700);
this.setLocationRelativeTo(null);
//definition du grid à utiliser sur le content pane
GridLayout gl = new GridLayout(5,2);
gl.setHgap(5);
gl.setVgap(5);
this.setLayout(gl);
//date
JPanel panel4 = new JPanel(new GridLayout(0,1));
Border border4 = BorderFactory.createTitledBorder("Date");
panel4.setBorder(border4);
//heure
JPanel panel3 = new JPanel(new GridLayout(0,1));
Border border3 = BorderFactory.createTitledBorder("Heure");
panel3.setBorder(border3);
// ButtonGroup group3 = new ButtonGroup();
JComboBox<String> choix1 = new JComboBox<String>();
choix1.setPreferredSize(new Dimension(20, 20));
choix1.addItem("Départ à");
choix1.addItem("Arrivée à");
JComboBox<String> choix2 = new JComboBox<String>();
choix1.setPreferredSize(new Dimension(20, 20));
choix2.addItem("00h");
choix2.addItem("01h");
choix2.addItem("02h");
choix2.addItem("03h");
choix2.addItem("04h");
choix2.addItem("05h");
choix2.addItem("06h");
choix2.addItem("07h");
choix2.addItem("08h");
choix2.addItem("09h");
choix2.addItem("10h");
choix2.addItem("11h");
choix2.addItem("12h");
choix2.addItem("13h");
choix2.addItem("14h");
choix2.addItem("15h");
choix2.addItem("16h");
choix2.addItem("17h");
choix2.addItem("18h");
choix2.addItem("19h");
choix2.addItem("20h");
choix2.addItem("21h");
choix2.addItem("22h");
choix2.addItem("23h");
JComboBox<String> choix3 = new JComboBox<String>();
choix3.setPreferredSize(new Dimension(20, 20));
choix3.addItem("00");
choix3.addItem("05");
choix3.addItem("10");
choix3.addItem("15");
choix3.addItem("20");
choix3.addItem("25");
choix3.addItem("30");
choix3.addItem("35");
choix3.addItem("40");
choix3.addItem("45");
choix3.addItem("50");
choix3.addItem("55");
panel3.add(choix1);
panel3.add(choix2);
panel3.add(choix3);
//conception case mode
JPanel panel1 = new JPanel(new GridLayout(0,1));
Border border = BorderFactory.createTitledBorder("Modes");
panel1.setBorder(border);
ButtonGroup group = new ButtonGroup();
JRadioButton radio1 = new JRadioButton("Tous", true);
JRadioButton radio2 = new JRadioButton("Ferré (Métro, RER, SNCF, Tramway");
JRadioButton radio3 = new JRadioButton("Bus, Tramway");
group.add(radio1);
panel1.add(radio1);
group.add(radio2);
panel1.add(radio2);
group.add(radio3);
panel1.add(radio3);
//criteres
JPanel panel2 = new JPanel(new GridLayout(0,1));
Border border2 = BorderFactory.createTitledBorder("Critères");
panel2.setBorder(border2);
ButtonGroup group2 = new ButtonGroup();
JRadioButton radio4 = new JRadioButton("Le plus rapide", true);
JRadioButton radio5 = new JRadioButton("Le moins de correspondance");
group2.add(radio4);
panel2.add(radio4);
group2.add(radio5);
panel2.add(radio5);
//on fait les ajouts au content pane
this.getContentPane().add(label1);
this.getContentPane().add(label2);
this.getContentPane().add(depart);
this.getContentPane().add(arrivee);
this.getContentPane().add(panel3);
this.getContentPane().add(label4);
Container contentPane = this.getContentPane();
contentPane.add(panel1, BorderLayout.CENTER);
contentPane.add(panel2, BorderLayout.CENTER);
// this.getContentPane().add(panel1);
// this.getContentPane().add(panel2);
this.getContentPane().add(recherche);
// this.getContentPane().add(label6);
/* pan.add(label1);
pan.add(label2);
pan.add(depart);
top.add(arrivee);
//On prévient notre JFrame que notre JPanel sera son content pane
this.setContentPane(pan);
this.setContentPane(top);*/
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
/*
public class Fenetre {
public static void main(String[] args){
//instanciation d'un objet JFrame
JFrame fenetre = new JFrame();
//Instanciation d'un objet JPanel
JPanel pan = new JPanel();
//instanciation d'un objet JComboBox
JComboBox combo1 = new JComboBox();
JComboBox combo2 = new JComboBox();
JComboBox combo3 = new JComboBox();
JLabel label = new JLabel();
//Définit un titre pour notre fenêtre
fenetre.setTitle("RATP APP");
//Définit sa taille : 400 pixels de large et 100 pixels de haut
fenetre.setSize(400, 100);
//Nous demandons maintenant à notre objet de se positionner au centre
fenetre.setLocationRelativeTo(null);
//Termine le processus lorsqu'on clique sur la croix rouge
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Définition de sa couleur de fond
pan.setBackground(Color.white);
//On prévient notre JFrame que notre JPanel sera son content pane
// fenetre.setContentPane(pan);
JPanel top = new JPanel();
top.add(label);
top.add(combo1);
top.add(combo2);
top.add(combo3);
pan.add(top, BorderLayout.NORTH);
fenetre.setContentPane(pan);
combo1.setPreferredSize(new Dimension(60, 20));
combo1.addItem("Départ à");
combo2.setPreferredSize(new Dimension(100, 20));
combo2.addItem("00h");
combo2.addItem("01h");
combo2.addItem("02h");
combo2.addItem("03h");
combo2.addItem("04h");
combo2.addItem("05h");
combo2.addItem("06h");
combo2.addItem("07h");
combo2.addItem("08h");
combo2.addItem("09h");
combo2.addItem("10h");
combo2.addItem("11h");
combo2.addItem("12h");
combo2.addItem("13h");
combo2.addItem("14h");
combo2.addItem("15h");
combo2.addItem("16h");
combo2.addItem("17h");
combo2.addItem("18h");
combo2.addItem("19h");
combo2.addItem("20h");
combo2.addItem("21h");
combo2.addItem("22h");
combo2.addItem("23h");
combo2.setPreferredSize(new Dimension(50, 20));
combo3.addItem("00");
combo3.addItem("05");
combo3.addItem("10");
combo3.addItem("15");
combo3.addItem("20");
combo3.addItem("25");
combo3.addItem("30");
combo3.addItem("35");
combo3.addItem("40");
combo3.addItem("45");
combo3.addItem("50");
combo3.addItem("55");
//Et enfin, la rendre visible
fenetre.setVisible(true);
}*/ |
Partager