tailieunhanh - Lecture Java methods: Object-oriented programming and data structures (2nd AP edition): Chapter 17 - Maria Litvin, Gary Litvin
Chapter 17 - 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. | GUI Components and Events Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 17- 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 17- 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 (LAF) 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 “Nimbus” a more polished, cross-platform LAF, . | GUI Components and Events Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 17- 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 17- 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 (LAF) 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 “Nimbus” a more polished, cross-platform LAF, added in Java 6. “Windows” for Windows “Windows Classic” like Windows 95 “Motif” for Unix / Linux 17- 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 . try { (plafName); } catch (Exception ex) { . } 17- The default LAF is cross-platform look and feel. 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); 17- Components don’t just “hang there”: each component is linked
đang nạp các trang xem trước