Segunda parte:
Código java:
Ver original//calendario
calendarioLayout customLayout = new calendarioLayout();
setFont
(new Font("Helvetica",
Font.
PLAIN,
12)); setLayout(customLayout);
add(anomenos);
anomenos.addActionListener(this);
add(mesmenos);
mesmenos.addActionListener(this);
meslabel.
setFont(new Font("Dialog",
1,
10)); add(meslabel);
add(mesmas);
mesmas.addActionListener(this);
add(anomas);
anomas.addActionListener(this);
add(label_2);
add(label_3);
add(label_4);
add(label_5);
add(label_6);
add(label_7);
add(label_8);
//entra a la clase maldita
mostrar_calendario();
// System.exit(0);
}
});
}
//metodo que ejecuta el cambiar de fecha
private void elijeDia
(String dia
){ diax=dia;
mesx
= String.
valueOf(currentDate.
get(currentDate.
MONTH)); anox
= String.
valueOf(currentDate.
get(currentDate.
YEAR)); int aux_mes
= Integer.
parseInt(mesx
); aux_mes += 1;
mesx
= String.
valueOf(aux_mes
); if(aux_mes<10){
mesx = "0"+mesx;
}
fecha_elegida=anox+separador+mesx+separador+diax;
//Aca hubica la fecha seleccionada en el cuadro de texto.
Frame1.jTextField2.setText(fecha_elegida);
//cerramos esta clase
cerrarMetodo();
}
public static void calendar(){
}
public void mostrar_calendario()
{
int b=0;
int c=1;
int tmp;
int x = 50;
int y = 130;
int dia = currentDate.get(currentDate.DATE);
mes = currentDate.get(currentDate.MONTH);
mes++;
int ano = currentDate.get(currentDate.YEAR);
int TotalDiasMes = currentDate.getActualMaximum(currentDate.DAY_OF_MONTH);
if (dia>currentDate.get(currentDate.DAY_OF_WEEK))
tmp = dia-currentDate.get(currentDate.DAY_OF_WEEK);
else
tmp = currentDate.get(currentDate.DAY_OF_WEEK)-dia;
while (tmp>7){
tmp=tmp-7;
}
tmp=8-tmp;
int DiaSemanaEmpiezaMes = tmp;
tmp = dia-currentDate.get(currentDate.DAY_OF_WEEK);
while((tmp+7)<TotalDiasMes){
tmp=tmp+7;
}
tmp=TotalDiasMes-tmp;
int DiaSemanaTerminaMes = tmp;
mes = currentDate.get(currentDate.MONTH);
meslabel.setText(" "+ARRMES[mes]+" del "+currentDate.get(currentDate.YEAR));
int j=1;
int aux=0;
for(int i=0; i<TotalDiasMes+DiaSemanaEmpiezaMes-1 ; i++){
aux++;
if (aux==8){
aux=1;
x = 50;
y = y + 25;
}
if (i<DiaSemanaEmpiezaMes-1){
x = x + 56;
}
else{
auxiliad_dia
= String.
valueOf(j
); dia_entero
= Integer.
parseInt(auxiliad_dia
); ponerDia(dia_entero,x,y);
x = x + 56;
j++;
}
}
}
int dia;
int mes;
int ano;
if (ae.getSource() == anomenos){
reiniciarBotones();
mes = currentDate.get(currentDate.MONTH);
dia = currentDate.get(currentDate.DATE);
ano = currentDate.get(currentDate.YEAR);
ano = ano - 1;
currentDate.set(ano,mes,dia);
mostrar_calendario();
}
if (ae.getSource() == anomas){
reiniciarBotones();
mes = currentDate.get(currentDate.MONTH);
dia = currentDate.get(currentDate.DATE);
ano = currentDate.get(currentDate.YEAR);
ano = ano + 1;
currentDate.set(ano,mes,dia);
mostrar_calendario();
}
if (ae.getSource() == mesmenos){
reiniciarBotones();
mes = currentDate.get(currentDate.MONTH);
dia = currentDate.get(currentDate.DATE);
ano = currentDate.get(currentDate.YEAR);
mes = mes - 1;
currentDate.set(ano,mes,dia);
mostrar_calendario();
}
if (ae.getSource() == mesmas){
reiniciarBotones();
mes = currentDate.get(currentDate.MONTH);
dia = currentDate.get(currentDate.DATE);
ano = currentDate.get(currentDate.YEAR);
mes = mes + 1;
currentDate.set(ano,mes,dia);
mostrar_calendario();
}
}