3.1 Lesson Outcomes
After completing this lesson, learners will be able to:
- Build GUI applications using Java.
- Apply event-driven programming.
- Create user interaction using GUI components.
- Develop contextual Java applications for specific sectors.
- Build operable Java solutions using frameworks and Java functionalities.
3.2 Overview
Java GUI applications provide visual interaction between users and software systems. Java supports GUI development through:
- Swing,
- JavaFX,
- and AWT.
GUI applications are important in:
- retail systems,
- healthcare systems,
- cloud dashboards,
- IoT monitoring systems,
- and network applications.
This lesson introduces learners to practical GUI application development using Java programming.
Understanding GUI application development is important because modern software applications require user-friendly interfaces and interactive functionality.
Case Study / Scenario
You are a junior Java developer at a South African technology company that provides smart software solutions for SMEs.
The company requests a contextual Java GUI application for a chosen sector such as:
- retail,
- healthcare,
- IoT,
- cloud systems,
- mobile applications,
- or networking.
The application must:
- include GUI components,
- process user input,
- display outputs,
- and provide sector-specific functionality.
PA0301 — Build a GUI Application Using Java
GUI applications use visual components such as:
- buttons,
- labels,
- text fields,
- and windows.
Java Example:
import javax.swing.*;
import java.awt.event.*;
public class RetailApp {
public static void main(String[] args) {
JFrame frame = new JFrame(“Retail Stock Manager”);
JButton btnAdd = new JButton(“Add Stock”);
JButton btnView = new JButton(“View Stock”);
JLabel lblInfo = new JLabel(“Stock Info will appear here.”);
btnAdd.setBounds(50, 50, 150, 30);
btnView.setBounds(220, 50, 150, 30);
lblInfo.setBounds(50, 100, 300, 30);
frame.add(btnAdd);
frame.add(btnView);
frame.add(lblInfo);
frame.setSize(450, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final int[] stock = {0};
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stock[0] += 10;
lblInfo.setText(“Current Stock: “ + stock[0]);
}
});
btnView.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
lblInfo.setText(“Viewing Stock: “ + stock[0]);
}
});
}
}
Expected Behaviour
- Clicking Add Stock increases stock values.
- Clicking View Stock displays stock information.
- GUI components respond to user actions.
- The application operates without runtime errors.
Practical Activity
Learners must:
- create Java GUI applications,
- add GUI components,
- apply event-driven programming,
- process user input,
- and display outputs dynamically.
Example Sector Applications
Retail Sector
- Stock management system
- Sales reporting system
- Invoice generator
Healthcare Sector
- Patient booking system
- Appointment management system
IoT Sector
- Smart temperature monitoring dashboard
- Sensor display system
Cloud-Based Application
- Employee attendance dashboard
- Cloud monitoring interface
Network Application
- Chat application
- Client-server communication interface
Practical Activity
Learners may:
- customize sector functionality,
- expand GUI features,
- and implement advanced application logic.
AK0301 — Java Programming Functionalities
Java GUI Functionality — Purpose
JFrame — Creates application windows
JButton — Handles user actions
JLabel — Displays text
ActionListener — Handles events
Arrays — Store application data
Variables — Store values
Methods — Organize functionality
Practical Activity
Learners must:
- explain GUI functionalities,
- identify event-driven programming concepts,
- and apply Java GUI principles.
IAC0301 — Expected Results are Achieved and the Basic GUI Application is Operable
Expected Results
- GUI components display correctly.
- Buttons respond to user interaction.
- Application data updates successfully.
- No runtime errors occur.
- Sector-specific functionality operates correctly.
- User interaction behaves as expected.
3.5 Key Notes / Summary
- Java GUI applications provide visual interaction.
- Swing and JavaFX support GUI development.
- Event-driven programming responds to user actions.
- GUI components improve usability.
- Arrays and variables store application data.
- Java GUI systems are widely used in software development.