Java GUI Programming and
Networking
Unit 5 - Swing, Event Handling, and Network Programming
Mr. S. Kanthi Kiran, Associate Professor, Dept. of CSE, Gayatri Vidya
Parishad College of Engineering(Autonomous)
Introduction to GUI and Swing -
Exploring Swing Components - JFrame
• Description: JFrame is the main container used to create the window
for a Swing application.
• It’s a top-level container that can hold other components.
• Usage: Used as the base window in most GUI applications.
Introduction to GUI and Swing -
Exploring Swing Components - JPanel
• Description: JPanel is a lightweight container used to group
components within a JFrame or other containers.
• Usage: Used for organizing the layout and grouping of components.
Introduction to GUI and Swing -
Exploring Swing Components - JButton
• Description: JButton is a button component that users can click to
trigger an action.
• Usage: Commonly used to perform actions in response to user
interaction.
Introduction to GUI and Swing -
Exploring Swing Components - JLabel
• Description: JLabel is a component used to display text or images.
• Usage: Often used for static text, instructions, or displaying images in
a GUI.
Introduction to GUI and Swing -
Exploring Swing Components - JTextField
• Description: JTextField allows the user to input single-line text.
• Usage: Commonly used in forms for fields like name, email, etc.
Introduction to GUI and Swing -
Exploring Swing Components - JTextArea
• Description: JTextArea allows multi-line text input.
• Usage: Often used for comments, messages, or multi-line inputs.
Introduction to GUI and Swing -
Exploring Swing Components - JCheckBox
• Description: JCheckBox represents a checkbox that can be selected or
deselected.
• Usage: Useful for settings or options that can be toggled on and off.
Introduction to GUI and Swing -
Exploring Swing Components - JRadioButton and
ButtonGroup
• Description: JRadioButton represents an option button that can be
selected or deselected.
• A ButtonGroup is used to group multiple radio buttons to ensure only
one can be selected.
• Usage: Useful for selecting one option from a group, such as gender or
color options.
Introduction to GUI and Swing -
Exploring Swing Components - JComboBox
• Description: JComboBox is a drop-down menu that allows users to
select one option from a list.
• Usage: Useful for selecting options from a predefined list, such as
country selection.
Component Description Example Use Case
JFrame Main application Base for all Swing
window applications
Introduction to JPanel Container for organizing
Grouping buttons and
GUI and Swing - components
labels
Exploring Swing JButton Clickable button Submitting a form
Components - JLabel Displaying static text or
Instructions or title text
JComboBox images
JTextField Single-line text input Input for username or
email
Multi-line text input Comments or feedback
JTextArea
form
JCheckBox Toggleable checkbox Accepting terms and
conditions
JRadioButton Single-select option
Gender selection
button
JComboBox Drop-down selection Selecting country or
menu language