Đang chuẩn bị liên kết để tải về tài liệu:
J2ME in a Nutshell phần 3

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

trang trong đó một loạt các hồ sơ cung cấp cơ sở vật chất còn thiếu có thể được cung cấp, trong một hình thức thích hợp cho lớp thiết bị mà mỗi hồ sơ được thiết kế. Thông tin hồ sơ thiết bị di động, hoặc MIDP cho ngắn, là một trong những hồ sơ, được sử dụng trên các thiết bị nhỏ gọn với một giao diện người dùng hạn chế | J2ME in a Nutshell public class TextBox2MIDlet extends TextBoxMIDlet implements CommandListener Exit command private static final Command EXIT COMMAND new Command Exit Command.EXIT 0 OK command private static final Command OK_COMMAND new Command OK Command.OK 0 Clear text box content private static final Command CLEAR_COMMAND new Command Clear Command.SCREEN 1 Reverse the content of the text box private static final Command REVERSE_COMMAND new Command Reverse Command.SCREEN 1 protected void startApp boolean firstTime started super.startApp If this is the first execution of startApp install commands if firstTime textBox.addCommand OK_COMMAND textBox.addCommand EXIT_COMMAND textBox.addCommand CLEAR_COMMAND textBox.addCommand REVERSE_COMMAND textBox.setCommandListener this Command implementations. public void commandAction Command c Displayable d if c EXIT_COMMAND destroyApp true notifyDestroyed else if c OK_COMMAND System.out.println OK pressed else if c CLEAR_COMMAND textBox.setString null else if c REVERSE_COMMAND String str textBox.getString if str null StringBuffer sb new StringBuffer str textBox.setString sb.reverse .toString Notice that this example is implemented by deriving it directly from the TextBoxMIDlet class from the previous example. Of course you wouldn t normally have to do this in the real world but here it serves to show how easy it is to add command handling to an existing class and you don t need to replicate code that you saw earlier The four Commands are defined as static class members for example 99 J2ME in a Nutshell private static final Command EXIT COMMAND new Command Exit Command.EXIT 0 Since Commands are simply constant-valued objects you can usually define them in this way and then reuse them wherever you need to which would include adding the same instance to more than one screen if necessary. You can see from Example 4-2 that the EXIT and OK commands use the standard types Command.EXIT and Command.OK respectively which allows the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.