Description
4.1 AWT Components & Containers
- Component: The base class for all AWT user interface elements.
- Container: A subclass of
Componentthat can hold other components. - Window: A top-level container with no borders or menu bar.
- Frame: A top-level window with a title, borders, and a menu bar.
- Panel: A simple container used to group components.
- AWT Controls:
Label(display text),Button(clickable control),Checkbox(on/off option),CheckboxGroup(radio buttons),TextField(single-line text input),TextArea(multi-line text input).
4.2 Layout Managers
- Layout Managers: Objects that automatically arrange components within a container.
- FlowLayout: Arranges components in a row, like a line of text.
- BorderLayout: Divides the container into five regions: North, South, East, West, and Center.
- GridLayout: Arranges components in a grid of rows and columns.
- GridBagLayout: A flexible layout manager that aligns components based on a grid of cells.
- Menu Components:
MenuBar(holds menus),Menu(a list of menu items),MenuItem(an item in a menu),FileDialog(a dialog for opening or saving files).
4.3 Introduction to Swing
- Swing: A more modern and flexible GUI toolkit built on AWT.
- Swing Features: Lightweight components (platform-independent), Pluggable Look and Feel, richer set of components.
- AWT vs. Swing: AWT components are heavyweight (rely on native OS components). Swing components are lightweight (drawn by Java itself).
4.4 Swing Components
- JLabel: Displays a short string of text or an image. Can include
Icons. - JTextField: Single-line text input field.
- JComboBox: Drop-down list or editable field.
- JButton: Clickable button.
- JCheckBox: On/off option.
- JRadioButton: A choice within a mutually exclusive group, managed by a
ButtonGroup.
4.5 Advanced Swing Components
- JTabbedPane: A component that lets you switch between different panels using tabs.
- JScrollPane: Adds scrollbars to a component, like a text area or a table, when its content exceeds the visible area.
- JTree: Displays hierarchical data, like files in a directory.
- JTable: Displays data in a tabular format (rows and columns).
- JProgressBar: A visual indicator of the progress of a task.
- JToolTip: A small pop-up window that appears when the mouse hovers over a component.
4.6 Introduction to Event Handling
- Delegation Event Model: A design pattern where an object (the event source) generates an event, and another object (the event listener) receives and handles it.
- Event Sources: Objects that generate events (e.g., a button).
- Event Listeners: Objects that “listen” for and handle specific events.
4.7 Event Classes
- ActionEvent: Generated when a button is clicked or a menu item is selected.
- ItemEvent: Generated when a checkbox or radio button’s state changes.
- KeyEvent: Generated when a key is pressed, released, or typed.
- MouseEvent: Generated when the mouse is clicked, moved, or enters/exits a component.
- TextEvent: Generated when the text within a text component changes.
4.8 Event Listener Interfaces
- ActionListener: Handles
ActionEvent. - ItemListener: Handles
ItemEvent. - KeyListener: Handles
KeyEvent. - MouseListener: Handles
MouseEvent(clicks, presses, releases). - MouseMotionListener: Handles
MouseEvent(movement, dragging). - TextListener: Handles
TextEvent.





Reviews
There are no reviews yet.