Tham khảo tài liệu 'bài giảng điện tử môn tin học: gui programming & database connectivity', công nghệ thông tin, tin học văn phòng phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Part III: GUI Programming & Database Connectivity Chapter 8: GUI Programming Chapter 9: Database Connectivity Võ Phương Bình - ITFAC - DLU Chapter 8: GUI Programming GUI Class Hierarchy Frames Creating frames, centering frames, adding components to frames Layout Managers FlowLayout, GridLayout, BorderLayout Drawing on Panels The paintComponent method Using Colors, Fonts, and Font Metrics Drawing Geometric Figures Lines, Rectangles, Ovals, Arcs, and Polygons Event-Driven Programming Event Source, Listener, Listener Interface Võ Phương Bình - ITFAC - DLU GUI Class Hierarchy (Swing) Võ Phương Bình - ITFAC - DLU JComponent Võ Phương Bình - ITFAC - DLU AWT (Optional) Võ Phương Bình - ITFAC - DLU Frames Frame is a window that is not contained inside another window. Frame is the basis to contain other user interface components in Java GUI applications. The Frame class can be used to create windows. For Swing GUI programs, use JFrame class to create widows. Võ Phương Bình - ITFAC - DLU UI Components Võ Phương Bình - ITFAC - DLU import .*; public class MyFrame { public static void main(String[] args) { JFrame frame = new JFrame("Test Frame"); (400, 300); (true); ( ); } } Creating Frames Võ Phương Bình - ITFAC - DLU Centering Frames By default, a frame is displayed in the upper-left corner of the screen. To display a frame at a specified location, you can use the setLocation(x, y) method in the JFrame class. This method places the upper-left corner of a frame at location (x, y). Võ Phương Bình - ITFAC - DLU Centering Frames, cont. Võ Phương Bình - ITFAC - DLU Adding Components into a Frame // Add a button into the frame ().add( new JButton("OK")); Võ Phương Bình - ITFAC - DLU NOTE The content pane is a subclass of Container. The statement in the preceding slide can be replaced by the following two lines: Container . | Part III: GUI Programming & Database Connectivity Chapter 8: GUI Programming Chapter 9: Database Connectivity Võ Phương Bình - ITFAC - DLU Chapter 8: GUI Programming GUI Class Hierarchy Frames Creating frames, centering frames, adding components to frames Layout Managers FlowLayout, GridLayout, BorderLayout Drawing on Panels The paintComponent method Using Colors, Fonts, and Font Metrics Drawing Geometric Figures Lines, Rectangles, Ovals, Arcs, and Polygons Event-Driven Programming Event Source, Listener, Listener Interface Võ Phương Bình - ITFAC - DLU GUI Class Hierarchy (Swing) Võ Phương Bình - ITFAC - DLU JComponent Võ Phương Bình - ITFAC - DLU AWT (Optional) Võ Phương Bình - ITFAC - DLU Frames Frame is a window that is not contained inside another window. Frame is the basis to contain other user interface components in Java GUI applications. The Frame class can be used to create windows. For Swing GUI programs, use JFrame class to create widows. Võ Phương