Lecture Java: Chapter 12

Lecture Java: Chapter 12 (Java Graphic User Interface) focuses on How to display a Window, Layout Manager, Common Control, Event Listener, Event Listener, Event Listener. | 1 1 Full Name: Trần Duy Thanh Blog : Email: tranduythanh@ Phone: 0987773061 Contact 2 2 2. Layout Manager 3. Common Control 4. Event Listener 6. Advanced Control 3 1. How to display a Window? 5. Dialogbox 4 1. How to display a Window? Extends from Frame or JFrame? import .*; import .*; import .*; 5 1. How to display a Window? public class MyWindow extends JFrame{ public MyWindow(){ super("Demo Windows"); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { MyWindow ui=new MyWindow(); (400, 300); (null); (true); } } 6 1. How to display a Window? super("Demo Windows"); Use to set title for this window setDefaultCloseOperation(EXIT_ON_CLOSE); Allow click ‘x’ Top right corner to close the window (400, 300); set Width =400 and Height =300 (null); Display window on desktop center screen . | 1 1 Full Name: Trần Duy Thanh Blog : Email: tranduythanh@ Phone: 0987773061 Contact 2 2 2. Layout Manager 3. Common Control 4. Event Listener 6. Advanced Control 3 1. How to display a Window? 5. Dialogbox 4 1. How to display a Window? Extends from Frame or JFrame? import .*; import .*; import .*; 5 1. How to display a Window? public class MyWindow extends JFrame{ public MyWindow(){ super("Demo Windows"); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { MyWindow ui=new MyWindow(); (400, 300); (null); (true); } } 6 1. How to display a Window? super("Demo Windows"); Use to set title for this window setDefaultCloseOperation(EXIT_ON_CLOSE); Allow click ‘x’ Top right corner to close the window (400, 300); set Width =400 and Height =300 (null); Display window on desktop center screen (true); Show the window 2. Layout Manager 7 FlowLayout BoxLayout BorderLayout CardLayout GridBagLayout GridLayout GroupLayout SpringLayout - Setting up the Layout before add another control. - Usually, we use JPanel to add another control, JPanel is container. JPanel could add another JPanel. 8 FlowLayout FlowLayout cho phép add các control trên cùng một dòng, khi nào hết chỗ chứa nó sẽ tự động xuống dòng, ta cũng có thể điều chỉnh hướng xuất hiện của control. Mặc định khi một JPanel được khởi tạo thì bản thân lớp chứa này sẽ có kiểu Layout là FlowLayout. Resize the Width 9 FlowLayout JPanel pnFlow=new JPanel(); (new FlowLayout()); (); JButton btn1=new JButton("FlowLayout"); JButton btn2=new JButton("Add các control"); JButton btn3=new JButton("Trên 1 dòng"); JButton btn4=new JButton("Hết chỗ chứa"); JButton btn5=new JButton("Thì xuống dòng"); (btn1);(btn2); (btn3);(btn4); (btn5); Container .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
184    96    9    03-06-2024
Đã 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.