SlideShare a Scribd company logo
https://www.facebook.com/Oxus20
oxus20@gmail.com
JAVA
Splash
Screen
» JTimer
» JProgressBar
» JWindow
» Splash Screen
Prepared By: Azita Azimi
Edited By: Abdul Rahman Sherzad
Agenda
» Splash Screen
˃ Introduction
˃ Demos
» JTimer
» JProgressBar
» JWindow
» Splash Screen Code
2
https://www.facebook.com/Oxus20
Splash Screen Introduction
» A Splash Screen is an image that appears while a game or
program is loading…
» Splash Screens are typically used by particularly large
applications to notify the user that the program is in the
process of loading…
» Also, sometimes can be used for the advertisement
purpose …
3
https://www.facebook.com/Oxus20
Splash Screen Demo
4
https://www.facebook.com/Oxus20
Splash Screen Demo
5
https://www.facebook.com/Oxus20
Splash Screen Demo
6
https://www.facebook.com/Oxus20
Required Components
to Build a Splash Screen
» JTimer
» JProgressBar
» JWindow
7
https://www.facebook.com/Oxus20
JTimer (Swing Timer)
» A Swing timer (an instance of javax.swing.Timer)
fires one or more action events after a specified
delay.
˃ Do not confuse Swing timers with the general-purpose timer facility in
the java.util package.
» You can use Swing timers in two ways:
˃ To perform a task once, after a delay.
For example, the tool tip manager uses Swing timers to determine when to
show a tool tip and when to hide it.
˃ To perform a task repeatedly.
For example, you might perform animation or update a component that
displays progress toward a goal. 8
https://www.facebook.com/Oxus20
Text Clock Demo
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.Timer;
class TextClockDemo extends JFrame {
private JTextField timeField;
public TextClockDemo() {
// Customize JFrame
this.setTitle("Clock Demo");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
this.setLocationRelativeTo(null);
this.setResizable(false);
9
https://www.facebook.com/Oxus20
// Customize text field that shows the time.
timeField = new JTextField(5);
timeField.setEditable(false);
timeField.setFont(new Font("sansserif", Font.PLAIN, 48));
this.add(timeField);
// Create JTimer which calls action listener every second
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Get the current time and show it in the textfield
Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int second = now.get(Calendar.SECOND);
timeField.setText("" + hour + ":" + minute + ":" + second);
}
});
timer.start();
this.pack();
this.setVisible(true);
} 10
https://www.facebook.com/Oxus20
public static void main(String[] args) {
new TextClockDemo();
}
}
11
https://www.facebook.com/Oxus20
Text Clock Demo Output
12
https://www.facebook.com/Oxus20
JProgressBar
» A progress bar is a component in a Graphical User
Interface (GUI) used to visualize the progression of an
extended computer operation such as
˃ a download
˃ file transfer
˃ or installation
» Sometimes, the graphic is accompanied by a textual
representation of the progress in a percent format.
13
https://www.facebook.com/Oxus20
JProgressBar Constructors:
» public JProgressBar()
JProgressBar aJProgressBar = new JProgressBar();
» public JProgressBar(int orientation)
JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
JProgressBar bJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
» public JProgressBar(int minimum, int maximum)
JProgressBar aJProgressBar = new JProgressBar(0, 100);
» public JProgressBar(int orientation, int minimum, int maximum)
JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
» public JProgressBar(BoundedRangeModel model)
DefaultBoundedRangeModel model = new DefaultBoundedRangeModel(0, 0, 0, 250);
JProgressBar aJProgressBar = new JProgressBar(model);
14
https://www.facebook.com/Oxus20
JProgressBar Demo
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.Timer;
public class JProgressDemo extends JFrame {
private static JProgressBar progressBar;
private Timer timer;
private static int count = 1;
private static int PROGBAR_MAX = 100;
public JProgressDemo() {
this.setTitle("JProgress Bar Demo");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setSize(300, 80);
15
https://www.facebook.com/Oxus20
progressBar = new JProgressBar();
progressBar.setMaximum(100);
progressBar.setForeground(new Color(2, 8, 54));
progressBar.setStringPainted(true);
this.add(progressBar, BorderLayout.SOUTH);
timer = new Timer(300, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
progressBar.setValue(count);
if (PROGBAR_MAX == count) {
timer.stop();
}
count++;
}
});
timer.start();
this.setVisible(true);
}
16
https://www.facebook.com/Oxus20
public static void main(String[] args) {
new JProgressDemo();
}
}
17
https://www.facebook.com/Oxus20
JProgressBar Output
18
https://www.facebook.com/Oxus20
JWindow
» A Window object is a top-level window with no borders
and no menubar.
» The default layout for a window is BorderLayout.
» JWindow is used in splash screen in order to not be
able to close the duration of splash screen execution
and progress.
19
https://www.facebook.com/Oxus20
Splash Screen Code
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import javax.swing.Timer;
public class SplashScreen extends JWindow {
private static JProgressBar progressBar;
private static int count = 1;
private static int TIMER_PAUSE = 100;
private static int PROGBAR_MAX = 105;
private static Timer progressBarTimer;
20
https://www.facebook.com/Oxus20
public SplashScreen() {
createSplash();
}
private void createSplash() {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
JLabel splashImage = new JLabel(new ImageIcon(getClass().getResource("image.gif")));
panel.add(splashImage);
progressBar = new JProgressBar();
progressBar.setMaximum(PROGBAR_MAX);
progressBar.setForeground(new Color(2, 8, 54));
progressBar.setBorder(BorderFactory.createLineBorder(Color.black));
panel.add(progressBar, BorderLayout.SOUTH);
this.setContentPane(panel);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
startProgressBar();
} 21
https://www.facebook.com/Oxus20
private void startProgressBar() {
progressBarTimer = new Timer(TIMER_PAUSE, new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
progressBar.setValue(count);
if (PROGBAR_MAX == count) {
SplashScreen.this.dispose();
progressBarTimer.stop();
}
count++;
}
});
progressBarTimer.start();
}
public static void main(String[] args) {
new SplashScreen();
}
} 22
https://www.facebook.com/Oxus20
END
https://www.facebook.com/Oxus20
23
Ad

More Related Content

Viewers also liked (6)

Java FX
Java FXJava FX
Java FX
alpercelk
 
JavaFX introduction
JavaFX introductionJavaFX introduction
JavaFX introduction
José Maria Silveira Neto
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
OXUS 20
 
Java swing
Java swingJava swing
Java swing
Apurbo Datta
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
Vitaly Friedman
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
OXUS 20
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
Vitaly Friedman
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 

Similar to Create Splash Screen with Java Step by Step (20)

Android camera2
Android camera2Android camera2
Android camera2
Takuma Lee
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
Murat Can ALPAY
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
DroidConTLV
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mary772
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mccormicknadine86
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
Korhan Bircan
 
YQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to userYQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to user
Tom Croucher
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 
Li How To2 10
Li How To2 10Li How To2 10
Li How To2 10
guest0246eb
 
Forcetree.com writing a java program to connect to sfdc
Forcetree.com writing  a java program to connect  to sfdcForcetree.com writing  a java program to connect  to sfdc
Forcetree.com writing a java program to connect to sfdc
Edwin Vijay R
 
Android Camera Architecture
Android Camera ArchitectureAndroid Camera Architecture
Android Camera Architecture
Picker Weng
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
Andres Almiray
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
InnovationM
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
Krzysztof Szafranek
 
Naive application development
Naive application developmentNaive application development
Naive application development
Shaka Huang
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at Nackademin
Robert Nyman
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
Iram Ramrajkar
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS
Ilia Idakiev
 
Android camera2
Android camera2Android camera2
Android camera2
Takuma Lee
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
DroidConTLV
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mary772
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mccormicknadine86
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
Korhan Bircan
 
YQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to userYQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to user
Tom Croucher
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 
Forcetree.com writing a java program to connect to sfdc
Forcetree.com writing  a java program to connect  to sfdcForcetree.com writing  a java program to connect  to sfdc
Forcetree.com writing a java program to connect to sfdc
Edwin Vijay R
 
Android Camera Architecture
Android Camera ArchitectureAndroid Camera Architecture
Android Camera Architecture
Picker Weng
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
InnovationM
 
Naive application development
Naive application developmentNaive application development
Naive application development
Shaka Huang
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at Nackademin
Robert Nyman
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
Iram Ramrajkar
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS
Ilia Idakiev
 
Ad

More from Abdul Rahman Sherzad (20)

Data is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Data is the Fuel of Organizations: Opportunities and Challenges in AfghanistanData is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Data is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Abdul Rahman Sherzad
 
PHP Unicode Input Validation Snippets
PHP Unicode Input Validation SnippetsPHP Unicode Input Validation Snippets
PHP Unicode Input Validation Snippets
Abdul Rahman Sherzad
 
Iterations and Recursions
Iterations and RecursionsIterations and Recursions
Iterations and Recursions
Abdul Rahman Sherzad
 
Sorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQLSorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQL
Abdul Rahman Sherzad
 
PHP Variable variables Examples
PHP Variable variables ExamplesPHP Variable variables Examples
PHP Variable variables Examples
Abdul Rahman Sherzad
 
Cross Join Example and Applications
Cross Join Example and ApplicationsCross Join Example and Applications
Cross Join Example and Applications
Abdul Rahman Sherzad
 
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Abdul Rahman Sherzad
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and Awareness
Abdul Rahman Sherzad
 
Database Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event SchedulersDatabase Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
 
Mobile Score Notification System
Mobile Score Notification SystemMobile Score Notification System
Mobile Score Notification System
Abdul Rahman Sherzad
 
Herat Innovation Lab 2015
Herat Innovation Lab 2015Herat Innovation Lab 2015
Herat Innovation Lab 2015
Abdul Rahman Sherzad
 
Evaluation of Existing Web Structure of Afghan Universities
Evaluation of Existing Web Structure of Afghan UniversitiesEvaluation of Existing Web Structure of Afghan Universities
Evaluation of Existing Web Structure of Afghan Universities
Abdul Rahman Sherzad
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail ExplanationPHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Abdul Rahman Sherzad
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
Abdul Rahman Sherzad
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
Abdul Rahman Sherzad
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
Abdul Rahman Sherzad
 
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaFal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Abdul Rahman Sherzad
 
Web Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and TechnologiesWeb Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and Technologies
Abdul Rahman Sherzad
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Abdul Rahman Sherzad
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
Abdul Rahman Sherzad
 
Data is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Data is the Fuel of Organizations: Opportunities and Challenges in AfghanistanData is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Data is the Fuel of Organizations: Opportunities and Challenges in Afghanistan
Abdul Rahman Sherzad
 
PHP Unicode Input Validation Snippets
PHP Unicode Input Validation SnippetsPHP Unicode Input Validation Snippets
PHP Unicode Input Validation Snippets
Abdul Rahman Sherzad
 
Sorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQLSorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQL
Abdul Rahman Sherzad
 
Cross Join Example and Applications
Cross Join Example and ApplicationsCross Join Example and Applications
Cross Join Example and Applications
Abdul Rahman Sherzad
 
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Applicability of Educational Data Mining in Afghanistan: Opportunities and Ch...
Abdul Rahman Sherzad
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and Awareness
Abdul Rahman Sherzad
 
Database Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event SchedulersDatabase Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
 
Evaluation of Existing Web Structure of Afghan Universities
Evaluation of Existing Web Structure of Afghan UniversitiesEvaluation of Existing Web Structure of Afghan Universities
Evaluation of Existing Web Structure of Afghan Universities
Abdul Rahman Sherzad
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail ExplanationPHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Abdul Rahman Sherzad
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
Abdul Rahman Sherzad
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
Abdul Rahman Sherzad
 
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaFal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Abdul Rahman Sherzad
 
Web Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and TechnologiesWeb Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and Technologies
Abdul Rahman Sherzad
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Abdul Rahman Sherzad
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
Abdul Rahman Sherzad
 
Ad

Recently uploaded (20)

How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 

Create Splash Screen with Java Step by Step

  • 1. https://www.facebook.com/Oxus20 [email protected] JAVA Splash Screen » JTimer » JProgressBar » JWindow » Splash Screen Prepared By: Azita Azimi Edited By: Abdul Rahman Sherzad
  • 2. Agenda » Splash Screen ˃ Introduction ˃ Demos » JTimer » JProgressBar » JWindow » Splash Screen Code 2 https://www.facebook.com/Oxus20
  • 3. Splash Screen Introduction » A Splash Screen is an image that appears while a game or program is loading… » Splash Screens are typically used by particularly large applications to notify the user that the program is in the process of loading… » Also, sometimes can be used for the advertisement purpose … 3 https://www.facebook.com/Oxus20
  • 7. Required Components to Build a Splash Screen » JTimer » JProgressBar » JWindow 7 https://www.facebook.com/Oxus20
  • 8. JTimer (Swing Timer) » A Swing timer (an instance of javax.swing.Timer) fires one or more action events after a specified delay. ˃ Do not confuse Swing timers with the general-purpose timer facility in the java.util package. » You can use Swing timers in two ways: ˃ To perform a task once, after a delay. For example, the tool tip manager uses Swing timers to determine when to show a tool tip and when to hide it. ˃ To perform a task repeatedly. For example, you might perform animation or update a component that displays progress toward a goal. 8 https://www.facebook.com/Oxus20
  • 9. Text Clock Demo import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Calendar; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.Timer; class TextClockDemo extends JFrame { private JTextField timeField; public TextClockDemo() { // Customize JFrame this.setTitle("Clock Demo"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new FlowLayout()); this.setLocationRelativeTo(null); this.setResizable(false); 9 https://www.facebook.com/Oxus20
  • 10. // Customize text field that shows the time. timeField = new JTextField(5); timeField.setEditable(false); timeField.setFont(new Font("sansserif", Font.PLAIN, 48)); this.add(timeField); // Create JTimer which calls action listener every second Timer timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent arg0) { // Get the current time and show it in the textfield Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); int second = now.get(Calendar.SECOND); timeField.setText("" + hour + ":" + minute + ":" + second); } }); timer.start(); this.pack(); this.setVisible(true); } 10 https://www.facebook.com/Oxus20
  • 11. public static void main(String[] args) { new TextClockDemo(); } } 11 https://www.facebook.com/Oxus20
  • 12. Text Clock Demo Output 12 https://www.facebook.com/Oxus20
  • 13. JProgressBar » A progress bar is a component in a Graphical User Interface (GUI) used to visualize the progression of an extended computer operation such as ˃ a download ˃ file transfer ˃ or installation » Sometimes, the graphic is accompanied by a textual representation of the progress in a percent format. 13 https://www.facebook.com/Oxus20
  • 14. JProgressBar Constructors: » public JProgressBar() JProgressBar aJProgressBar = new JProgressBar(); » public JProgressBar(int orientation) JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL); JProgressBar bJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); » public JProgressBar(int minimum, int maximum) JProgressBar aJProgressBar = new JProgressBar(0, 100); » public JProgressBar(int orientation, int minimum, int maximum) JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL, 0, 100); » public JProgressBar(BoundedRangeModel model) DefaultBoundedRangeModel model = new DefaultBoundedRangeModel(0, 0, 0, 250); JProgressBar aJProgressBar = new JProgressBar(model); 14 https://www.facebook.com/Oxus20
  • 15. JProgressBar Demo import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JProgressBar; import javax.swing.Timer; public class JProgressDemo extends JFrame { private static JProgressBar progressBar; private Timer timer; private static int count = 1; private static int PROGBAR_MAX = 100; public JProgressDemo() { this.setTitle("JProgress Bar Demo"); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setSize(300, 80); 15 https://www.facebook.com/Oxus20
  • 16. progressBar = new JProgressBar(); progressBar.setMaximum(100); progressBar.setForeground(new Color(2, 8, 54)); progressBar.setStringPainted(true); this.add(progressBar, BorderLayout.SOUTH); timer = new Timer(300, new ActionListener() { public void actionPerformed(ActionEvent ae) { progressBar.setValue(count); if (PROGBAR_MAX == count) { timer.stop(); } count++; } }); timer.start(); this.setVisible(true); } 16 https://www.facebook.com/Oxus20
  • 17. public static void main(String[] args) { new JProgressDemo(); } } 17 https://www.facebook.com/Oxus20
  • 19. JWindow » A Window object is a top-level window with no borders and no menubar. » The default layout for a window is BorderLayout. » JWindow is used in splash screen in order to not be able to close the duration of splash screen execution and progress. 19 https://www.facebook.com/Oxus20
  • 20. Splash Screen Code import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JWindow; import javax.swing.Timer; public class SplashScreen extends JWindow { private static JProgressBar progressBar; private static int count = 1; private static int TIMER_PAUSE = 100; private static int PROGBAR_MAX = 105; private static Timer progressBarTimer; 20 https://www.facebook.com/Oxus20
  • 21. public SplashScreen() { createSplash(); } private void createSplash() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel splashImage = new JLabel(new ImageIcon(getClass().getResource("image.gif"))); panel.add(splashImage); progressBar = new JProgressBar(); progressBar.setMaximum(PROGBAR_MAX); progressBar.setForeground(new Color(2, 8, 54)); progressBar.setBorder(BorderFactory.createLineBorder(Color.black)); panel.add(progressBar, BorderLayout.SOUTH); this.setContentPane(panel); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); startProgressBar(); } 21 https://www.facebook.com/Oxus20
  • 22. private void startProgressBar() { progressBarTimer = new Timer(TIMER_PAUSE, new ActionListener() { public void actionPerformed(ActionEvent arg0) { progressBar.setValue(count); if (PROGBAR_MAX == count) { SplashScreen.this.dispose(); progressBarTimer.stop(); } count++; } }); progressBarTimer.start(); } public static void main(String[] args) { new SplashScreen(); } } 22 https://www.facebook.com/Oxus20