TAILIEUCHUNG - Introduction to Java: 8 Input Fields

Tham khảo tài liệu 'introduction to java: 8 input fields', 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 In this chapter Text Component TextField TextArea Extending TextField Input Fields There are two fundamental ways for users to provide input to a program they can type on a keyboard or they can select something a button a menu item etc. using a mouse. When you want a user to provide input to your program you can display a list of choices to choose from or allow the user to interact with your program by typing with the keyboard. Presenting choices to the user is covered in Chapter 9 Pick Me. As far as keyboard input goes the package provides two options. The TextField class is a single line input field while the TextArea class is a multiline one. Both TextField and TextArea are subclasses of the class Textcomponent which contains all the common functionality of the two. Textcomponent is a subclass of Component which is a subclass of Object. So you inherit all of these methods when you work with either TextField or TextArea. Text Component By themselves the TextField and TextArea classes are fairly robust. However in order to reduce duplication between the classes they both inherit a number of methods from the TextComponent class. The constructor for TextComponent is package private so you cannot create an instance of it yourself. Some of the activities shared by TextField and TextArea through the TextComponent methods include setting the text getting the text selecting the text and making it readonly. 302 Text Component 303 TextComponent Methods Contents Both TextField and TextArea contain a set of characters whose content determines the current value of the TextComponent. The following methods are usually called in response to an external event. public String getText The getText method returns the current contents of the TextComponent as a String object. public void setText String text The setText method sets the content of the TextComponent to text. If the TextComponent is a TextArea you can embed newline characters n in the text so that .

TỪ KHÓA LIÊN QUAN
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.