J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

CalendarItem

A CalendarItem in action The CalendarItem visualizes dates and allows users to edit dates.

Design

The above CalendarItem has been designed with following styles:


.calendarForm {
	background {
		type: vertical-gradient;
		top-color: white;
		bottom-color: #aaa;
		start: 70%;
		end: 100%;
	}
	layout: hcenter | top;
	padding-top: 3px;
}

.calendar {
	layout: expand;
	label-style: calendarMonth;
}

.calendar:hover {
}

.calendarMonth {
	font-color: #222;
	font-style: bold;
	font-size: small;
	before: url( arrow-left.png );
	after: url( arrow-right.png );
	layout: expand | center;
}

.calendarWeekday {
	layout: center;
	font-style: italic | bold;
	min-width: 12%;
}

.calendarDay {
	padding: 2px;
	font-style: italic;
	font-color: #222;
	layout: right;
}

.calendarDay:hover {
	background-color: #222;
	font-color: #efefef;
}

.calendarCurrentday extends .calendarDay {
	background-color: #8f8;
}

.calendarCurrentday:hover {
	background-color: #1a1;
	font-color: #fff;
}

.calendarDayInactive extends .calendarDay {
	font-color: #666;
}

.calendarDayInactive:hover {
	background-color: #666;
	font-color: #fff;
}

The CalendarItem uses following static styles for the design of its components:

  • .calendarWeekday: the design of the weekdays headlines
  • .calendarDay: a day of the calendar
  • .calendarCurrentday: the day that is is currently selected
  • .calendarDayInactive: a day from a non current month

Also remember to define corresponding :hover styles like .calendarCurrentday:hover.

The label of a CalendarItem is used for the name of the currently selected month and year. Use the label-style CSS attribute in the CalendarItem's style for specifying a custom design. In the above example we use the .calendarMonth style for designing the label (and for adding arrows before and after the month's name).

You can use following attributes for designing a CalendarItem:

Programming

Using the CalendarItem is simple - just initialize it with a java.util.Calendar or use the current date:

Calendar birthdate = getBirthdate();
if (birthdate == null) {
	//#style calendar
	this.birthdateCalendar = new CalendarItem();
} else {
	//#style calendar
	this.birthdateCalendar = new CalendarItem( birthdate );
}

Please refer to the "datefield" sample application for a working example.

Configuration

There are is one preprocessing variable that you can either specify in the <variables> section of your build.xml or in your messages.txt files when using the Localization framework.

Variable  DefaultExplanation
polish.CalendarItem.FirstDayOfWeek Monday The first day of the week. In most countries this is Monday, in the US the week starts traditionally on a Sunday. Allowed values are Monday or Sunday.

JavaDoc

back to top