Teams Winter 2011/team1/BlackBerry/Add Elements to Main Screen

From CDOT Wiki
Revision as of 15:52, 17 March 2011 by Azea (talk | contribs)
Jump to: navigation, search

3. Add Elements to Main (First) Screen

3.1. Open MyScreen.java class.
3.2. Create class Student with the following fields:

    private String firstName;
    private String lastName;
    private String email;
 

3.3. Add an array in MyScreen class to work with data.
3.4. The following elements are added to the MyScreen() constructor. Add a text field:

    AutoTextEditField atf = new AutoTextEditField("Student Name: ", "");
 

3.5. Set the border and background for the text field:

    Border roundedBorder = BorderFactory.createRoundedBorder(new XYEdges(5, 5, 5, 5), Border.STYLE_SOLID);
    Background solidBackground = BackgroundFactory.createSolidBackground(Color.LIGHTSTEELBLUE);
    atf.setBorder(roundedBorder);
    atf.setBackground(solidBackground);
    add(atf);   
 

3.6. Add a search button:

    ButtonField _bf=new ButtonField("Search");
    add(_bf);
 

3.7. Add the array of students to the list field:

   ObjectListField olf = new ObjectListField();
   for (int i=0; i< ls.length; i++) {
       olf.insert(i, ls[i].getFirstName() + " " + ls[i].getLastName());
   }      
   add(olf);