SlideShare a Scribd company logo
1 of 5
Download to read offline
Material 3
31
main Method
The main method provides the control of
program flow. The Java interpreter
executes the application by invoking the
main method.
The main method looks like this:
public static void main(String[] args) {
// Statements;
}
32
Displaying Text in a Message
Dialog Box
you can use the showMessageDialog
method in the JOptionPane class.
JOptionPane is one of the many
predefined classes in the Java system,
which can be reused rather than
ā€œreinventing the wheel.ā€
RunSource
33
The showMessageDialog Method
JOptionPane.showMessageDialog(null, "Welcome to
Java!",
"Example 1.2",
JOptionPane.INFORMATION_MESSAGE));
34
The exit Method
Use Exit to terminate the program and stop
all threads.
NOTE: When your program starts, a thread
is spawned to run the program. When the
showMessageDialog is invoked, a separate
thread is spawned to run this method. The
thread is not terminated even you close the
dialog box. To terminate the thread, you
have to invoke the exit method.

More Related Content

Similar to Lo3

21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
SathwikO33
Ā 
Chapter 2.4
Chapter 2.4Chapter 2.4
Chapter 2.4
sotlsoc
Ā 
Md09 multithreading
Md09 multithreadingMd09 multithreading
Md09 multithreading
Rakesh Madugula
Ā 
M C6java3
M C6java3M C6java3
M C6java3
mbruggen
Ā 
Java
JavaJava
Java
mbruggen
Ā 
Delphi - Howto Threads
Delphi - Howto ThreadsDelphi - Howto Threads
Delphi - Howto Threads
Niall Munro
Ā 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall session
Narinder Kumar
Ā 
polymorphismpresentation-160825122725.pdf
polymorphismpresentation-160825122725.pdfpolymorphismpresentation-160825122725.pdf
polymorphismpresentation-160825122725.pdf
BapanKar2
Ā 

Similar to Lo3 (20)

21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
Ā 
Chapter 2.4
Chapter 2.4Chapter 2.4
Chapter 2.4
Ā 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
Ā 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Ā 
Md09 multithreading
Md09 multithreadingMd09 multithreading
Md09 multithreading
Ā 
M C6java3
M C6java3M C6java3
M C6java3
Ā 
Java
JavaJava
Java
Ā 
Java applet
Java appletJava applet
Java applet
Ā 
Java applets
Java appletsJava applets
Java applets
Ā 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Ā 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Ā 
Delphi - Howto Threads
Delphi - Howto ThreadsDelphi - Howto Threads
Delphi - Howto Threads
Ā 
OOFeatures_revised-2.pptx
OOFeatures_revised-2.pptxOOFeatures_revised-2.pptx
OOFeatures_revised-2.pptx
Ā 
Lesson12 other behavioural patterns
Lesson12 other behavioural patternsLesson12 other behavioural patterns
Lesson12 other behavioural patterns
Ā 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
Ā 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
Ā 
Analysis of a basic java program
Analysis of a basic java programAnalysis of a basic java program
Analysis of a basic java program
Ā 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall session
Ā 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
Ā 
polymorphismpresentation-160825122725.pdf
polymorphismpresentation-160825122725.pdfpolymorphismpresentation-160825122725.pdf
polymorphismpresentation-160825122725.pdf
Ā 

More from liankei

More from liankei (20)

Lo 19
Lo 19Lo 19
Lo 19
Ā 
Lo 18
Lo 18Lo 18
Lo 18
Ā 
Lo 13
Lo 13Lo 13
Lo 13
Ā 
Lo 12
Lo 12Lo 12
Lo 12
Ā 
Lo 11
Lo 11Lo 11
Lo 11
Ā 
Lo 06
Lo 06Lo 06
Lo 06
Ā 
Lo 05
Lo 05Lo 05
Lo 05
Ā 
Lo 04
Lo 04Lo 04
Lo 04
Ā 
Lo 01
Lo 01Lo 01
Lo 01
Ā 
Lo 16
Lo 16Lo 16
Lo 16
Ā 
Lo 15
Lo 15Lo 15
Lo 15
Ā 
Lo 09
Lo 09Lo 09
Lo 09
Ā 
Lo 08
Lo 08Lo 08
Lo 08
Ā 
Lo 03
Lo 03Lo 03
Lo 03
Ā 
Lo 20
Lo 20Lo 20
Lo 20
Ā 
Lo19
Lo19Lo19
Lo19
Ā 
Lo20
Lo20Lo20
Lo20
Ā 
Lo17
Lo17Lo17
Lo17
Ā 
Lo18
Lo18Lo18
Lo18
Ā 
Lo15
Lo15Lo15
Lo15
Ā 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
Ā 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Ā 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Ā 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Ā 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Ā 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
Ā 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
Ā 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Ā 

Lo3

  • 2. 31 main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; }
  • 3. 32 Displaying Text in a Message Dialog Box you can use the showMessageDialog method in the JOptionPane class. JOptionPane is one of the many predefined classes in the Java system, which can be reused rather than ā€œreinventing the wheel.ā€ RunSource
  • 4. 33 The showMessageDialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2", JOptionPane.INFORMATION_MESSAGE));
  • 5. 34 The exit Method Use Exit to terminate the program and stop all threads. NOTE: When your program starts, a thread is spawned to run the program. When the showMessageDialog is invoked, a separate thread is spawned to run this method. The thread is not terminated even you close the dialog box. To terminate the thread, you have to invoke the exit method.