Lecture Introduction to Java programming - Chapter 12: GUI basics

The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the framework of Java GUI API and use the GUI components to develop user-friendly interfaces for applications and applets. | Chapter 12 GUI Basics Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the framework of Java GUI API and use the GUI components to develop user-friendly interfaces for applications and applets. Objectives To distinguish between Swing and AWT (§). To describe the Java GUI API hierarchy (§). To create user interfaces using frames, panels, and simple GUI components (§). To understand the role of layout managers (§). To use the FlowLayout, GridLayout, and BorderLayout managers to layout components in a container (§). To use JPanel as subcontainers (§). To specify colors and fonts using the Color and Font classes (§§). To apply common features such as borders, tool tips, fonts, and colors on Swing components (§). To use borders to visually group user-interface components (§). To create image icons using the ImageIcon class (§). Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your name: " JLabel jlblName = new JLabel("Enter your name: "); // Create a text field with text "Type Name Here" JTextField jtfName = new JTextField("Type Name Here"); // Create a check box with text bold JCheckBox jchkBold = new JCheckBox("Bold"); // Create a radio button with text red JRadioButton jrbRed = new JRadioButton("Red"); // Create a combo box with choices red, green, and blue JComboBox jcboColor = new JComboBox(new String[]{"Red", "Green", "Blue"}); Button Label Text field Check Box Radio Button Combo Box Swing vs. AWT So why do the GUI component classes have a prefix J? Instead of JButton, why not name it simply Button? In fact, there is a class already named Button in the package. When Java was introduced, the GUI classes were bundled in a library known as the Abstract Windows Toolkit (AWT). For every . | Chapter 12 GUI Basics Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the framework of Java GUI API and use the GUI components to develop user-friendly interfaces for applications and applets. Objectives To distinguish between Swing and AWT (§). To describe the Java GUI API hierarchy (§). To create user interfaces using frames, panels, and simple GUI components (§). To understand the role of layout managers (§). To use the FlowLayout, GridLayout, and BorderLayout managers to layout components in a container (§). To use JPanel as subcontainers (§). To specify colors and fonts using the Color and Font classes (§§). To apply common features such as borders, tool tips, fonts, and colors on Swing components (§). To use borders to visually group user-interface components (§). To create image icons using the ImageIcon

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
Đã 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.