SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 

Semelhante a 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 프레임웍민태 김
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Último (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

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