SlideShare a Scribd company logo
JAVA PROGRAMMING - SWING
Prof. Navya Francis
Asst. Professor
Kristu Jayanti College
SWING
• Java Swing is a popular and powerful Graphical User Interface (GUI)
toolkit that is used for developing desktop applications.
• It is a part of the Java Foundation Classes (JFC) and provides a rich set
of components and layout managers for creating a variety of GUIs.
• Java Swing is platform-independent and can be used on any operating
system that supports Java.
SWING
• It provides a set of lightweight components that are not only easy to use
but also customizable.
• Some of the commonly used components in Swing are buttons, text
fields, labels, menus, and many more.
• It also provides a robust event-handling mechanism that allows
developers to handle events generated by the graphical components.
• Some of the commonly used layout managers in Java Swing are
BorderLayout, FlowLayout, GridLayout, CardLayout, and BoxLayout.
FEATURES OF JAVA SWING
• Platform Independence: Platform independence is one of Java Swing’s
most remarkable features. It can run on any platform that supports Java.
Thus, Swing-based applications can run on Windows, Mac, Linux, or any
other Java-compatible operating system.
• Lightweight Components: Java Swing provides a set of lightweight
components that are easy to use and customizable. These components
are designed to consume less memory and use less processing power,
making Swing-based applications run efficiently.
FEATURES OF JAVA SWING
• Layout Managers: Java Swing provides a set of layout managers that
can be used to organize the graphical components in a GUI. These
layout managers enable developers to create flexible and responsive
GUIs that adapt to different screen sizes and resolutions.
• Robust Event Handling Mechanism: Java Swing provides a robust
event handling mechanism that allows developers to handle events
generated by the graphical components. Developers can register event
listeners to detect and respond to user interactions with the GUI.
FEATURES OF JAVA SWING
• Pluggable Look and Feel: Java Swing provides a pluggable look and
feels that allows developers to customize the appearance of the GUI
according to the user’s preferences. Developers can choose from several
pre-built looks and feel themes or create their own custom themes.
THE MODEL-VIEW-CONTROLLER
ARCHITECTURE
• Swing uses the model-view-controller architecture (MVC) as the
fundamental design behind each of its components. Essentially, MVC
breaks GUI components into three elements.
• Each of these elements plays a crucial role in how the component
behaves.
The MVC pattern architecture consists of three layers:
• Model: It represents the business layer of application. It is an object to carry the data that can also contain
the logic to update controller if data is changed.
• View: It represents the presentation layer of application. It is used to visualize the data that the model
contains.
• Controller: It works on both the model and view. It is used to manage the flow of application, i.e. data
in the model object and to update the view whenever data is changed.
JAVA Programming : Topic JAVA Programming Swing
• The advantages of MVC architecture are as follows:
• MVC has the feature of scalability that in turn helps the growth of application.
• The components are easy to maintain because there is less dependency.
• A model can be reused by multiple views that provides reusability of code.
• The developers can work with the three layers (Model, View, and Controller) simultaneously.
• Using MVC, the application becomes more understandable.
• Using MVC, each layer is maintained separately therefore we do not require to deal with massive
code.
• The extending and testing of application is easier.
ADVANTAGES OF MVC ARCHITECTURE
JAVA Programming : Topic JAVA Programming Swing
SWING APPLETS
• So far, we have created the applets based on AWT(Abstract Window
Toolkit) by extending the Applet class of the awt package.
• We can even create applets based on the Swing package. In order to
create such applets, we must extend JApplet class of the swing package
JAPPLET
• JApplet is a top-level container class and you should never draw on it
directly, instead you should draw on the component class like JPanel and
then add this JPanel to the JApplet
CREATING A SWING APPLET
In the upcoming code, first, we have created a swing applet by
extending JApplet class and we have added a JPanel to it.
Next, we have created a class B, which has extended JPanel class of Swing
package and have also implemented ActionListener interace to listen to
the button click event generated when buttons added to JPanel are clicked.
JAVA Programming : Topic JAVA Programming Swing

More Related Content

PPTX
Swing components
PDF
5 best Java Frameworks
PDF
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
PDF
Swing api
PDF
MVP Clean Architecture
PDF
What is Angular Programming Language.pdf
PPTX
OOP_Swing_HDCSE FOR UNDERSTANDING oop.pptx
PDF
The Brainify App - JavaFx
Swing components
5 best Java Frameworks
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
Swing api
MVP Clean Architecture
What is Angular Programming Language.pdf
OOP_Swing_HDCSE FOR UNDERSTANDING oop.pptx
The Brainify App - JavaFx

Similar to JAVA Programming : Topic JAVA Programming Swing (20)

PPTX
PPTX
SWING-AWT_Overview of Swing and AWT.pptx
ODP
JavaFX in Action Part I
PPTX
Java Training in Chennai
PPTX
Mvc ppt
PDF
MVC Seminar Presantation
PPTX
Mobile App Architectures & Coding guidelines
PDF
Step-by-Step Process of Angular Web Development
PPT
GUI design using JAVAFX.ppt
PPTX
Java Programming
PPTX
Building databound JavaScript apps with Knockoutjs
PPTX
unit1.pptx
PDF
software architecture
PPTX
MVC.pptx
PPTX
Shield UI JavaScript Chart
PPTX
spring
PPTX
21110113913.pptxElectricity is a type of
PPTX
Demo Lecture 01 Notes.pptx by Sabki Kaksha
PPTX
Demo Lecture 01 Notes paid , course notes
PPTX
A Smooth Transition to HTML5
SWING-AWT_Overview of Swing and AWT.pptx
JavaFX in Action Part I
Java Training in Chennai
Mvc ppt
MVC Seminar Presantation
Mobile App Architectures & Coding guidelines
Step-by-Step Process of Angular Web Development
GUI design using JAVAFX.ppt
Java Programming
Building databound JavaScript apps with Knockoutjs
unit1.pptx
software architecture
MVC.pptx
Shield UI JavaScript Chart
spring
21110113913.pptxElectricity is a type of
Demo Lecture 01 Notes.pptx by Sabki Kaksha
Demo Lecture 01 Notes paid , course notes
A Smooth Transition to HTML5
Ad

More from Navya Francis (11)

PPTX
Data Warehosuing & Data Mining: Apriori Algorithm
PPTX
Data Warehosuing & Data Mining: FP Growth
PPTX
C Programming: Looping Statements in C Pgm
PPTX
C Programming: Control Statements in C Pgm
PPTX
Data Warehousing & Data Mining: Introduction
PPTX
C Programming: Basic Structure of C Program
PPTX
Data Structures: Introduction to Data Structures
PPTX
JAVA Programming: Topic -AWT(Abstract Window Tool )
PPTX
Data Structures: Classification of Data Structures
PPTX
Software Engineering Topic: Risk Management
PPTX
Software Engineering: Topic: Waterfall Model
Data Warehosuing & Data Mining: Apriori Algorithm
Data Warehosuing & Data Mining: FP Growth
C Programming: Looping Statements in C Pgm
C Programming: Control Statements in C Pgm
Data Warehousing & Data Mining: Introduction
C Programming: Basic Structure of C Program
Data Structures: Introduction to Data Structures
JAVA Programming: Topic -AWT(Abstract Window Tool )
Data Structures: Classification of Data Structures
Software Engineering Topic: Risk Management
Software Engineering: Topic: Waterfall Model
Ad

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Institutional Correction lecture only . . .
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial disease of the cardiovascular and lymphatic systems
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Module 4: Burden of Disease Tutorial Slides S2 2025
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Institutional Correction lecture only . . .
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
O7-L3 Supply Chain Operations - ICLT Program
RMMM.pdf make it easy to upload and study
GDM (1) (1).pptx small presentation for students
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A systematic review of self-coping strategies used by university students to ...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

JAVA Programming : Topic JAVA Programming Swing

  • 1. JAVA PROGRAMMING - SWING Prof. Navya Francis Asst. Professor Kristu Jayanti College
  • 2. SWING • Java Swing is a popular and powerful Graphical User Interface (GUI) toolkit that is used for developing desktop applications. • It is a part of the Java Foundation Classes (JFC) and provides a rich set of components and layout managers for creating a variety of GUIs. • Java Swing is platform-independent and can be used on any operating system that supports Java.
  • 3. SWING • It provides a set of lightweight components that are not only easy to use but also customizable. • Some of the commonly used components in Swing are buttons, text fields, labels, menus, and many more. • It also provides a robust event-handling mechanism that allows developers to handle events generated by the graphical components. • Some of the commonly used layout managers in Java Swing are BorderLayout, FlowLayout, GridLayout, CardLayout, and BoxLayout.
  • 4. FEATURES OF JAVA SWING • Platform Independence: Platform independence is one of Java Swing’s most remarkable features. It can run on any platform that supports Java. Thus, Swing-based applications can run on Windows, Mac, Linux, or any other Java-compatible operating system. • Lightweight Components: Java Swing provides a set of lightweight components that are easy to use and customizable. These components are designed to consume less memory and use less processing power, making Swing-based applications run efficiently.
  • 5. FEATURES OF JAVA SWING • Layout Managers: Java Swing provides a set of layout managers that can be used to organize the graphical components in a GUI. These layout managers enable developers to create flexible and responsive GUIs that adapt to different screen sizes and resolutions. • Robust Event Handling Mechanism: Java Swing provides a robust event handling mechanism that allows developers to handle events generated by the graphical components. Developers can register event listeners to detect and respond to user interactions with the GUI.
  • 6. FEATURES OF JAVA SWING • Pluggable Look and Feel: Java Swing provides a pluggable look and feels that allows developers to customize the appearance of the GUI according to the user’s preferences. Developers can choose from several pre-built looks and feel themes or create their own custom themes.
  • 7. THE MODEL-VIEW-CONTROLLER ARCHITECTURE • Swing uses the model-view-controller architecture (MVC) as the fundamental design behind each of its components. Essentially, MVC breaks GUI components into three elements. • Each of these elements plays a crucial role in how the component behaves.
  • 8. The MVC pattern architecture consists of three layers: • Model: It represents the business layer of application. It is an object to carry the data that can also contain the logic to update controller if data is changed. • View: It represents the presentation layer of application. It is used to visualize the data that the model contains. • Controller: It works on both the model and view. It is used to manage the flow of application, i.e. data in the model object and to update the view whenever data is changed.
  • 10. • The advantages of MVC architecture are as follows: • MVC has the feature of scalability that in turn helps the growth of application. • The components are easy to maintain because there is less dependency. • A model can be reused by multiple views that provides reusability of code. • The developers can work with the three layers (Model, View, and Controller) simultaneously. • Using MVC, the application becomes more understandable. • Using MVC, each layer is maintained separately therefore we do not require to deal with massive code. • The extending and testing of application is easier. ADVANTAGES OF MVC ARCHITECTURE
  • 12. SWING APPLETS • So far, we have created the applets based on AWT(Abstract Window Toolkit) by extending the Applet class of the awt package. • We can even create applets based on the Swing package. In order to create such applets, we must extend JApplet class of the swing package
  • 13. JAPPLET • JApplet is a top-level container class and you should never draw on it directly, instead you should draw on the component class like JPanel and then add this JPanel to the JApplet
  • 14. CREATING A SWING APPLET In the upcoming code, first, we have created a swing applet by extending JApplet class and we have added a JPanel to it. Next, we have created a class B, which has extended JPanel class of Swing package and have also implemented ActionListener interace to listen to the button click event generated when buttons added to JPanel are clicked.