TAILIEUCHUNG - Thinking in Java 3rd Edition phần 8

Ví dụ này tải các nút với các loại khác nhau của các mặt hàng, và sau đó được các phím (). Những đi trở lại như một String [], bạn có thể không mong đợi nếu bạn đang sử dụng các phím () trong thư viện các bộ sưu tập. Ở đây, | example because a JLabel will be the size of its string attempting to right-justify its text yields an unchanged display when using FlowLayout. Feedback GridLayout A GridLayout allows you to build a table of components and as you add them they are placed left-to-right and top-to-bottom in the grid. In the constructor you specify the number of rows and columns that you need and these are laid out in equal proportions. Feedback c14 Demonstrates GridLayout. applet code GridLayout1 width 300 height 250 applet import . import . import . public class GridLayout1 extends JApplet public void init Container cp getContentPane new GridLayout 7 3 for int i 0 i 20 i new JButton Button i public static void main String args new GridLayout1 300 250 In this case there are 21 slots but only 20 buttons. The last slot is left empty because no balancing goes on with a GridLayout. Feedback GridBagLayout The GridBagLayout provides you with tremendous control in deciding exactly how the regions of your window will lay themselves out and reformat themselves when the window is resized. However it s also the most complicated layout manager and quite difficult to understand. It is intended primarily for automatic code generation by a GUI builder GUI builders might use GridBagLayout instead of absolute placement . If your design is so complicated that you feel you need to use Chapter 14 Creating Windows Applets 803 GridBagLayout then you should be using a GUI builder tool to generate that design. If you feel you must know the intricate details I ll refer you to Core Java 2 Volume 1 by Horstmann Cornell Prentice Hall 2001 or a dedicated Swing book as a starting point. Feedback Absolute positioning It is also possible to set the absolute position of the graphical components in this way 1. Set a null layout manager for your Container setLayout null . Feedback 2. Call setBounds or reshape depending on the .

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.