SlideShare a Scribd company logo
Written by
Shraddha Sheth
Neel Shah
o Creating Windows
o Creating a Window
o Components and Containers
o Basics of Components
o Using Containers
o Containers Layout Managers
o Adding a Menu to a Window
o Applets

JFC – JavaTM
Foundation Classes
Encompass a group of features for constructing graphical
user interfaces (GUI).
Implemented without any native code.
“Swing” is the codename of the project that developed the
first JFC components (JFC 1.11
).
The name “Swing” is frequently used to refer to new
components and related API.
JFC includes:
The Swing Components
Dialog, Tabbed pane, Buttons, File Chooser, ...
Pluggable Look and Feel
Accessibility API
Screen readers, Braille displays, ...
Java 2DTM
API (Java 2 Platform only)
Drag and Drop (Java 2 Platform only)
Between Java applications and native applications.
Each picture shows the same program but with
a different look and feel
javax.swing.plaf.metal.MetalLookAndFeel
javax.swing.plaf.motif.MotifLookAndFeel
Javax.swing.plaf.windows.WindowsLookAn
dFeel
import javax.swing.UIManager;
static setLookAndFeel() method that is defined in the
UIManager class.
This method can throw an exception of
ClassNotFoundException if the look-and-feel class cannot be
found,
For example:
try {
 UIManager.setLookAndFeel(“com.sun.java.swing.plaf.motif.MotifL
ookAndFeel”);
} catch(Exception e) {
 System.err.println(“Look and feel not set.”);
}
UIManager.LookAndFeelInfo[]
looks = UIManager.getInstalledLookAndFeels();
for( UIManager.LookAndFeelInfo look : looks)
System.out.println(look.getClassName());
Java Default Look And Feel
UIManager.setLookAndFeel
( UIManager.getCrossPlatformLookAndFeel());
Swing provides many standard GUI components
such as buttons, lists, menus, and text areas,
which you combine to create your program's GUI.
Swing provides containers such as a window.
top level: frames, dialogs
intermediate level: panel, scroll pane, tabbed pane, ...
View Components
Descendents of the java.awt.Container class
Components that can contain other components.
Use a layout manager to position and size the
components contained in them.
Components are added to a container using one
of the various forms of its add method
Depending on which layout manager is used by the
container
panel.add(component);
Every program that presents a Swing GUI
contains at least one top-level container.
A Top level container provides the support that
Swing components need to perform their painting
and event-handling.
Swing provides four top-level containers:
JFrame (Main window)
JDialog (Base For Dialogs)
JApplet (An applet display area within a browser
window)
JWindow (Secondary Display Devices)
To appear on screen, every GUI component must be part
of a containment hierarchy, with a top-level container
as its root.
Each top-level container has a content pane that contains
visible components in that top-level container’s GUI.
A top-level container can not contain another top
level container.
A frame implemented as an instance of the JFrame
class, is a window that has decorations such as a
border, a title and buttons for closing and iconifying
the window.
Applications with a GUI typically use at least one
frame.
import javax.swing.*;
public class HelloWorldSwing {
public static void main(String[] args) {
JFrame frame = new JFrame("HelloWorldSwing");
final JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label); // 1.4
// OR USE THIS frame.add(label); JDK 5
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Position (x,y)
Name .setName() .getName();
Size
Foreground And Background Color
Font
Cursor
State (setEnabled ([True/False])) isEnable()
Visible (setVisible([True/False])) isVisible()
Valid isValid()
Position is defined by x and y coordinates of type int,
or by an object of type java.awt.Point.
Size is defined by width and height, also values of
type int, or by an object of type java.awt.Dimension.
A Rectangle specifies an area in a coordinate space
that is enclosed by the Rectangle object's upper-left
point (x,y) in the coordinate space, its width, and its
height.
The decorations on a frame are platform dependent.
A JApplet object has the same arrangement of panes
as a JFrame object.
Window class and its subclasses, as objects of type
Window (or of a subclass type) can’t be contained in
another container.

More Related Content

What's hot

Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
Mazenetsolution
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Java swing
Java swingJava swing
Java swing
Apurbo Datta
 
Swing
SwingSwing
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
Shehrevar Davierwala
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
jehan1987
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
suraj pandey
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
OXUS 20
 
Swings in java
Swings in javaSwings in java
Swings in java
Jyoti Totla
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
kirupasuchi1996
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
babak danyal
 
Jdbc
JdbcJdbc
Java swing and events
Java swing and eventsJava swing and events
Java swing and events
Prathamesh sawant
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
tL19 awt
tL19 awttL19 awt
tL19 awt
teach4uin
 

What's hot (20)

Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Java swing
Java swingJava swing
Java swing
 
Swing
SwingSwing
Swing
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
Introdu.awt
Introdu.awtIntrodu.awt
Introdu.awt
 
Swings in java
Swings in javaSwings in java
Swings in java
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
 
04b swing tutorial
04b swing tutorial04b swing tutorial
04b swing tutorial
 
Jdbc
JdbcJdbc
Jdbc
 
GUI Programming with Java
GUI Programming with JavaGUI Programming with Java
GUI Programming with Java
 
java swing
java swingjava swing
java swing
 
Java Swing
Java SwingJava Swing
Java Swing
 
Java swing and events
Java swing and eventsJava swing and events
Java swing and events
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 

Viewers also liked

java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in javaDeepak Sharma
 
Java awt
Java awtJava awt
Java awt
Arati Gadgil
 
Java applets
Java appletsJava applets
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cyclemyrajendra
 
Java applets
Java appletsJava applets
Java appletslopjuan
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
Multi-threaded Programming in JAVA
Multi-threaded Programming in JAVAMulti-threaded Programming in JAVA
Multi-threaded Programming in JAVA
Vikram Kalyani
 
Gui
GuiGui
Java/Swing
Java/SwingJava/Swing
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART II
OXUS 20
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 
Applet java
Applet javaApplet java
Applet java
Jorge Luis Tinoco
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaRaghu nath
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 

Viewers also liked (20)

java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
 
Java swing
Java swingJava swing
Java swing
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
Java awt
Java awtJava awt
Java awt
 
Java applets
Java appletsJava applets
Java applets
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Java applets
Java appletsJava applets
Java applets
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
 
Multi-threaded Programming in JAVA
Multi-threaded Programming in JAVAMulti-threaded Programming in JAVA
Multi-threaded Programming in JAVA
 
Gui
GuiGui
Gui
 
Java/Swing
Java/SwingJava/Swing
Java/Swing
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART II
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Applet java
Applet javaApplet java
Applet java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 

Similar to Java Swing

Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
Hemo Chella
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
Hemo Chella
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
TabassumMaktum
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Computer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptxComputer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptx
jonathancapitulo2
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
Viên Mai
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1sotlsoc
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
HyunJeiThaddeus
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
Narayana Swamy
 
JavaFX ALA ppt.pptx
JavaFX ALA ppt.pptxJavaFX ALA ppt.pptx
JavaFX ALA ppt.pptx
BhagyasriPatel1
 
08graphics
08graphics08graphics
08graphics
Waheed Warraich
 
Java AWT and Java FX
Java AWT and Java FXJava AWT and Java FX
Java AWT and Java FX
pratikkadam78
 
L11cs2110sp13
L11cs2110sp13L11cs2110sp13
L11cs2110sp13
karan saini
 
Java swing 1
Java swing 1Java swing 1
Java swing 1
Mukesh Tekwani
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
PriyanshiPrajapati27
 
Tycs advance java sem 5 unit 1,2,3,4 (2017)
Tycs advance java sem 5 unit 1,2,3,4 (2017)Tycs advance java sem 5 unit 1,2,3,4 (2017)
Tycs advance java sem 5 unit 1,2,3,4 (2017)
WE-IT TUTORIALS
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swingbackdoor
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
Sohanur63
 
Java session13
Java session13Java session13
Java session13
Jigarthacker
 

Similar to Java Swing (20)

Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Computer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptxComputer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptx
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
JavaFX ALA ppt.pptx
JavaFX ALA ppt.pptxJavaFX ALA ppt.pptx
JavaFX ALA ppt.pptx
 
08graphics
08graphics08graphics
08graphics
 
Java AWT and Java FX
Java AWT and Java FXJava AWT and Java FX
Java AWT and Java FX
 
L11cs2110sp13
L11cs2110sp13L11cs2110sp13
L11cs2110sp13
 
Java swing 1
Java swing 1Java swing 1
Java swing 1
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Tycs advance java sem 5 unit 1,2,3,4 (2017)
Tycs advance java sem 5 unit 1,2,3,4 (2017)Tycs advance java sem 5 unit 1,2,3,4 (2017)
Tycs advance java sem 5 unit 1,2,3,4 (2017)
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
Report swings
Report swingsReport swings
Report swings
 
Java session13
Java session13Java session13
Java session13
 

Recently uploaded

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

Java Swing

  • 2. o Creating Windows o Creating a Window o Components and Containers o Basics of Components o Using Containers o Containers Layout Managers o Adding a Menu to a Window o Applets 
  • 3. JFC – JavaTM Foundation Classes Encompass a group of features for constructing graphical user interfaces (GUI). Implemented without any native code. “Swing” is the codename of the project that developed the first JFC components (JFC 1.11 ). The name “Swing” is frequently used to refer to new components and related API.
  • 4. JFC includes: The Swing Components Dialog, Tabbed pane, Buttons, File Chooser, ... Pluggable Look and Feel Accessibility API Screen readers, Braille displays, ... Java 2DTM API (Java 2 Platform only) Drag and Drop (Java 2 Platform only) Between Java applications and native applications.
  • 5. Each picture shows the same program but with a different look and feel javax.swing.plaf.metal.MetalLookAndFeel javax.swing.plaf.motif.MotifLookAndFeel Javax.swing.plaf.windows.WindowsLookAn dFeel
  • 6. import javax.swing.UIManager; static setLookAndFeel() method that is defined in the UIManager class. This method can throw an exception of ClassNotFoundException if the look-and-feel class cannot be found, For example: try {  UIManager.setLookAndFeel(“com.sun.java.swing.plaf.motif.MotifL ookAndFeel”); } catch(Exception e) {  System.err.println(“Look and feel not set.”); }
  • 7. UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels(); for( UIManager.LookAndFeelInfo look : looks) System.out.println(look.getClassName()); Java Default Look And Feel UIManager.setLookAndFeel ( UIManager.getCrossPlatformLookAndFeel());
  • 8. Swing provides many standard GUI components such as buttons, lists, menus, and text areas, which you combine to create your program's GUI. Swing provides containers such as a window. top level: frames, dialogs intermediate level: panel, scroll pane, tabbed pane, ... View Components
  • 9. Descendents of the java.awt.Container class Components that can contain other components. Use a layout manager to position and size the components contained in them. Components are added to a container using one of the various forms of its add method Depending on which layout manager is used by the container panel.add(component);
  • 10.
  • 11. Every program that presents a Swing GUI contains at least one top-level container. A Top level container provides the support that Swing components need to perform their painting and event-handling. Swing provides four top-level containers: JFrame (Main window) JDialog (Base For Dialogs) JApplet (An applet display area within a browser window) JWindow (Secondary Display Devices)
  • 12.
  • 13. To appear on screen, every GUI component must be part of a containment hierarchy, with a top-level container as its root. Each top-level container has a content pane that contains visible components in that top-level container’s GUI. A top-level container can not contain another top level container.
  • 14.
  • 15. A frame implemented as an instance of the JFrame class, is a window that has decorations such as a border, a title and buttons for closing and iconifying the window. Applications with a GUI typically use at least one frame.
  • 16.
  • 17. import javax.swing.*; public class HelloWorldSwing { public static void main(String[] args) { JFrame frame = new JFrame("HelloWorldSwing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); // 1.4 // OR USE THIS frame.add(label); JDK 5 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  • 18.
  • 19.
  • 20.
  • 21. Position (x,y) Name .setName() .getName(); Size Foreground And Background Color Font Cursor State (setEnabled ([True/False])) isEnable() Visible (setVisible([True/False])) isVisible() Valid isValid()
  • 22. Position is defined by x and y coordinates of type int, or by an object of type java.awt.Point. Size is defined by width and height, also values of type int, or by an object of type java.awt.Dimension. A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's upper-left point (x,y) in the coordinate space, its width, and its height.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. The decorations on a frame are platform dependent. A JApplet object has the same arrangement of panes as a JFrame object. Window class and its subclasses, as objects of type Window (or of a subclass type) can’t be contained in another container.