SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette

Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryOXUS 20
 
Revision c odesagain
Revision c odesagainRevision c odesagain
Revision c odesagainrex0721
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART IIOXUS 20
 
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 JavaOXUS 20
 
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 ExplanationOXUS 20
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and GraphicsOXUS 20
 
Conditional Statement
Conditional Statement Conditional Statement
Conditional Statement OXUS 20
 
TKP Java Notes for Teaching Kids Programming
TKP Java Notes for Teaching Kids ProgrammingTKP Java Notes for Teaching Kids Programming
TKP Java Notes for Teaching Kids ProgrammingLynn Langit
 
Everything about Object Oriented Programming
Everything about Object Oriented ProgrammingEverything about Object Oriented Programming
Everything about Object Oriented ProgrammingAbdul Rahman Sherzad
 
Java Regular Expression PART I
Java Regular Expression PART IJava Regular Expression PART I
Java Regular Expression PART IOXUS 20
 
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 ClassesOXUS 20
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesOXUS 20
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number TutorialOXUS 20
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticOXUS 20
 
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 TechnologiesOXUS 20
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsOXUS 20
 
Note - Java Remote Debug
Note - Java Remote DebugNote - Java Remote Debug
Note - Java Remote Debugboyw165
 
Core java notes with examples
Core java notes with examplesCore java notes with examples
Core java notes with examplesbindur87
 
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 ClassesAbdul Rahman Sherzad
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesAbdul Rahman Sherzad
 

En vedette (20)

Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
 
Revision c odesagain
Revision c odesagainRevision c odesagain
Revision c odesagain
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART II
 
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
 
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
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
 
Conditional Statement
Conditional Statement Conditional Statement
Conditional Statement
 
TKP Java Notes for Teaching Kids Programming
TKP Java Notes for Teaching Kids ProgrammingTKP Java Notes for Teaching Kids Programming
TKP Java Notes for Teaching Kids Programming
 
Everything about Object Oriented Programming
Everything about Object Oriented ProgrammingEverything about Object Oriented Programming
Everything about Object Oriented Programming
 
Java Regular Expression PART I
Java Regular Expression PART IJava Regular Expression PART I
Java Regular Expression PART I
 
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
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non Static
 
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
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
 
Note - Java Remote Debug
Note - Java Remote DebugNote - Java Remote Debug
Note - Java Remote Debug
 
Core java notes with examples
Core java notes with examplesCore java notes with examples
Core java notes with examples
 
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
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
 

Similaire à Create Splash Screen with Java Step by Step

The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsHaim Michael
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CNjojule
 
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 userTom Croucher
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)Alexander Casall
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1rajivmordani
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?Ankara JUG
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART IOXUS 20
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webpjcozzi
 
Hybrid App using WordPress
Hybrid App using WordPressHybrid App using WordPress
Hybrid App using WordPressHaim Michael
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART IIOXUS 20
 
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山Microsoft
 
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍민태 김
 

Similaire à Create Splash Screen with Java Step by Step (20)

Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
 
The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid Applications
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Javascript
JavascriptJavascript
Javascript
 
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
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
27javascript
27javascript27javascript
27javascript
 
Hybrid App using WordPress
Hybrid App using WordPressHybrid App using WordPress
Hybrid App using WordPress
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART II
 
JavaScript
JavaScriptJavaScript
JavaScript
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Vaadin & Web Components
Vaadin & Web ComponentsVaadin & Web Components
Vaadin & Web Components
 
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山
Internet Explorer 10とマイクロソフトにとってのHTML5 in 岡山
 
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
 
Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
 

Plus de OXUS 20

Java Arrays
Java ArraysJava Arrays
Java ArraysOXUS 20
 
Java Methods
Java MethodsJava Methods
Java MethodsOXUS 20
 
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 AnswersOXUS 20
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART IIIOXUS 20
 
JAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIJAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIOXUS 20
 
Object Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesObject Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesOXUS 20
 

Plus de OXUS 20 (6)

Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Java Methods
Java MethodsJava Methods
Java Methods
 
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
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
 
JAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIJAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART III
 
Object Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesObject Oriented Programming with Real World Examples
Object Oriented Programming with Real World Examples
 

Dernier

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 

Dernier (20)

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

Create Splash Screen with Java Step by Step

  • 1. 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
  • 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
  • 4. Splash Screen Demo 4 https://www.facebook.com/Oxus20
  • 5. Splash Screen Demo 5 https://www.facebook.com/Oxus20
  • 6. Splash Screen Demo 6 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
  • 18. JProgressBar Output 18 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