some code samples, various examples of simple modeling ideas and some minor algorithms.

CalendarGraphic.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import java.awt.*;
  2. class CalendarGraphic extends Frame
  3. {
  4. TextField daytext,monthtext,yeartext;
  5. public CalendarGraphic(int d,int m,int y)
  6. {
  7. setTitle("Date display");
  8. setSize(300,100);
  9. setLayout(new FlowLayout());
  10. daytext = new TextField(2);
  11. monthtext = new TextField(3);
  12. yeartext = new TextField(4);
  13. add(daytext);
  14. add(monthtext);
  15. add(yeartext);
  16. setVisible(true);
  17. display(d,m,y);
  18. }
  19. public void display(int day,int month,int year)
  20. {
  21. String monthname="";
  22. switch(month)
  23. {
  24. case 1: monthname="JAN"; break;
  25. case 2: monthname="FEB"; break;
  26. case 3: monthname="MAR"; break;
  27. case 4: monthname="APR"; break;
  28. case 5: monthname="MAY"; break;
  29. case 6: monthname="JUN"; break;
  30. case 7: monthname="JUL"; break;
  31. case 8: monthname="AUG"; break;
  32. case 9: monthname="SEP"; break;
  33. case 10: monthname="OCT"; break;
  34. case 11: monthname="NOV"; break;
  35. case 12: monthname="DEC"; break;
  36. }
  37. daytext.setText(Integer.toString(day));
  38. monthtext.setText(monthname);
  39. yeartext.setText(Integer.toString(year));
  40. }
  41. }