LWUIT 1.1 for Java ME Developers- P2

Tham khảo tài liệu 'lwuit for java me developers- p2', 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ả | Chapter 2 While textLabel is instantiated from Label animLabel is a customized version. The code for this class appears below import import import public class HelloLabel extends Label decides which circle is to be drawn private int state time when previous repaint was done private long prevTime private boolean done private boolean initialized nominal interval between two successive repaints private final int interval 150 width of the label private int width height of the label private int height radius of first circle private int rad1 10 radii of other three circles private int rad2 rad3 rad4 top left corners of bounding rectangles - smallest to largest private int x1 y1 x2 y2 x3 y3 x4 y4 create a new HelloLabel public HelloLabel super if this object is registered for animation then this method will be called once for every frame public boolean animate painting parameters not set up so don t repaint if initialized return false 37 Components get current time long currentTime check if it s interval milliseconds or more since last repaint also see if all circles have been drawn if done currentTime - prevTime interval it s more than interval milliseconds so save current time for next check prevTime currentTime increment state to draw next larger circle state check if all circles drawn if state 5 all finished so set done flag done true and ask for string display to be updated HelloForm getComponentForm .updateText request repaint return true either too soon for next repaint or all circles drawn no repaint to be done return false reinitialize to start animation for next non-space character public void resumeAnimation state 0 done false will be called whenever animate method returns true public void paint Graphics g save the present color int color set color for drawing circles 0xff8040 38 Chapter 2 act as per state value switch state draw smallest circle .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.