DateField
The DateField allows you to enter dates and time in different modes:
- Native Input Mode: When the native mode is used, a new input screen will pop up for the user. This allows your user to use all native input mechanisms that the target device supports but it does interrupt the flow within the application. The Native Input Mode is used by default.
- Direct Input Mode: With the Direct Input Mode J2ME Polish accepts input directly without showing a new popup screen.
<variable name="polish.DateField.useDirectInput" value="true"/>
Design
The above DateField has been designed with following styles:
colors {
fontColor: rgb( 30, 85, 86 );
}
.dateInput {
margin: 1;
padding: 4;
font-style: bold;
font-size: small;
font-color: fontColor;
background-color: silver;
border-color: black;
}
.dateInput:hover {
padding: 3;
border-width: 2;
background-color: white;
}
Additionally following settings have been made:
<variable name="polish.DateField.useDirectInput" value="true"/>
You can use following attributes for designing a DateField:
| CSS Attribute | Default | Values | Explanation |
|---|---|---|---|
| after | - | imageurl | The URL of the image that should be shown after the item in question. |
| always-include | false | true, false | Defines if a style should always be included, even if not used. |
| background | - | background definition | The background of an item or screen. The default background for items is "none", the default background for screens is a simple white background. |
| before | - | imageurl | The URL of the image that should be shown before the item in question. |
| complete-border | - | border | A border reference from the borders section. The border includes the label of the item and is independent of the item's normal border. |
| complete-background | - | background | A background name from the backgrounds section. The background includes the label of the item and is independent of the item's normal background. |
| border | - | border definition | The border of an item or screen. The default border is "none". |
| complete-background-padding | - | integer | The padding that is added to the complete-background and/or complete-border. Note that this does not change the size of the item, so you might need to adapt margins or normal paddings for your design. |
| focused-style | focused | style | The name of the style for the currently focused item, usually applied with a [style-name]:hover construct. |
| font-bitmap | - | string | Defines which bitmap (bmf) font should be used. |
| include-label | false | true, false | Usually the label of an item is rendered separately of the item's content. You can expand the background and border over the label as well using this attribute. |
| inherit | true | true, false | Defines if a style that extends this style should inherit all attributes. |
| label-style | label | style | The name of the style for the label of the corresponding Item. |
| max-height | - | integer | The maximum height of an item. |
| max-width | - | integer | The maximum width of an item. |
| min-height | - | integer | The minimum height of an item. |
| min-width | - | integer | The minimum width of an item. |
| table-selected-background | - | background | The background for selected cells of a table. |
| colspan | 1 | integer | The number of columns wich are used by the item within a table. |
| table-selected-row-background | - | background | The background for selected rows of a table. |
| opacity | 255 | integer | The opacity of an item between 0 (fully transparent) and 255 (fully opaque). |
| pressed-style | - | style | The style which indicates that an item is being pressed, usually applied with a [style-name]:pressed construct. |
| table-selected-column-background | - | background | The background for selected columns of a table. |
| text-effect | - | Sets a text effect. | |
| text-horizontal-adjustment | 0 | integer | Adjusts the text by the specified number of pixels horizontally. Negative values move the text to the left. |
| text-vertical-adjustment | 0 | integer | Adjusts the text by the specified number of pixels vertically. Negative values move the text to the top. |
| text-wrap | true | true, false | Determines wether the text should be wrapped or whether it should be kept on a single line, even when it is larger than the available width. |
| text-wrap-animate | true | true, false | You can deactivate animations for texts that should not be wrapped and which are too long for a single line. |
| text-wrap-animation-direction | both | both, left, right | The direction of the animation when the text is too wide and wrapping is deactivated. |
| text-wrap-animation-speed | 1 | integer | The speed of the animation when the text is too wide and wrapping is deactivated. |
| view-type | - | fade-in, fade-out, particle, size-decrease, size-increase | Defines another visualization for an Item or a Screen. |
| visible | true | true, false | Toggles the visibility of an item. When an item is invisible, it will not occupy any space. |
| x-adjust | 0 | integer | The horizontal position adjustment. |
DateField-Commands
A DateField adds the "Clear" command to the menu when the direct input mode is used. The names of this and other commands can be changed easily using localization in your messages.txt file:
polish.command.clear=Reset
Programming
Use the DateField like the MIDP javax.microedition.lcdui.DateField:
//#style dateInput this.birthdate = new DateField( "birthday:", DateField.DATE ); this.birthdate.setDate( new Date( System.currentTimeMillis() ) );
Configuration
There are several preprocessing variables 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 | Default | Explanation |
|---|---|---|
| polish.DateFormat | ymd | The sequence of date parts - use y for the year, m for the month and d for the day.
US American format is for example mdy.
You can also use the abbreviations us for US American, fr for French and de for
German date formats.
For TIME or DATE_TIME DateFields hh:mm will be appended in any case.
|
| polish.DateFormatEmptyText | YYYY-MM-DD | Defines the text that should be shown by an empty DateField - the shown default depends on the polish.DateFormat variable as well
- if polish.DateFormat is for example mdy, the default will be MM-DD-YYYY.
|
| polish.DateFormatSeparator | - | The separator between years, months and days of a DATE or DATE_TIME DateField. |