BTCE | 5th Sem
Adv-Java SubjectUnit 4

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

#FeatureExplanation
1GUI ToolkitProvides components for desktop applications
2Platform IndependentRuns on different operating systems
3Lightweight ComponentsImplemented in Java, not OS-dependent
4Rich ComponentsJFrame, JLabel, JTextField, JButton, JCheckBox, JRadioButton, JComboBox, JTable
5Event HandlingUses event listeners to respond to user actions
6Easy to Build FormsLogin, registration, calculator, student management
7Separation of GUI and LogicInterface 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!" appears

2. 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

FeaturePurposeExample
Code EditorSyntax highlightingSystem.out.println("Hello");
Auto CompletionSuggests methods and classesType Syso → suggests System.out.println
Error DetectionHighlights syntax errorsRed underlines
Debugging ToolsFind program errorsBreakpoints, step into
Project ManagementOrganizes files and packagesFolder structure

2.3 Project Creation Steps

Steps in NetBeans/Eclipse:

StepAction
1File → New Project
2Select Java Application
3Enter Project Name (e.g., SwingDemo)
4Create Main Class

Example:

public class SwingDemo {
    public static void main(String[] args) {
        System.out.println("Project Created Successfully");
    }
}

Output:

Project Created Successfully

2.4 Code Management

Organizing source code using packages.

package student;

public class Student {
}

Benefits:

  1. Better organization
  2. Easy maintenance
  3. 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

ComponentPurpose
JFrameMain window
JLabelDisplays text
JTextFieldAccepts text input
JButtonCreates a button
JCheckBoxAllows selection
JRadioButtonAllows one choice from a group
JComboBoxDrop-down list
JTableDisplays tabular data
JPanelGroups components
JMenuBarMenu 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 D

4.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:

  1. Source — The component that generates the event
  2. Event Object — Contains event information
  3. Listener — Receives and handles the event
Button → ActionEvent → ActionListener

5.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

ListenerPurpose
ActionListenerButton events
MouseListenerMouse events
KeyListenerKeyboard events
WindowListenerWindow 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:

  1. Less coding
  2. Override only required methods

6. Desktop Application Development

6.1 Working of Front-End Applications

GUI Design Principles

A good GUI should be:

  1. Simple
  2. Consistent
  3. Responsive
  4. 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 + JButton

6.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

  1. Platform Independent
  2. Rich GUI Components
  3. Event-Driven Programming
  4. Easy Database Integration
  5. 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 Transactions

7.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:

  1. Faster development
  2. Easy maintenance
  3. 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 AOP

Example: A web application may use Spring Core + Spring MVC + Spring JDBC without using other modules.

Benefits:

  1. Flexibility
  2. Easy Integration
  3. 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 automatically

Benefits:

  1. Loose Coupling
  2. Better Testing
  3. 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:

  1. BeanFactory
  2. ApplicationContext
  3. 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 objects

Spring Approach:

@Autowired
StudentDAO dao;   // Spring creates and injects objects

IoC Flow:

Application
    ↓
Spring Container
    ↓
Object Creation
    ↓
Dependency Injection

9.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:

  1. Object Creation
  2. Dependency Injection
  3. Lifecycle Management
  4. Configuration Management

Example:

ApplicationContext context =
    new ClassPathXmlApplicationContext("beans.xml");

9.4 Advantages of IoC

  1. Loose Coupling
  2. Easier Testing
  3. Better Maintainability
  4. Reusability
  5. 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:

  1. Mandatory Dependencies
  2. 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:

  1. Optional Dependencies
  2. Flexible Configuration

10.4 Field Injection

Uses @Autowired.

@Service
public class StudentService {
    @Autowired
    private StudentDAO dao;
}

Advantages:

  1. Less Code
  2. Simple Configuration

Disadvantages:

  • Difficult to test

10.5 Dependency Resolution

Spring resolves dependencies automatically.

@Autowired
private StudentDAO dao;

Spring searches:

  1. Matching Bean
  2. Matching Type
  3. Matching Name

10.6 Comparison of DI Techniques

TechniqueInjection PointMandatory?Testability
ConstructorConstructorYesBest
SetterSetter methodNoGood
FieldField directlyYesPoor

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 Object

11.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 3

11.3 Difference Between Singleton and Prototype

AspectSingletonPrototype
ObjectsOne ObjectMultiple Objects
DefaultYesExplicit Scope
MemoryLess MemoryMore Memory
Use CaseStateless beansStateful 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 Removed

12. Spring MVC Configuration

12.1 Dispatcher Servlet

Front Controller of Spring MVC.

Flow:

Browser
    ↓
DispatcherServlet
    ↓
Controller
    ↓
View

Configuration:

<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

AnnotationPurpose
@NotNullCannot be null
@NotEmptyCannot be empty
@SizeLength validation
@EmailEmail validation
@MinMinimum value
@MaxMaximum 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

  1. Separation of Concerns
  2. Easy Validation
  3. Powerful Request Mapping
  4. Flexible View Management
  5. 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 techniques

16. Key Syntax — Quick Reference

ConceptSyntax/Example
Import Swingimport javax.swing.*;
Create JFrameJFrame frame = new JFrame("Title");
Create JLabelJLabel label = new JLabel("Text");
Create JTextFieldJTextField tf = new JTextField();
Create JButtonJButton btn = new JButton("Click");
Create JCheckBoxJCheckBox cb = new JCheckBox("Java");
Create JPanelJPanel panel = new JPanel();
Set Boundscomponent.setBounds(x, y, width, height);
Add Componentframe.add(component);
Set Sizeframe.setSize(400, 300);
Set Layoutframe.setLayout(new FlowLayout());
Set Close Operationframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Set Visibleframe.setVisible(true);
Add ActionListenerbutton.addActionListener(e -> {...});
Show DialogJOptionPane.showMessageDialog(frame, "Message");
GridLayoutframe.setLayout(new GridLayout(2, 2));
BorderLayoutframe.setLayout(new BorderLayout());
FlowLayoutframe.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

  1. Swing — GUI toolkit for desktop applications.
  2. JFrame — Top-level container (main window).
  3. JPanel — Grouping container.
  4. JLabel, JTextField, JButton — Basic components.
  5. Layout Managers — FlowLayout, BorderLayout, GridLayout.
  6. Delegation Event Model — Source → Event → Listener.
  7. ActionListener — Handles button clicks.
  8. Event Adapters — Default implementations for listeners.
  9. IDE Features — Code editor, auto-complete, debugging.
  10. Breakpoints — Pause execution for debugging.
  11. Calculator App — Classic Swing example.
  12. Swing + JDBC — Database connectivity in desktop apps.
  13. Spring — Enterprise Java framework.
  14. IoC — Inversion of Control; container manages objects.
  15. DI — Dependency Injection; three types (Constructor, Setter, Field).
  16. Bean — Object managed by Spring.
  17. @Component, @Service, @Repository, @Controller — Stereotype annotations.
  18. @Autowired — Injects dependencies.
  19. Bean Scope — Singleton (default), Prototype.
  20. @PostConstruct / @PreDestroy — Lifecycle callbacks.
  21. DispatcherServlet — Front controller in Spring MVC.
  22. @RequestMapping — Maps URLs to controllers.
  23. View Resolver — Maps view names to JSP pages.
  24. Form Tag Library — Spring JSP form tags.
  25. Data Binding — Auto-maps form data to objects.
  26. Spring Validation — @NotNull, @Email, @Size, @Min, @Max.
  27. @Valid + BindingResult — Validation in controllers.
  28. Spring Modules — Core, MVC, JDBC, ORM, Security, AOP.
  29. Advantages of Spring — Loose coupling, testability, maintainability.
  30. Advantages of Swing — Platform independent, rich components, event-driven.

18. Glossary of Key Terms

TermDefinition
SwingJava GUI toolkit for desktop applications
JFrameTop-level container (main window)
JPanelContainer for grouping components
JLabelComponent that displays text or images
JTextFieldComponent for text input
JButtonClickable button component
JCheckBoxComponent allowing multiple selections
Layout ManagerControls component arrangement
FlowLayoutArranges components left to right
BorderLayoutArranges components in 5 regions
GridLayoutArranges components in a grid
EventAction generated by user interaction
ActionListenerInterface for handling button clicks
Event AdapterClass providing default listener implementations
IDEIntegrated Development Environment
BreakpointPause point for debugging
SpringEnterprise Java framework
IoCInversion of Control; container manages objects
DIDependency Injection; providing dependencies
BeanObject managed by Spring
@ComponentStereotype annotation for Spring beans
@AutowiredAnnotation for dependency injection
@ServiceStereotype for service-layer beans
@RepositoryStereotype for data-access beans
@ControllerStereotype for MVC controllers
Singleton ScopeOne bean instance per container
Prototype ScopeNew bean instance per request
@PostConstructLifecycle callback after initialization
@PreDestroyLifecycle callback before destruction
DispatcherServletFront controller in Spring MVC
View ResolverMaps view names to JSP pages
@RequestMappingMaps URLs to controller methods
Form Tag LibrarySpring JSP tags for forms
Data BindingAuto-mapping form data to objects
@ValidTriggers validation on a model object
BindingResultHolds validation errors
@NotNullValidation: value cannot be null
@EmailValidation: valid email format
@SizeValidation: length constraints
@Min / @MaxValidation: numeric range

On this page

1. Introduction to Java Swings1.1 What is Java Swing?1.2 Important Points about Swing1.3 Simple Swing Example1.4 Swing Workflow (14 Steps)2. Introduction to IDE2.1 What is an IDE?2.2 Features of IDEs2.3 Project Creation Steps2.4 Code Management2.5 Debugging Tools3. Swing Components3.1 JLabel3.2 JTextField3.3 JButton3.4 JCheckBox3.5 Common Swing Components4. Containers and Controls4.1 JFrame4.2 JPanel4.3 Layout ManagersFlowLayoutBorderLayoutGridLayout4.4 Event Controls5. Event Handling in Swing5.1 Event Model5.2 Action Events5.3 Event Listeners5.4 Event Adapters6. Desktop Application Development6.1 Working of Front-End ApplicationsGUI Design PrinciplesUser InteractionEvent-Driven ProgrammingInterface Development6.2 Calculator Application DevelopmentUser Interface DesignArithmetic OperationsEvent HandlingResult DisplayComplete Calculator Example6.3 Database Connectivity in SwingConnecting Swing with JDBCData RetrievalData Manipulation6.4 Swing Application Case StudiesStudent Management SystemLibrary Management SystemEmployee Management SystemInventory Management System6.5 Advantages of Swing7. Spring Framework Fundamentals7.1 What is Spring?7.2 Spring Framework Architecture7.3 Features of Spring Framework7.3.1 Lightweight Framework7.3.2 Modular Design7.3.3 Dependency Management7.3.4 Enterprise Application Support8. Spring Architecture8.1 Architecture Overview8.2 Core Container8.3 Data Access Layer8.4 Web Layer8.5 Integration Layer9. Inversion of Control (IoC)9.1 IoC Concept9.2 Bean Management9.3 Container Services9.4 Advantages of IoC10. Dependency Injection Techniques10.1 What is Dependency Injection?10.2 Constructor Injection10.3 Setter Injection10.4 Field Injection10.5 Dependency Resolution10.6 Comparison of DI Techniques11. Bean Scope and Bean Lifecycle11.1 Singleton Scope11.2 Prototype Scope11.3 Difference Between Singleton and Prototype11.4 Bean Initialization11.5 Bean Destruction11.6 Bean Lifecycle Summary12. Spring MVC Configuration12.1 Dispatcher Servlet12.2 Configuration Files12.3 Controller Setup12.4 View Resolver13. Request Mapping and Form Tag Library13.1 RequestMapping Annotation13.2 URL Mapping13.3 Form Tags13.4 Data Binding14. Spring Validation14.1 Validation Framework14.2 Error Handling14.3 Validation Annotations14.4 Form Validation Techniques14.5 Advantages of Spring MVC15. Unit Summary16. Key Syntax — Quick Reference17. Exam-Focused Points18. Glossary of Key Terms