List Renderer of LWUIT Extension

Source: Internet
Author: User

1. model

 

Class Contact {<br/> private String name; <br/> private String email; <br/> private Image pic; <br/> public Contact (String name, String email, image pic) {<br/> this. name = name; <br/> this. email = email; <br/> this. pic = pic; <br/>}< br/> public String getName () {<br/> return name; <br/>}< br/> public String getEmail () {<br/> return email; <br/>}< br/> public Image getPic () {<br/> return pic; <br/>}< br/>}

 

2. render

 

Class ContactsRenderer extends Container implements ListCellRenderer {<br/> private Label name = new Label (""); <br/> private Label email = new Label (""); <br/> private Label pic = new Label (""); <br/> private Label focus = new Label (""); </p> <p> // sean architecture <br/> public ContactsRenderer () {<br/> setLayout (new BorderLayout ()); <br/> addComponent (BorderLayout. WEST, pic); <br/> Container cnt = new Container (new BoxLayout (BoxLayout. y_AXIS); <br/> name. getStyle (). setBgTransparency (0); <br/> // name. getStyle (). setFont (Font. createSystemFont (Font. FACE_SYSTEM, Font. STYLE_BOLD, Font. SIZE_MEDIUM); <br/> email. getStyle (). setBgTransparency (0); <br/> cnt. addComponent (name); <br/> cnt. addComponent (email); <br/> addComponent (BorderLayout. CENTER, cnt); </p> <p> // focus. getStyle (). setBgTransparency (100); <br/>}< br/> // sean fills in the presentation content for each instance's presentation architecture <br/> public Component getListCellRendererComponent (List list List, Object value, int index, boolean isSelected) {<br/> Contact person = (Contact) value; <br/> name. setText (person. getName (); <br/> email. setText (person. getEmail (); <br/> pic. setIcon (person. getPic (); <br/> return this; <br/>}< br/> // sean currently selected instance, show the animation Start Screen <br/> public Component getListFocusComponent (List list) {<br/> return focus; <br/>}< br/>}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.