TAILIEUCHUNG - Java™ How to Program ( Deitel - Deitel) - Phần 20

Tham khảo sách 'java™ how to program ( deitel - deitel) - phần 20', 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ả | to white. Line 25 attaches mous ePanel to the JFrame. As you learned in Section you typically must specify the layout of the GUI components in a JFrame. In that section we introduced the layout manager FlowLayout. Here we use the default layout of a JFrame s content paneBorderLayout. This layout manager arranges components into five regions north south east west and center. north corresponds to the top of the container. This example uses the center and south regions. Line 25 uses a two-argument version of method add to place mousePanel in the center region. The BorderLayout automatically sizes the component in the center to use all the space in the JFrame that is not occupied by components in the other regions. Section discusses BorderLayout in more detail. Page 555 Lines 2728 in the constructor declare JLabel statusBar and attach it to the JFrame s south region. This JLabel occupies the width of the JFrame. The region s height is determined by the JLabel. Line 31 creates an instance of inner class MouseHandler lines 3690 called handler that responds to mouse events. Lines 3233 register handler as the listener for mousePanel s mouse events. Methods addMouseListener and addMouseMotionListener are inherited indirectly from class Component and can be used to register MouseListener s and MouseMotionListeners respectively. A MouseHandler object is both a MouseListener and a MouseMotionListener because the class implements both interfaces. Note In this example we chose to implement both interfaces to demonstrate a class that implements more than one interface. However we also could have implemented interface MouseInputListener here. Page 556 When the mouse enters and exits mousePanel s area methods mouseEntered lines 6267 and mouseExited lines 7074 are called respectively. Method mouseEntered displays a message in the statusBar indicating that the mouse entered the JPanel and changes the background color to green. Method mous eExited displays a message in .

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.