Adv-Java Unit 3: Complete Concepts Guide
Unit 4: Java Swings & Spring -> Generated and Prepared By Thiruselvan (ThiruXD)
1. Introduction to Java Swings
1.1 What is Java Swing?
Java Swing is a GUI (Graphical User Interface) toolkit used to create desktop applications. It is part of the Java Foundation Classes (JFC) and provides platform-independent GUI components.
Swing is used to create Graphical User Interfaces such as:
- Windows
- Buttons
- Text fields
- Labels
- Check boxes
- Menus
1.2 Important Points about Swing
| # | Feature | Explanation |
|---|---|---|
| 1 | GUI Toolkit | Provides components for desktop applications |
| 2 | Platform Independent | Runs on different operating systems |
| 3 | Lightweight Components | Implemented in Java, not OS-dependent |
| 4 | Rich Components | JFrame, JLabel, JTextField, JButton, JCheckBox, JRadioButton, JComboBox, JTable |
| 5 | Event Handling | Uses event listeners to respond to user actions |
| 6 | Easy to Build Forms | Login, registration, calculator, student management |
| 7 | Separation of GUI and Logic | Interface and logic organized separately |
1.3 Simple Swing Example
import javax.swing.*;
public class SwingExample {
public static void main(String[] args) {
JFrame frame = new JFrame("My First Swing Program");
JLabel label = new JLabel("Welcome to Java Swing");
label.setBounds(80, 50, 200, 30);
JButton button = new JButton("Click Me");
button.setBounds(100, 100, 120, 40);
button.addActionListener(e ->
JOptionPane.showMessageDialog(frame, "Button Clicked!"));
frame.add(label);
frame.add(button);
frame.setSize(350, 250);
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}Output:
┌──────────────────────────────────────┐
│ My First Swing Program X │
├──────────────────────────────────────┤
│ │
│ Welcome to Java Swing │
│ │
│ ┌───────────┐ │
│ │ Click Me │ │
│ └───────────┘ │
│ │
└──────────────────────────────────────┘1.4 Swing Workflow (14 Steps)
1. Import Swing
2. Create JFrame
3. Create JLabel
4. Set label position
5. Create JButton
6. Set button position
7. Tell button what to do when clicked
8. Add label to JFrame
9. Add button to JFrame
10. Set JFrame size
11. Set layout
12. Set close operation
13. Make JFrame visible
14. User clicks "Click Me"
15. ActionListener runs
16. "Button Clicked!" appears2. Introduction to IDE
2.1 What is an IDE?
An IDE (Integrated Development Environment) is software used to write, compile, run, and debug Java programs.
Popular IDEs:
- Eclipse IDE
- NetBeans
- IntelliJ IDEA
2.2 Features of IDEs
| Feature | Purpose | Example |
|---|---|---|
| Code Editor | Syntax highlighting | System.out.println("Hello"); |
| Auto Completion | Suggests methods and classes | Type Syso → suggests System.out.println |
| Error Detection | Highlights syntax errors | Red underlines |
| Debugging Tools | Find program errors | Breakpoints, step into |
| Project Management | Organizes files and packages | Folder structure |
2.3 Project Creation Steps
Steps in NetBeans/Eclipse:
| Step | Action |
|---|---|
| 1 | File → New Project |
| 2 | Select Java Application |
| 3 | Enter Project Name (e.g., SwingDemo) |
| 4 | Create Main Class |
Example:
public class SwingDemo {
public static void main(String[] args) {
System.out.println("Project Created Successfully");
}
}Output:
Project Created Successfully2.4 Code Management
Organizing source code using packages.
package student;
public class Student {
}Benefits:
- Better organization
- Easy maintenance
- Avoids naming conflicts
2.5 Debugging Tools
Breakpoints pause program execution.
public class DebugExample {
public static void main(String[] args) {
int a = 10;
int b = 20;
int c = a + b; // Breakpoint here
System.out.println(c);
}
}Common Debugging Features:
- Step Into
- Step Over
- Step Return
- Variable Watch
3. Swing Components
3.1 JLabel
Displays text or images.
import javax.swing.*;
public class LabelDemo {
public static void main(String[] args) {
JFrame f = new JFrame();
JLabel label = new JLabel("Welcome");
label.setBounds(100, 100, 150, 30);
f.add(label);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
}3.2 JTextField
Used for user input.
import javax.swing.*;
public class TextFieldDemo {
public static void main(String[] args) {
JFrame f = new JFrame();
JTextField tf = new JTextField();
tf.setBounds(50, 50, 150, 30);
f.add(tf);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
}3.3 JButton
Represents a clickable button.
import javax.swing.*;
public class ButtonDemo {
public static void main(String[] args) {
JFrame f = new JFrame();
JButton b = new JButton("Click");
b.setBounds(100, 100, 100, 30);
f.add(b);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
}3.4 JCheckBox
Allows multiple selections.
import javax.swing.*;
public class CheckBoxDemo {
public static void main(String[] args) {
JFrame f = new JFrame();
JCheckBox cb = new JCheckBox("Java");
cb.setBounds(100, 100, 100, 30);
f.add(cb);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
}3.5 Common Swing Components
| Component | Purpose |
|---|---|
| JFrame | Main window |
| JLabel | Displays text |
| JTextField | Accepts text input |
| JButton | Creates a button |
| JCheckBox | Allows selection |
| JRadioButton | Allows one choice from a group |
| JComboBox | Drop-down list |
| JTable | Displays tabular data |
| JPanel | Groups components |
| JMenuBar | Menu bar |
4. Containers and Controls
4.1 JFrame
Top-level container — the main window.
import javax.swing.*;
public class FrameDemo {
public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
frame.setSize(400, 300);
frame.setVisible(true);
}
}4.2 JPanel
Used to group components.
import javax.swing.*;
public class PanelDemo {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.add(new JButton("Save"));
frame.add(panel);
frame.setSize(300, 300);
frame.setVisible(true);
}
}4.3 Layout Managers
Controls component arrangement.
FlowLayout
Components arranged left to right.
frame.setLayout(new FlowLayout());BorderLayout
Regions: North, South, East, West, Center.
frame.setLayout(new BorderLayout());GridLayout
Creates rows and columns.
frame.setLayout(new GridLayout(2, 2));GridLayout Example:
A B
C D4.4 Event Controls
Events occur when users interact with components.
Examples:
- Button Click
- Mouse Click
- Keyboard Input
5. Event Handling in Swing
5.1 Event Model
Swing follows the Delegation Event Model.
Components:
- Source — The component that generates the event
- Event Object — Contains event information
- Listener — Receives and handles the event
Button → ActionEvent → ActionListener5.2 Action Events
Generated when a button is clicked.
import javax.swing.*;
import java.awt.event.*;
public class ActionDemo {
public static void main(String[] args) {
JFrame f = new JFrame();
JButton b = new JButton("Click");
b.setBounds(100, 100, 100, 30);
b.addActionListener(e -> System.out.println("Button Clicked"));
f.add(b);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
}5.3 Event Listeners
| Listener | Purpose |
|---|---|
| ActionListener | Button events |
| MouseListener | Mouse events |
| KeyListener | Keyboard events |
| WindowListener | Window events |
Example:
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Clicked");
}
});5.4 Event Adapters
Adapters provide default implementations.
import java.awt.event.*;
public class Demo extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}Benefits:
- Less coding
- Override only required methods
6. Desktop Application Development
6.1 Working of Front-End Applications
GUI Design Principles
A good GUI should be:
- Simple
- Consistent
- Responsive
- User Friendly
Example — Student Form:
Name: [__________]
Age: [__________]
Course: [__________]
[Save] [Reset]User Interaction
Users interact through:
- Buttons
- Text Fields
- Menus
- Dialog Boxes
JButton save = new JButton("Save");Event-Driven Programming
Program responds to user actions.
button.addActionListener(e -> System.out.println("Saved"));Interface Development
Combining components to create applications.
JFrame + JLabel + JTextField + JButton6.2 Calculator Application Development
User Interface Design
Components:
- JTextField
- Buttons
[ 10 ]
[ + ] [ - ]
[ * ] [ / ]
[ = ]Arithmetic Operations
int result = num1 + num2;Event Handling
button.addActionListener(e -> {
int a = 10;
int b = 20;
System.out.println(a + b);
});Result Display
resultField.setText(String.valueOf(result));Complete Calculator Example
JButton add = new JButton("+");
add.addActionListener(e -> {
int a = Integer.parseInt(t1.getText());
int b = Integer.parseInt(t2.getText());
result.setText(String.valueOf(a + b));
});6.3 Database Connectivity in Swing
Connecting Swing with JDBC
Connection con = DriverManager.getConnection(url, user, password);Example:
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost/test", "root", "root");Data Retrieval
ResultSet rs = stmt.executeQuery("SELECT * FROM student");
while (rs.next()) {
System.out.println(rs.getString("name"));
}Data Manipulation
Insert:
stmt.executeUpdate("INSERT INTO student VALUES(1,'Rahul')");Update:
stmt.executeUpdate("UPDATE student SET name='Amit'");Delete:
stmt.executeUpdate("DELETE FROM student");6.4 Swing Application Case Studies
Student Management System
Features:
- Add Student
- Update Student
- Delete Student
- View Student
Components: JFrame, JTextField, JButton, JTable
Library Management System
Features:
- Add Books
- Issue Books
- Return Books
- Search Books
Database: Books Table, Students Table
Employee Management System
Features:
- Employee Registration
- Salary Details
- Attendance Tracking
INSERT INTO employee VALUES(101,'John');Inventory Management System
Features:
- Product Entry
- Stock Update
- Sales Management
- Reports
UPDATE product SET quantity=50 WHERE id=1;6.5 Advantages of Swing
- Platform Independent
- Rich GUI Components
- Event-Driven Programming
- Easy Database Integration
- Flexible Layout Managers
7. Spring Framework Fundamentals
7.1 What is Spring?
The Spring Framework is one of the most popular Java frameworks used for developing enterprise applications. It provides comprehensive infrastructure support and simplifies development through Dependency Injection (DI) and Inversion of Control (IoC).
Spring
|
Spring Container
|
----------------------------
| | | |
Student Teacher Course Fee
| | | |
----------- Dependencies ---7.2 Spring Framework Architecture
SPRING FRAMEWORK
|
↓
Spring Container
|
IoC + Dependency Injection
|
Managed Objects (Beans)
|
---------------------------------------
| | | | |
MVC JDBC ORM Security AOP
| | | | |
Web Database JPA/ Login/ Logging/
Hibernate Transactions7.3 Features of Spring Framework
7.3.1 Lightweight Framework
What is Lightweight? Spring does not require heavyweight application servers and consumes fewer resources.
Features:
- Small footprint
- POJO (Plain Old Java Object) based
- Easy deployment
Example:
public class Student {
private int id;
private String name;
}Spring manages this object without requiring special inheritance.
Advantages:
- Faster development
- Easy maintenance
- Reduced memory usage
7.3.2 Modular Design
Spring consists of independent modules.
Major Modules:
Spring Framework
|
|-- Core Container
|-- Spring MVC
|-- Spring JDBC
|-- Spring ORM
|-- Spring Security
|-- Spring AOPExample: A web application may use Spring Core + Spring MVC + Spring JDBC without using other modules.
Benefits:
- Flexibility
- Easy Integration
- Reduced Complexity
7.3.3 Dependency Management
Spring manages dependencies automatically.
Without Spring:
public class StudentService {
StudentDAO dao = new StudentDAO(); // Tightly coupled
}With Spring:
@Autowired
private StudentDAO dao; // Spring injects automaticallyBenefits:
- Loose Coupling
- Better Testing
- Easier Maintenance
7.3.4 Enterprise Application Support
Spring supports enterprise-level applications.
Features:
- Transaction Management
- Security
- Database Integration
- Web Services
- Cloud Applications
Example:
@Transactional
public void saveStudent() {
}Spring manages transactions automatically.
8. Spring Architecture
8.1 Architecture Overview
Application
|
--------------------------------
| Core Container |
| Data Access Layer |
| Web Layer |
| Integration Layer |
--------------------------------8.2 Core Container
Core of Spring Framework.
Components:
- BeanFactory
- ApplicationContext
- IoC Container
Example:
ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml");8.3 Data Access Layer
Provides database support.
Features:
- JDBC Support
- ORM Integration
- Transaction Management
Example:
JdbcTemplate jdbcTemplate;Spring JDBC simplifies database operations.
8.4 Web Layer
Supports web application development.
Components:
- Spring MVC
- Controllers
- View Resolvers
Example:
@Controller
public class HomeController {
}8.5 Integration Layer
Integrates with external technologies.
Examples:
- Hibernate
- JPA
- JMS
- Web Services
Example:
@Repository
public class StudentDAO {
}9. Inversion of Control (IoC)
9.1 IoC Concept
Definition:Inversion of Control means object creation and dependency management are transferred from the programmer to the Spring container.
Traditional Approach:
StudentDAO dao = new StudentDAO(); // Programmer creates objectsSpring Approach:
@Autowired
StudentDAO dao; // Spring creates and injects objectsIoC Flow:
Application
↓
Spring Container
↓
Object Creation
↓
Dependency Injection9.2 Bean Management
What is a Bean? A Bean is an object managed by Spring.
Example:
@Component
public class Student {
}Spring automatically manages this object.
XML Bean Definition:
<bean id="student" class="com.demo.Student"/>9.3 Container Services
Spring Container provides:
- Object Creation
- Dependency Injection
- Lifecycle Management
- Configuration Management
Example:
ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml");9.4 Advantages of IoC
- Loose Coupling
- Easier Testing
- Better Maintainability
- Reusability
- Scalability
10. Dependency Injection Techniques
10.1 What is Dependency Injection?
Dependency Injection (DI) is the process of providing dependencies to an object.
10.2 Constructor Injection
Dependencies are injected through the constructor.
public class StudentService {
private StudentDAO dao;
public StudentService(StudentDAO dao) {
this.dao = dao;
}
}Spring Configuration (XML):
<bean id="dao" class="StudentDAO"/>
<bean id="service" class="StudentService">
<constructor-arg ref="dao"/>
</bean>Advantages:
- Mandatory Dependencies
- Better Immutability
10.3 Setter Injection
Dependency injected through setter methods.
public class StudentService {
private StudentDAO dao;
public void setDao(StudentDAO dao) {
this.dao = dao;
}
}XML Configuration:
<property name="dao" ref="dao"/>Advantages:
- Optional Dependencies
- Flexible Configuration
10.4 Field Injection
Uses @Autowired.
@Service
public class StudentService {
@Autowired
private StudentDAO dao;
}Advantages:
- Less Code
- Simple Configuration
Disadvantages:
- Difficult to test
10.5 Dependency Resolution
Spring resolves dependencies automatically.
@Autowired
private StudentDAO dao;Spring searches:
- Matching Bean
- Matching Type
- Matching Name
10.6 Comparison of DI Techniques
| Technique | Injection Point | Mandatory? | Testability |
|---|---|---|---|
| Constructor | Constructor | Yes | Best |
| Setter | Setter method | No | Good |
| Field | Field directly | Yes | Poor |
11. Bean Scope and Bean Lifecycle
11.1 Singleton Scope
Default scope in Spring. Only one object is created.
@Component
@Scope("singleton")
public class Student {
}Diagram:
Request 1 → Same Object
Request 2 → Same Object
Request 3 → Same Object11.2 Prototype Scope
Creates a new object every time.
@Component
@Scope("prototype")
public class Student {
}Diagram:
Request 1 → Object 1
Request 2 → Object 2
Request 3 → Object 311.3 Difference Between Singleton and Prototype
| Aspect | Singleton | Prototype |
|---|---|---|
| Objects | One Object | Multiple Objects |
| Default | Yes | Explicit Scope |
| Memory | Less Memory | More Memory |
| Use Case | Stateless beans | Stateful beans |
11.4 Bean Initialization
Executed after bean creation.
@PostConstruct
public void init() {
System.out.println("Bean Initialized");
}11.5 Bean Destruction
Executed before bean removal.
@PreDestroy
public void destroy() {
System.out.println("Bean Destroyed");
}11.6 Bean Lifecycle Summary
1. Bean Instantiation
2. Dependency Injection
3. @PostConstruct (init)
4. Bean Ready for Use
5. @PreDestroy (destroy)
6. Bean Removed12. Spring MVC Configuration
12.1 Dispatcher Servlet
Front Controller of Spring MVC.
Flow:
Browser
↓
DispatcherServlet
↓
Controller
↓
ViewConfiguration:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>12.2 Configuration Files
Used to define beans and MVC settings.
<context:component-scan base-package="com.demo"/>12.3 Controller Setup
Controller handles requests.
@Controller
public class HomeController {
}Request Handler:
@RequestMapping("/home")
public String home() {
return "home";
}12.4 View Resolver
Maps view names to JSP pages.
<bean class="InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>13. Request Mapping and Form Tag Library
13.1 RequestMapping Annotation
Maps URL requests.
@RequestMapping("/student")
public String student() {
return "student";
}13.2 URL Mapping
Maps multiple URLs.
@RequestMapping(value="/save", method=RequestMethod.POST)13.3 Form Tags
Spring provides JSP form tags.
Tag Library:
<%@ taglib prefix="form"
uri="http://www.springframework.org/tags/form"%>Example:
<form:form modelAttribute="student">
<form:input path="name"/>
</form:form>13.4 Data Binding
Automatically maps form data to Java objects.
public class Student {
private String name;
}<form:input path="name"/>Automatically binds value.
14. Spring Validation
14.1 Validation Framework
Used to validate user input.
@NotNull
private String name;14.2 Error Handling
Validation errors are displayed to users.
<form:errors path="name"/>14.3 Validation Annotations
| Annotation | Purpose |
|---|---|
| @NotNull | Cannot be null |
| @NotEmpty | Cannot be empty |
| @Size | Length validation |
| Email validation | |
| @Min | Minimum value |
| @Max | Maximum value |
Example:
@NotEmpty
private String name;
@Email
private String email;14.4 Form Validation Techniques
Model Class:
public class Student {
@NotEmpty
private String name;
@Email
private String email;
}Controller:
@PostMapping("/save")
public String save(@Valid Student student, BindingResult result) {
if (result.hasErrors()) {
return "form";
}
return "success";
}JSP:
<form:errors path="name"/>
<form:errors path="email"/>14.5 Advantages of Spring MVC
- Separation of Concerns
- Easy Validation
- Powerful Request Mapping
- Flexible View Management
- Integration with Spring Modules
15. Unit Summary
JAVA SWINGS & SPRING
│
├── Introduction to Java Swings
│ ├── GUI toolkit
│ ├── Platform independent
│ ├── Lightweight components
│ └── Simple Swing example
│
├── Introduction to IDE
│ ├── Features (editor, auto-complete, debugging)
│ ├── Project creation
│ ├── Code management
│ └── Debugging tools
│
├── Swing Components
│ ├── JLabel, JTextField, JButton
│ ├── JCheckBox, JRadioButton
│ └── JComboBox, JTable
│
├── Containers and Controls
│ ├── JFrame (top-level container)
│ ├── JPanel (grouping)
│ ├── Layout Managers (Flow, Border, Grid)
│ └── Event controls
│
├── Event Handling
│ ├── Delegation Event Model
│ ├── Action events
│ ├── Event listeners
│ └── Event adapters
│
├── Desktop Application Development
│ ├── GUI design principles
│ ├── Calculator application
│ ├── Database connectivity (JDBC + Swing)
│ └── Case studies (Student, Library, Employee, Inventory)
│
├── Spring Framework Fundamentals
│ ├── Features (lightweight, modular, DI, enterprise)
│ ├── Architecture (Core, Data, Web, Integration)
│ ├── Inversion of Control (IoC)
│ └── Dependency Injection (Constructor, Setter, Field)
│
├── Bean Scope and Lifecycle
│ ├── Singleton scope
│ ├── Prototype scope
│ ├── @PostConstruct
│ └── @PreDestroy
│
├── Spring MVC Configuration
│ ├── DispatcherServlet
│ ├── Configuration files
│ ├── Controller setup
│ └── View resolver
│
├── Request Mapping and Form Tags
│ ├── @RequestMapping
│ ├── URL mapping
│ ├── Form tag library
│ └── Data binding
│
└── Spring Validation
├── Validation framework
├── Error handling
├── Validation annotations
└── Form validation techniques16. Key Syntax — Quick Reference
| Concept | Syntax/Example |
|---|---|
| Import Swing | import javax.swing.*; |
| Create JFrame | JFrame frame = new JFrame("Title"); |
| Create JLabel | JLabel label = new JLabel("Text"); |
| Create JTextField | JTextField tf = new JTextField(); |
| Create JButton | JButton btn = new JButton("Click"); |
| Create JCheckBox | JCheckBox cb = new JCheckBox("Java"); |
| Create JPanel | JPanel panel = new JPanel(); |
| Set Bounds | component.setBounds(x, y, width, height); |
| Add Component | frame.add(component); |
| Set Size | frame.setSize(400, 300); |
| Set Layout | frame.setLayout(new FlowLayout()); |
| Set Close Operation | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| Set Visible | frame.setVisible(true); |
| Add ActionListener | button.addActionListener(e -> {...}); |
| Show Dialog | JOptionPane.showMessageDialog(frame, "Message"); |
| GridLayout | frame.setLayout(new GridLayout(2, 2)); |
| BorderLayout | frame.setLayout(new BorderLayout()); |
| FlowLayout | frame.setLayout(new FlowLayout()); |
| Spring @Component | @Component public class Student {} |
| Spring @Autowired | @Autowired private StudentDAO dao; |
| Spring @Service | @Service public class StudentService {} |
| Spring @Repository | @Repository public class StudentDAO {} |
| Spring @Controller | @Controller public class HomeController {} |
| Spring @Scope | @Scope("singleton") / @Scope("prototype") |
| Spring @PostConstruct | @PostConstruct public void init() {} |
| Spring @PreDestroy | @PreDestroy public void destroy() {} |
| Spring @RequestMapping | @RequestMapping("/home") |
| Spring @PostMapping | @PostMapping("/save") |
| Spring @Valid | @Valid Student student |
| Spring @NotNull | @NotNull private String name; |
| Spring @Email | @Email private String email; |
| Spring @NotEmpty | @NotEmpty private String name; |
| Spring @Size | @Size(min=2, max=50) |
| Spring @Min | @Min(18) |
| Spring @Max | @Max(100) |
| Spring XML Bean | <bean id="student" class="com.demo.Student"/> |
| Spring Constructor Injection | <constructor-arg ref="dao"/> |
| Spring Setter Injection | <property name="dao" ref="dao"/> |
| Spring View Resolver | <bean class="InternalResourceViewResolver"> |
| Spring Form Tag | <form:form modelAttribute="student"> |
| Spring Form Input | <form:input path="name"/> |
| Spring Form Errors | <form:errors path="name"/> |
17. Exam-Focused Points
- Swing — GUI toolkit for desktop applications.
- JFrame — Top-level container (main window).
- JPanel — Grouping container.
- JLabel, JTextField, JButton — Basic components.
- Layout Managers — FlowLayout, BorderLayout, GridLayout.
- Delegation Event Model — Source → Event → Listener.
- ActionListener — Handles button clicks.
- Event Adapters — Default implementations for listeners.
- IDE Features — Code editor, auto-complete, debugging.
- Breakpoints — Pause execution for debugging.
- Calculator App — Classic Swing example.
- Swing + JDBC — Database connectivity in desktop apps.
- Spring — Enterprise Java framework.
- IoC — Inversion of Control; container manages objects.
- DI — Dependency Injection; three types (Constructor, Setter, Field).
- Bean — Object managed by Spring.
- @Component, @Service, @Repository, @Controller — Stereotype annotations.
- @Autowired — Injects dependencies.
- Bean Scope — Singleton (default), Prototype.
- @PostConstruct / @PreDestroy — Lifecycle callbacks.
- DispatcherServlet — Front controller in Spring MVC.
- @RequestMapping — Maps URLs to controllers.
- View Resolver — Maps view names to JSP pages.
- Form Tag Library — Spring JSP form tags.
- Data Binding — Auto-maps form data to objects.
- Spring Validation — @NotNull, @Email, @Size, @Min, @Max.
- @Valid + BindingResult — Validation in controllers.
- Spring Modules — Core, MVC, JDBC, ORM, Security, AOP.
- Advantages of Spring — Loose coupling, testability, maintainability.
- Advantages of Swing — Platform independent, rich components, event-driven.
18. Glossary of Key Terms
| Term | Definition |
|---|---|
| Swing | Java GUI toolkit for desktop applications |
| JFrame | Top-level container (main window) |
| JPanel | Container for grouping components |
| JLabel | Component that displays text or images |
| JTextField | Component for text input |
| JButton | Clickable button component |
| JCheckBox | Component allowing multiple selections |
| Layout Manager | Controls component arrangement |
| FlowLayout | Arranges components left to right |
| BorderLayout | Arranges components in 5 regions |
| GridLayout | Arranges components in a grid |
| Event | Action generated by user interaction |
| ActionListener | Interface for handling button clicks |
| Event Adapter | Class providing default listener implementations |
| IDE | Integrated Development Environment |
| Breakpoint | Pause point for debugging |
| Spring | Enterprise Java framework |
| IoC | Inversion of Control; container manages objects |
| DI | Dependency Injection; providing dependencies |
| Bean | Object managed by Spring |
| @Component | Stereotype annotation for Spring beans |
| @Autowired | Annotation for dependency injection |
| @Service | Stereotype for service-layer beans |
| @Repository | Stereotype for data-access beans |
| @Controller | Stereotype for MVC controllers |
| Singleton Scope | One bean instance per container |
| Prototype Scope | New bean instance per request |
| @PostConstruct | Lifecycle callback after initialization |
| @PreDestroy | Lifecycle callback before destruction |
| DispatcherServlet | Front controller in Spring MVC |
| View Resolver | Maps view names to JSP pages |
| @RequestMapping | Maps URLs to controller methods |
| Form Tag Library | Spring JSP tags for forms |
| Data Binding | Auto-mapping form data to objects |
| @Valid | Triggers validation on a model object |
| BindingResult | Holds validation errors |
| @NotNull | Validation: value cannot be null |
| Validation: valid email format | |
| @Size | Validation: length constraints |
| @Min / @Max | Validation: numeric range |