To Make an Interactive GUI Program To make an interactive GUI program, you need: Components buttons, windows, menus, etc. Events mouse clicked, window closed, button clicked, etc. Event listeners (interfaces) and event handlers (methods) listen for events to be trigged, and then perform actions to handle them | Lecture 8: User Interface Components with Swing Swing Overview (1) Classes from package defines various GUI components — objects with which the user interacts via the mouse, the keyboard or another form of input. Some basic GUI components JLabel JTextField JCheckBox JComboBox JList JPanel Most of the swing components are written completely in java, so they provide a greater portability and flexibility than the original GUI components from package Awt components are platform dependent Some swing components are still platform dependent. , JFrame Swing Overview (2) Common superclasses of many of the Swing components Component class Operations common to most GUI components are found in Component class. Container class Two important methods originates in this class add — adds components to a container. setLayout — enables a program to specify the layout manager that helps a Container position and size its components. JLabel A JLabel object provides text instructions or information on a GUI — display a single line of read-only text, an image or both text and image Example code One thing to be emphasized: if you do not explicitly add a GUI component to a container, the GUI component will not be displayed when the container appears on the screen To Make an Interactive GUI Program To make an interactive GUI program, you need: Components buttons, windows, menus, etc. Events mouse clicked, window closed, button clicked, etc. Event listeners (interfaces) and event handlers (methods) listen for events to be trigged, and then perform actions to handle them Event-Handling Model (1) Some GUIs are event driven — they generate events when the user interacts with the GUI , moving the mouse, clicking a button, typing in a text field, selecting an item from a menu, etc. When a user interaction occurs, an event is sent to the program. Many event types are defined in . | Lecture 8: User Interface Components with Swing Swing Overview (1) Classes from package defines various GUI components — objects with which the user interacts via the mouse, the keyboard or another form of input. Some basic GUI components JLabel JTextField JCheckBox JComboBox JList JPanel Most of the swing components are written completely in java, so they provide a greater portability and flexibility than the original GUI components from package Awt components are platform dependent Some swing components are still platform dependent. , JFrame Swing Overview (2) Common superclasses of many of the Swing components Component class Operations common to most GUI components are found in Component class. Container class Two important methods originates in this class add — adds components to a container. setLayout — enables a program to specify the layout manager that helps a Container position and size its components. .