All pastes #291723 Raw Edit

Sans nom

public text v1 · immutable
#291723 ·published 2006-12-25 17:33 UTC
rendered paste body
package dateheure;


import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JComboBox;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;


public class Calendrier2
{
    
    JButton[] tabcal = new JButton[42];
    
    public JPanel createView() 
    {
		JPanel panel = new JPanel(); //Contenu de la fenetre
                panel.setLayout(new GridBagLayout());//applique le layout au panel
     
                GridBagConstraints c = new GridBagConstraints();//applique les contraintes au grid bag
                
                GregorianCalendar calendar = new GregorianCalendar();
                
                             
                //creation de la Combo box
                JComboBox comb1 = new JComboBox();
                
                String[] tabmois = {"Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Décembre"};
                
                for(int i=0; i<=11; i++)
                {
                 comb1.addItem(tabmois[i]);
                }
                
                //Selection du moi courant dans le combobox
                comb1.setSelectedIndex(new Integer(calendar.get(java.util.Calendar.MONTH)));

                
                //creation du Spinner
                JSpinner spin1 = new JSpinner();
                
                //Selection de l'année courante dans le spinner
                spin1.setValue(new Integer(calendar.get(java.util.Calendar.YEAR)));
                
                c.ipadx=5;
                c.ipady=5;
                c.gridx=0;
                c.gridy=0;
                c.fill = GridBagConstraints.BOTH;
                c.gridwidth=1;
                c.gridheight=1;
                c.insets= new Insets(5,5,5,5);
                panel.add(comb1,c);
                
                c.gridx=1;
                c.gridy=0;
                panel.add(spin1,c);

                
                //creation du Grid layout -- 2eme Panel
                JPanel pan1 = new JPanel();

                pan1.setLayout(new GridLayout(7,7));
                
                String[] tabjours = {"Dim","Lun","Mar","Mer","Jeu","Ven","Sam"};
                
                for(int i=0; i<=6; i++)
                {
                 pan1.add(new JLabel (tabjours[i]));
                }
                
                for (int i=0; i<=46 ; i++)
                {
                    pan1.add(new JButton(""+i));
                }
                
                c.fill = GridBagConstraints.BOTH;
                c.gridx=0;
                c.gridy=1;
                c.gridwidth=2;
                panel.add(pan1,c);
                
                
                //Affichage de la Date du jour -- 3eme Panel
                c.fill = GridBagConstraints.CENTER;
                c.gridx=0;
                c.gridy=2;
                c.gridwidth=2;
                Date dateDuJour = new Date();
                SimpleDateFormat date1 = new SimpleDateFormat("EEEE d MMMM yyyy");
                panel.add(new JLabel(""+date1.format(dateDuJour)),c);
                
                
                
                return panel;
    }
}