Session6 J2ME High Level User Interface(HLUI) part1

966 views

Published on

Sesssion6 HLUI Part1

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • free download the updated file from here:-http://gg.gg/yi7pn
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
966
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
28
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Session6 J2ME High Level User Interface(HLUI) part1

  1. 1. Outline-session 6 (09-April-2009) <ul><li>>> High-Level User Interface: Part I </li></ul><ul><li>-TextField </li></ul><ul><li>-Choice and ChoiceGroup </li></ul><ul><li>-Image and Image Item </li></ul>
  2. 2. TextField <ul><li>>> create a TextField you can specify an input constraint. </li></ul><ul><li>>> A constraint provides restrictions on the data that a user may enter </li></ul><ul><li>>> There are four constraints to support the following specific types of input </li></ul><ul><li>--email addresses, </li></ul><ul><li>-- URLs </li></ul><ul><li>-- numeric values and </li></ul><ul><li>-- phone numbers </li></ul><ul><li>>> In addition to constraints, when you create a TextField you specify how many characters you anticipate you will need. </li></ul>
  3. 3. TextField
  4. 4. TextField
  5. 5. Constraint Value <ul><li>>> values assigned to each constraint </li></ul><ul><li>>> Its not possible to combine constraint(Password is a special case) </li></ul><ul><li>>> let's combine EMAILADDR and NUMERIC. </li></ul><ul><li>TextField.EMAILADDR 00000000 00000000 0000000 1 </li></ul><ul><li>TextField.NUMERIC 00000000 00000000 000000 10 </li></ul><ul><li> ---------------------------- </li></ul><ul><li>logical OR 00000000 00000000 000000 11 </li></ul><ul><li>000000 11 is the value for PHONENUMBER </li></ul>
  6. 6. Constraint Value <ul><li>>> Now, let's combine, PASSWORD with EMAILADDR and see what we get </li></ul><ul><li>TextField.EMAILADDR 00000000 00000000 0000000 1 </li></ul><ul><li>TextField.PASSWORD 00000001 00000000 00000000 </li></ul><ul><li> ---------------------------- </li></ul><ul><li>logical OR 0000000 1 00000000 00000001 </li></ul><ul><li>>> first (right-most) 16 bits are reserved for constraints </li></ul><ul><li>>> PASSWORD is outside the range of these values, we don't have a collision with another constraint </li></ul><ul><li>>> PASSWORD is a modifier that is to be used along with other constraints </li></ul><ul><li>>> you cannot combine constraints. </li></ul>
  7. 7. Constraint Value <ul><li>>> how the constraint mask works </li></ul><ul><li>>> mask was created to work in conjunction with the method getConstraints() </li></ul><ul><li>>> reason for the mask is to remove the PASSWORD modifier </li></ul><ul><li>>> 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 </li></ul><ul><li>>> TextField.getConstraints() & TextField.CONSTRAINT_MASK </li></ul><ul><li>>>TextField tfPwd = new TextField(&quot;Password:&quot;, &quot;&quot;, 10,TextField.ANY | TextField.PASSWORD); </li></ul><ul><li>TextField.ANY 00000000 00000000 00000000 </li></ul><ul><li>TextField.PASSWORD 0000000 1 00000000 00000000 </li></ul><ul><li>-------------------------- </li></ul><ul><li>constraint value 0000000 1 00000000 00000000 </li></ul><ul><li>>>tfPwd.getConstraints() 0000000 1 00000000 00000000 </li></ul><ul><li>>>to get the value we are looking for, we need to mask off the modifier: </li></ul><ul><li>tfPwd.getConstraints() & TextField.CONSTRAINT_MASK </li></ul>
  8. 8. Constraint Value <ul><li>>> how the constraint mask works </li></ul><ul><li>which looks as follows: </li></ul><ul><li>tfPwd.getConstraints() 000000 1 00000000 00000000 </li></ul><ul><li>TextField.CONSTRAINT_MASK 00000000 11111111 11111111 </li></ul><ul><li>---------------------------- </li></ul><ul><li>logical AND 00000000 00000000 00000000 </li></ul><ul><li>>>if ((tfPwd.getConstraints() & TextField.PASSWORD) != 0) </li></ul><ul><li>System.out.println(&quot;Password modifier applied&quot;); </li></ul>

×