Can somebody help me with this please. i need to create a //calendar on the frame. i got the frame but the calendar is not woking.
import jpb.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class DayOfWeekAWT
{
public static void main(String[] args)
{
Frame f = new DayOfWeekFrame("Day Of Week");
f.setSize(450, 100);
f.setVisible(true);
}
}
class DayOfWeekFrame extends Frame
{
int last_Day = 31;
//private Choice calendar = new Choice();
GregorianCalendar date = new GregorianCalendar(); // datermine the current date.
private Label month_Label = new Label("Month: ", Label.CENTER);
private Label day_Label = new Label("Day: ", Label.CENTER);
//private Label year_Label = new Label("Year: ", Label.CENTER);
private Label bottom_Label = new Label(" ",Label.CENTER);
private Choice monthNames = new Choice();
private Choice numberOfDays = new Choice();
private Label year = new Label("Year:", Label.CENTER);
private TextField which_year = new TextField("", Label.CENTER);
private TextArea ta = new TextArea();
//which_year.setEdittable();
String LabelContents = year.getText();
Panel calendar = new Panel();
/////////////////////////////////////////////////////////////////
// Constructor
public DayOfWeekFrame(String title)
{
super(title);
setBackground(new Color(255, 255, 255));
//setLayout(new GridLayout());
setLayout(new FlowLayout());
//////////////////////////////////////////////////////////////////
add(which_year);
add(calendar);
add(monthNames);
monthNames.add("January");
monthNames.add("February");
monthNames.add("March");
monthNames.add("April");
monthNames.add("May");
monthNames.add("June");
monthNames.add("July");
monthNames.add("August");
monthNames.add("September");
monthNames.add("October");
monthNames.add("November");
monthNames.add("December");
add(month_Label);
add(monthNames);
monthNames.addItemListener(new monthNamesListener());
add(day_Label);
add(numberOfDays);
numberOfDays.addItemListener(new numberOfDaysListener());
add(year);
add(which_year);
//add(ta);
//add(LabelContents);
addWindowListener(new WindowCloser()); // window listener.
for (int first_Day = 1; first_Day <= last_Day; first_Day++)
{
numberOfDays.add(first_Day + "");
}
//addWindowListener(new WindowCloser());
int month =0;
int Days;
switch(month)
{
case 2: //February
// Days = 28;
// if (year % 4 == 0)
// {
// Days = 29;
// if ((year % 100 == 0) && (year % 400 !=0))
// Days = 28;
// }
// break;
case 4: //April
case 6: //June
case 9: //September
case 11://November
Days = 30;
break;
default: Days =31;
break;
}
}
}
//class monthNamesListener implements ItemListener
//{
//public void itemStateChanged(ItemEvent evt)
//{
//if (evt.getStateChange() == ItemEvent.SELECTED)
//{
// for (int first_Day = 1; first_Day <= last_Day; first_Day++)
//{
// numberOfDays.add(first_Day + "");
//}
//}
//}
class numberOfDaysListener implements ItemListener {
public void itemStateChanged(ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
}
}
}
class WindowCloser extends WindowAdapter {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
}