TAILIEUCHUNG - Professional Java JDK 6 Edition 2007 phần 9

Tham khảo tài liệu 'professional java jdk 6 edition 2007 phần 9', 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ả | Part II A Broad Understanding of Java APIs Tools and Techniques false initially disable the cancel menu item since there is no active request false new MenuItem - new MenuItem Configure Zipcode .addActionListener new ActionListener . retrieve user input for zipcode field new MenuItem Exit .addActionListener new ActionListener public void actionPerformed ActionEvent evt O new TrayIcon wImage Weather Watcher menu . The actionPerformed method of the WeatherWatcher class is where weather Web Services requests are started. Because is called the request is non-blocking and starts up in a background thread. When the request terminates either successfully or fails with an exception the anonymous AsyncHandler GetWeatherResponse s handleResponse method is called called when user clicks Get Weather context menu item initiates asynchronous web service call public void actionPerformed ActionEvent evt false true future zipcode new AsyncHandler GetWeatherResponse note that this reponse method is on another thread so we have to get back on the GUI thread to do any updates to our GUI components public void handleResponse Response GetWeatherResponse resp try final Weather w if if there was an exception during the web service processing it will be thrown here GetWeatherResponse gwr w else 592 Chapter 11 Communicating between Java Components and Other Platforms user cancelled the request re-enable menus and return try new Runnable public void run false true catch Exception ex return . All execution in handleResponse occurs on a different thread. This is extremely important it means whenever you want to update your GUI .

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.