9
Outline-session 6 (09-April- 2009) >> High-Level User Interface: Part I -TextField -Choice and ChoiceGroup -Image and Image Item

Session6 J2ME High Level User Interface(HLUI) part1

Embed Size (px)

DESCRIPTION

Sesssion6 HLUI Part1

Citation preview

Page 1: Session6 J2ME High Level User Interface(HLUI) part1

Outline-session 6 (09-April-2009)

>> High-Level User Interface: Part I-TextField-Choice and ChoiceGroup-Image and Image Item

Page 2: Session6 J2ME High Level User Interface(HLUI) part1

TextField

>> create a TextField you can specify an input constraint.>> A constraint provides restrictions on the data that a user may enter>> There are four constraints to support the following specific types of input

--email addresses, -- URLs-- numeric values and -- phone numbers

>> In addition to constraints, when you create a TextField you specify how many characters you anticipate you will need.

Page 3: Session6 J2ME High Level User Interface(HLUI) part1

TextField

Page 4: Session6 J2ME High Level User Interface(HLUI) part1

TextField

Page 5: Session6 J2ME High Level User Interface(HLUI) part1

Constraint Value>> values assigned to each constraint

>> Its not possible to combine constraint(Password is a special case)>> let's combine EMAILADDR and NUMERIC.TextField.EMAILADDR 00000000 00000000 00000001TextField.NUMERIC 00000000 00000000 00000010

----------------------------logical OR 00000000 00000000 0000001100000011 is the value for PHONENUMBER

Page 6: Session6 J2ME High Level User Interface(HLUI) part1

Constraint Value>> Now, let's combine, PASSWORD with EMAILADDR and see what we get

TextField.EMAILADDR 00000000 00000000 00000001TextField.PASSWORD 00000001 00000000 00000000

----------------------------logical OR 00000001 00000000 00000001

>> first (right-most) 16 bits are reserved for constraints>> PASSWORD is outside the range of these values, we don't have a collision with

another constraint>> PASSWORD is a modifier that is to be used along with other constraints

>> you cannot combine constraints.

Page 7: Session6 J2ME High Level User Interface(HLUI) part1

Constraint Value>> how the constraint mask works>> mask was created to work in conjunction with the method getConstraints()>> reason for the mask is to remove the PASSWORD modifier>> When you need to know the value of the constraint for a TextField, you call this

method and perform a logical AND operation as follows>> TextField.getConstraints() & TextField.CONSTRAINT_MASK>>TextField tfPwd = new TextField("Password:", "", 10,TextField.ANY |

TextField.PASSWORD);TextField.ANY 00000000 00000000 00000000TextField.PASSWORD 00000001 00000000 00000000

--------------------------constraint value 00000001 00000000 00000000>>tfPwd.getConstraints() 00000001 00000000 00000000>>to get the value we are looking for, we need to mask off the modifier:tfPwd.getConstraints() & TextField.CONSTRAINT_MASK

Page 8: Session6 J2ME High Level User Interface(HLUI) part1

Constraint Value>> how the constraint mask workswhich looks as follows:tfPwd.getConstraints() 0000001 00000000 00000000TextField.CONSTRAINT_MASK 00000000 11111111 11111111----------------------------logical AND 00000000 00000000 00000000>>if ((tfPwd.getConstraints() & TextField.PASSWORD) != 0)System.out.println("Password modifier applied");

Page 9: Session6 J2ME High Level User Interface(HLUI) part1