Lecture note Java methods A & AB: Object-oriented programming and data structures: Chapter 16 - Maria Litvin, Gary Litvin

Chapter 16 - GUI components and events. This chapter is only a brief overview of Java’s Swing package and event handling classes. After studying this chapter, the reader should be able to get enough background to research on his or her own the remaining classes and methods from Java’s API docs. | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. GUI Components and Events 16- This chapter is only a brief overview of Java’s Swing package and event handling classes. Objectives: Get a more systematic introduction to basic Swing components, their methods, and events they generate. Components discussed: JLabel JButton JToggleButton JCheckBox JComboBox JSlider JTextField JPasswordField JTextArea 16- After studying this chapter, the reader should be able to get enough background to research on his or her own the remaining classes and methods from Java’s API docs. Pluggable Look and Feel Look and feel refers to the GUI aspect of a program. Java’s Swing supports PLAF (Pluggable Look and Feel). Java provides several LAFs, including: “Metal” platform independent “Windows” for Windows “Windows Classic” like Windows 95 “Motif” for Unix / . | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. GUI Components and Events 16- This chapter is only a brief overview of Java’s Swing package and event handling classes. Objectives: Get a more systematic introduction to basic Swing components, their methods, and events they generate. Components discussed: JLabel JButton JToggleButton JCheckBox JComboBox JSlider JTextField JPasswordField JTextArea 16- After studying this chapter, the reader should be able to get enough background to research on his or her own the remaining classes and methods from Java’s API docs. Pluggable Look and Feel Look and feel refers to the GUI aspect of a program. Java’s Swing supports PLAF (Pluggable Look and Feel). Java provides several LAFs, including: “Metal” platform independent “Windows” for Windows “Windows Classic” like Windows 95 “Motif” for Unix / Linux 16- The UIManager class has a method getInstalledLookAndFeels that lists all available PLAFs. PLAF (cont’d) Three ways to set look and feel: file: Command-line switch: In the program: C:\> java . MetalLookAndFeel . try { (plafName); } catch (Exception ex) { . } 16- The default PLAF is “Metal.” A setting in the program overrides the settings in command line (if any) and in the properties file. GUI Components Components are created using constructors: To be usable, a component must be added to the application’s “content pane” or to another component: JLabel guest = new JLabel ("Guest”); JPanel scorePanel = new JPanel(); (guest); 16- Components don’t just “hang there”: each component is linked to its parent component; the top-level component is the application window’s content pane. GUI Events Components .

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
12    25    1    28-11-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.