tailieunhanh - LWUIT 1.1 for Java ME Developers- P5

Tham khảo tài liệu 'lwuit for java me developers- p5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 8 Creating a Custom Component Sometimes we feel the need for a special application-oriented component that is not available in the LWUIT library. On such occasions a custom component has to be created and in this chapter we are going to see how to do that. At a very fundamental level it would seem that the only thing one needs to do for building a made-to-order component is write a class that extends Component. However this essential step is not enough by itself except in trivial cases. For practical usage explicit action is required to implement one or more of the characteristics that make the LWUIT components so flexible and versatile. Some of these characteristics are The ability to be styled Support for responding to customer inputs like a keypress Mechanisms for informing other objects that a specified incident has taken place Support for plugging in different visual presentations Provision for working out preferred dimensions In the following demo application we shall build up a component that tells the current time not through the usual analog or digital presentation but through a text string. Creating a Custom Component The making of a component Our new component has two operational modes real-time display and elapsed-time display. The default mode is real-time display which displays the time of day. This can be seen in the following screenshot The other mode displays the elapsed time from the instant the timer is started. As shown in the following screenshot an icon e is used to indicate that the component is operating in the elapsed-time mode. TimeTeller is the underlying class here that generates the time information to be displayed but does not handle the implementation of the display. It also generates an alarm but does not explicitly take any further action. In this example the TimeTeller class works with the following interfaces and class public interface AlarmHandler defines the functionality of the class for handling alarms generated by TimeTeller.

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.