TAILIEUCHUNG - Bài giảng Lập trình Java: Buổi 3 - Industrial university of Ho Chi Minh City

Bài giảng "Lập trình Java - Graphic user interface in Java" trình bày các nội dung: Top-level container, layout manager, common control, event listener, dialogbox, advanced control. nội dung chi tiết. | 1/3/2016 03. Graphic User Interface in Java Faculty of Information Technologies Industrial University of Ho Chi Minh City 1 GUI components (p2) Top-level container Layout Manager Common Control Event Listener Dialogbox Advanced Control 2 Top-level container 3 1 1/3/2016 Top-level container: JFrame 4 Top-level container: JDialog 5 Top-level container: Window 6 2 1/3/2016 GUI Components - JPanel • A JPanel is used to group other components into rectangular regions • Properties: o • A panel can be nested within another panel o The default layout manager is FlowLayout Usage: o • Allocate JPanel, put other components in it, add to other container Constructors: o JPanel() o JPanel(LayoutManager lm) 7 GUI Components - JPanel 8 GUI Components - JLabel • Labels are usually used to display information or identify other components in the interface • A label can be composed of text, and image, or both at the same time • The ImageIcon class is used to represent an image that is stored in a label • The alignment of the text and image within the label can be set explicitly 9 3 1/3/2016 GUI Components - JLabel • Constructors: o JLabel() o JLabel (String labeltext) o JLabel (String labeltext, int alignment) • Creates an empty label • Creates a label with a given text • Creates a label with given alignment where alignment can be LEFT, RIGHT, CENTER, LEADING or TRAILING. o JLabel (Icon img) o JLabel (String str, Icon img, int align) • Only Icon will be used for label 10 GUI Components - JLabel • Some methods: o String getText() o void setText(String text) • Gets or sets the text displayed on the label o Font getFont() o void setFont(Font font) • Gets or sets the current font of the label 11 Using special fonts for text • To draw characters in a font, you must first create an object of the class Font • Constructor: o Font( String font_name, int font_style, int font_size ) Arial Tahoma Times .

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.