TAILIEUCHUNG - Java Programming for absolute beginner- P14

Java Programming for absolute beginner- P14:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | 2 25 03 8 52 AM Page 218 k 0 c c 0 2 V 0 a c E E s k a o k a s s Telling the Story Creating the MadLib Game Frame The program uses a MadDialog object to retrieve user input. The MadLib class extends Frame. It listens for when the user closes the MadDialog dialog box and then builds the story and displays it in its un-editable TextArea. The MadDialog Frame itself will remain hidden until after the story is already built. Here s why. The MadDialog object is modal and it is shown first by calling true . It will maintain focus until it is hidden again. When the user clicks the x on the MadDialog window the buildStory method is called before the dialog is actually closed. Once the story is done the MadDialog will disappear and the MadLib will display the completed story. The buildStory method itself works by creating an array of Strings that represent segments of the story that break where words should be inserted. The String getStringArray method defined in the MadDialog class returns the String array sorted in the order they should be inserted into the story. This makes the two arrays indices correspond with each other so they are processed in a for loop to build the story. Here is the source for . MadLib A MadLib game import . import . public class MadLib extends Frame implements WindowListener private TextArea display private MadDialog dialog public MadLib super MadLib Game display new TextArea 7 60 new Font Timesroman 16 false add display addWindowListener this setLocation 100 150 pack dialog new MadDialog this this 150 100 true setVisible true team Line - live informative Non-cost and Genuine Please purchase PDF Split-Merge on to remove this watermark. 2 25 03 8 52 AM Page 219 219 public static void .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
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.