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
   | public class gcDateSelector extends JPanel {
 
    private static int left_margin = 10;
    private static int right_margin = 10;
    private static int top_margin = 10;
    private static int bottom_margin = 10;
    private static int fontSize = 14;
 
    private JComboBox jour = new JComboBox();
    private JComboBox mois = new JComboBox();
    private JComboBox annee = new JComboBox();
    private JComboBox heures = new JComboBox();
    private JComboBox minutes = new JComboBox();
 
 
    public gcDateSelector(String libelle) {
 
        this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
 
        JPanel panelTitre = new JPanel();
        JLabel titre = new JLabel();
        titre.setText(libelle);
        titre.setFont(new Font("Dialog", Font.BOLD, 14));
        panelTitre.setAlignmentX(Component.LEFT_ALIGNMENT);
        panelTitre.add(titre);
 
        for (int i=1; i<10; i++) {jour.addItem("0"+i);}
        for (int i=10; i<32; i++) {jour.addItem(i);}
 
        mois.addItem("Janvier");
        mois.addItem("Février");
        mois.addItem("Mars");
        mois.addItem("Avril");
        mois.addItem("Mai");
        mois.addItem("Juin");
        mois.addItem("Juillet");
        mois.addItem("Août");
        mois.addItem("Septembre");
        mois.addItem("Octobre");
        mois.addItem("Novembre");
        mois.addItem("Décembre");
 
        annee.addItem("2008");
        annee.addItem("2009");
        annee.addItem("2010");
        annee.addItem("2011");
 
        for (int i=0; i<10; i++) {heures.addItem("0"+i);}
        for (int i=10; i<24; i++) {heures.addItem(i);}
 
        for (int i=0; i<10; i++) {minutes.addItem("0"+i);}
        for (int i=10; i<60; i++) {minutes.addItem(i);}
 
        JPanel dd = new JPanel();
        dd.setLayout(new FlowLayout());
        dd.setAlignmentX(Component.LEFT_ALIGNMENT);
        dd.add(jour);
        dd.add(Box.createHorizontalStrut(5));
        dd.add(mois);
        dd.add(Box.createHorizontalStrut(5));
        dd.add(annee);
 
        JPanel hh = new JPanel();
        hh.setLayout(new FlowLayout());
        hh.setAlignmentX(Component.LEFT_ALIGNMENT);
        hh.add(heures);
        hh.add(Box.createHorizontalStrut(5));
        hh.add(minutes);        
 
        this.setBorder(new LineBorder(Color.blue));
 
        this.add(panelTitre);
        this.add(dd);
        this.add(hh);
 
    }
 
} |