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 © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 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. . | GUI Components and Events Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 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 to its parent .